A hacky Node module for simulating Flux for my Hue "Bathroom" light group
- Get the IP address of your Hue Bridge and generate a username
- Install dependencies:
npm install
- 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
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
- In
cron.txt
:5 7,20 * * * $HOME/cron/hue-lights.sh > /dev/null 2>&1
- 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
chmod +x cron/hue-lights.sh
- Then I create all Cron jobs by running:
crontab cron.txt
- 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)
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.
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.
- Send
POST /api
with body{"devicetype":"foobar"}
- You'll get an error in return, that's okay.
- Press the button on the Hue Bridge
- Send the request again
GET http://{{ip}}/api/{{username}}
PUT http://{{ip}}/api/{{username}}/lights/{{id}}/state
{"on": true, "bri": 77}