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

hueset

v1.2.0

Published

A node module to set Phillips hue bulb parameters using env or cli params

Downloads

10

Readme

hueset

A node module to set Phillips hue bulb parameters

Installation

Hueset can be used as a global or local package. To install it locally and use it in your project, run:

npm install hueset

If you just want to control hue bulbs from the command line, install it globally. This will give you access to the hueset command line argument:

npm install -g hueset

Usage

To use hueset, you need to setup a user on your hue bridge, know your bridge's IP address, and know the light number you'd like to control. Check out this guide for getting that basic info.

var user = '12345';
var ip = '10.0.0.1';
var light = '1';
var color = 'red';

var Hue = require('hueset');
var light = new Hue.light(user, ip, light);

light.on(color);
  • user is the hash generated by creating a user on your hue bridge
  • ip is the local IP address of your hue bridge
  • light is the light number you'd like to actuate
  • color is any valid CCS color string, such as 'red' or '#ff0000'

.on([color])

Turns on the light referenced by the new Hue.light constructor. If a color is supplied, the light is set to that color when it is turned on. Lights that are already on will be set to the new color. If no color is supplied, the light's on state will be set to 'true' and use the previous color values. Lights that do not support color will use the computed brightness value of the supplied color (i.e. it's safe to set Philips Hue White bulb to 'purple'.)

light.on('red');

.get(cb(err, resp))

Get the current state of a light. This works for both color bulbs and dimmable lights. Accepts a callback function that takes two parameters, err and response - err is null for successful responses.

Response is in the format:

{
  on: Bool,
  color: Color
}

where on is a boolean, and color is an abstract Color object created with qix's color module

light.get(function(err, res){
  if (err) {
    // problem getting light info
    return;
  }
  console.log(res.on); // true or false
  console.log(res.color) // Color object
  console.log(res.color.hex()) // something like #ff0000
});

.off()

Turns off the light referenced by the new Hue.light constructor. Note that this only set's the light's on state to 'false', so subsequent calls to .on() will restore the light to the exact same color and brightness from before .off() was called.

light.off();

Global Usage

When installed globablly, you can call hueset from the command line.

CLI switches

See command line options and usage by running hueset --help

Usage: hueset [options]

  Options:

    -h, --help           output usage information
    -V, --version        output the version number
    -u, --user [value]   Hue User Name
    -i, --ip [value]     IP address of hue hub
    -l, --light <n>      Light number (1, 2, etc.)
    -c, --color [value]  Any valid CSS color ('red', #00ff33, etc.)
    -o, --off            Turn off light specified by --light

Example:

$ hueset -u '1234' -i '10.0.0.1' -l 2 -c yellow

Any of these switches overrides environment variables, so this is possible:

export hueuser=123456
export hueip=10.0.100.42
export huelight=4

command line:

$ source .env
$ hueset -c red

Omitting other actions (no color, no 'off' flag) returns a light's properties:

$ source .env
$ hueset
{ on: true,
  color: { model: 'hsv', color: [ 120, 100, 50 ], valpha: 1 } }

Environment Vars

Hueset will read environment variables. Set these on the command line, or source them from a .env file that is excluded from your SCM.

.env:

export hueuser=123456
export hueip=10.0.100.42
export huelight=4

command line:

$ source .env
$ hueset -c red

These can also be set or overridden at runtime

$ source .env
$ huelight=2 hueset -c red