npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tradfri

v2.0.0-alpha.1

Published

Controll Trådfri Smart Bulbs with Node.js

Downloads

3

Readme

Node.js Trådfri library

Controll Trådfri Smart Bulbs with Node.js

Installation

npm install --save tradfri

Usage

Importing library

const Tradfri = require('tradfri')

Setting up identiy

When connecting to a new gateway, a one time setup of a new identity is needed.

// The IP address of the gateway
const ip = '10.0.0.8'

// The code on the back of the gateway
const code = 'jrzig5WPzec71IZN'

Tradfri.createIdentity(ip, code).then((result) => {
  // Store result.identity and result.preSharedKey for later use
})

Controlling light bulbs

// The IP address of the gateway
const ip = '10.0.0.8'

// The previously savied identity
const identity = 'ab452750c31b4bad85873ab0dadf062b'
const preSharedKey = 'eQG5fURURkCcTPlc'

// Create the client
const client = new Tradfri(ip, identity, preSharedKey)

// Turn on the kitchen lights
client.putGroup(150284, { on: true, color: 'f1e0b5', brightness: 203 })

API

Tradfri.createIdentity(ip, code)

Register a new identity with the gateway.

  • ip (string) The ip address of the gateway
  • code (string) The code on the back of the gateway

new Tradfri(ip, identity, preSharedKey)

Create a new Trådfri client.

  • ip (string) The ip address of the gateway
  • identity (string) The previously generated identity
  • preSharedKey (string) The previously generated pre shared key

Trafri#listGroupIds() => Promise<string[]>

Return a list of all group ids.

Tradfri#getGroup(id: string) => Promise<GroupInfo>

Get information about a specific group.

  • id (string) The id of the group

The returned information:

  • id (string) The id of the group
  • name (string) The human readable name of the group
  • deviceIds (string[]) List of ids of the devices connected to this group
  • on (boolean) Wether the bulbs in this group is turned on or not

Tradfri#getDevice(id: string) => Promise<DeviceInfo>

Get information about a specific device.

  • id (string) The id of the device

The returned information:

  • id (string) The id of the device
  • name (string) The human readable name of the device
  • type FIXME

If the device is a bulb, the following properties also exists:

  • on (boolean) Wether the bulb is turned on or not
  • color (string) The current color of the bulb
  • brightness (number) The current brightness of the bulb (0-255 inclusively)

Tradfri#putGroup(id: string, patch: GroupPatch) => Promise<void>

Update the state of a group. All properties of the patch are optional, and only the ones present will be updated.

  • id (string) The id of the group
  • patch (object)
    • on (boolean) Wether the bulbs in this group should be turned on or not
    • color (string) The new color of the bulbs
    • brightness (number) The new brightness of the bulbs (0-255 inclusively)
    • transitionTime (number) Number of milliseconds during which to transition into the new state (maximum resolution is one tenth of a second)