Gun-Hue
Real-time updates with hue and gunDB
What it is
This is a tiny library that syncs hue data and lets you change your lights through gunDB.
By using gun, you get some immediate benefits:
- simpler API interface
- easy real-time UI updates
- real-time updates on other client's apps
- offline editing
- street cred
How to use it
The best way to install is from npm. Here's how:
npm install gun-hue
You can import this library instead of Gun
(or just import it for side effects) and it'll add a new method to your gun instances called hue
.
var Gun = var gun = typeof gunhue // 'function'
.hue()
takes an object with the IP of the bridge and your private key. To find the bridge and get an API key, read this great guide.
gun
Once you've done that, it'll fetch the hue state and plug it in your gun instance. That's when the fun begins! Every GET/POST command hue supports is available through gun.
var lights = hue// Print out your available lightslights // Turn on all the lightslights // Print out all the ruleshue // Listen for changes to a lights' brightnesslights // Change the brightnesslights
For more stuff you can do, I shall defer to the Philips Hue API (you may need to register to see it all).
Warning
If you change the state of the lights through something other than gun after it's already connected, the state won't sync. This is because this library doesn't poll the rest service.
Once this gun issue has been resolved, I'll probably build the polling logic.
Support
Have questions? Either post an issue or tag me on Gitter (I usually hang out there as @PsychoLlama).
Thanks for checking out the project! 😊