I released v1.0.0 of huey today, adding some exciting new features: specifically, light groups and group events. Using them enabled me to quickly and easily set up a light timing schedule from one of my home machines, managed with cron (through the excellent whenever gem). In case you too would like awesome automatic light magic, here’s how to make it work.
Huey v1.0.0
New in huey v1.0.0 are light groups: arbitrary collections of bulbs on which you can run commands simultaneously. Getting them to work is ridiculously simple:
1 2 3 4 |
|
Once you have a group set up, you can act on all its bulbs simultaneously as you would on any individual bulb.
1 2 3 4 5 6 7 |
|
Of course, you probably want to do the same actions to groups over and over again: for example, dimming all your lights at night and brightening them in the morning. For that we have a shorthand called events:
1 2 |
|
YAML Setup
Huey can read your groups and events from YAML configuration files. Here’s a sample from my setup:
1 2 3 4 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
1 2 3 |
|
I’m setting up three groups here, called Study, Bedroom, and Living Room. I have a lot of potential events and I selected two to show here: what happens when we wake up, and the corresponding later afternoon setup. (If we end up hating this it’s likely to change, but it gives you an idea how this is supposed to work, anyhow.) Once everything is slurped in, running an event is simple.
Whenever
Finally, I have it all stitched together through whenever, because who likes reading crontabs? When you set up whenever, it creates a file called config/schedule.rb that it uses to read the crontab. I altered mine to include this:
1 2 3 4 5 |
|
To install your new crontab, use whenever --update-crontab
.
That’s all there is to it! Now your Hue lights will work in perfect synchronization with the schedule you’ve provided, allowing you to set up your home lighting system however you like, and alter it easily from cron.
But there’s a lot more you can do with huey if you’d like. Why not make an event that’s triggered by an incoming email or phone call? Or set your door bell to flash your lights instead of ring a chime? With events and light groups, setting up this kind of awesome automation functionality is easier than ever. So go do something cool with it!