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

hue-lights-flux

v1.0.0

Published

> A hacky Node module for simulating Flux for my Hue "Bathroom" light group

Downloads

1

Readme

A hacky Node module for simulating Flux for my Hue "Bathroom" light group

Getting started

  1. Get the IP address of your Hue Bridge and generate a username
  2. Install dependencies: npm install
  3. Run the script, passing in the IP address and username from step 1:
HUE_IP={IP_GOES_HERE} HUE_USER={USERNAME_GOES_HERE} npx hue-lights-flux

Running the script daily

To run the script automatically, I've setup a crontab job. My $HOME directory is structured similar to this:

~
└── cron.txt
    └── cron/
        ├── hue-lights.sh
        └── hue-lights-flux/
            └── index.js
  1. In cron.txt:
    5 7,20 * * * $HOME/cron/hue-lights.sh > /dev/null 2>&1
  2. In cron/hue-lights.sh
    #!/usr/bin/env sh
    PATH="/usr/local/bin:/usr/bin:/bin"
    
    HUE_IP={IP_GOES_HERE} HUE_USER={USERNAME_GOES_HERE} node cron/hue-lights-flux
  3. chmod +x cron/hue-lights.sh
  4. Then I create all Cron jobs by running: crontab cron.txt

Messy development notes

Hue documentation

  • https://developers.meethue.com/develop/get-started-2/
  • https://developers.meethue.com/develop/get-started-2/core-concepts/
  • https://developers.meethue.com/develop/hue-api/lights-api/

API endpoint: http://192.168.1.2/api/{{username}} (the IP address needs to be discovered through your router – yours might be different)

Tips

Don’t Always Send ‘ON’

Once you have sent the ‘ON’ attribute to a light, it will stay on. Do not repeatedly send the ‘ON’ command as this will slow the responsiveness of the bridge.

Max. Number of Commands per Second

You can send commands to the lights too fast. If you stay roughly around 10 commands per second to the /lights resource as maximum you should be fine. For /groups commands you should keep to a maximum of 1 per second.

API

Creating a new user

  1. Send POST /api with body {"devicetype":"foobar"}
  2. You'll get an error in return, that's okay.
  3. Press the button on the Hue Bridge
  4. Send the request again

Listing lights and groups

GET http://{{ip}}/api/{{username}}

Updating a light

PUT http://{{ip}}/api/{{username}}/lights/{{id}}/state

{"on": true, "bri": 77}