gh

gun-hue

Easy hue client with real-time sync

Showing:

Popularity

Downloads/wk

0

GitHub Stars

9

Maintenance

Last Commit

5yrs ago

Contributors

2

Package

Dependencies

2

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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 = require('gun-hue')
var gun = new Gun().get('hue')

typeof gun.hue // '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.hue({
    domain: '192.168.1.337',
    key: 'HfBwAl0gNPUQnmqCaxZCcNfd',
})

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.path('lights')
// Print out your available lights
lights.map().val('Lights:')

// Turn on all the lights
lights.map().path('state.on').put(true)

// Print out all the rules
hue.get('rules').map().val('Rules:')

// Listen for changes to a lights' brightness
lights.path('5.state.bri').on(change => {
    // Brightness update!
})

// Change the brightness
lights.path('5.state.bri').put(42)

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! 😊

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial