Lurker News
Curious to know if anyone has written programs for their own, regular, & personal use. And if so what they are? E.g. A colleague of mine tracks all of his homes energy use through a custom program which disaggregates the energy consumption per device and outputs a report to a tablet.

Comments (651) 385 threads

Show all comments

Showing thread 82 of 385

jffry4 replies#
Most of my light bulbs are color-temperature-adjustable. So I wrote a small program which varies the color temperature throughout the day and night.

I started by matching it to the solar elevation, but ultimately I like it more just on a fixed schedule. I've also programmed it to make a more dramatic warm shift near bedtime, and to fade up a bedroom light when it's time to wake up.
Due to the inevitability of scope creep this system also now tracks the charging status and position of my robot vacuum, and I'm working to expand it to collect the 15-minute-interval usage data from my electric provider's website.

ryanchants1 reply#
I've been wanting to build something like your light system. What smart lights do you use?
jffry#
Hue bulbs, the kind that talk to a central bridge over, I believe, ZigBee.

The bridge just hooks up over ethernet and provides a locally accessible no-nonsense REST api that is surprisingly well documented (sadly requires logging in with a free account: https://developers.meethue.com/develop/hue-api/ ).
Authentication is simple. Press the big button on the bridge, hit an API endpoint within 30 seconds, and you get an auth token.
The only other requests I needed were a GET to list the id and status of all bulbs, and a POST per bulb that is on to change its color temperature (you cannot set color temp of a bulb that is off).

arthurofbabylon1 reply#
Super curious about the inter-workings of this system
jsf011 reply#
I was about to make something just like your light bulb system for my own home (minus the vacuum part anyway). Any chance that code is open source? Very interested in any other details you’d be willing to share.
jffry#
It's not open source, but the good news is it's relatively simple. My bulbs are Hue bulbs which use their bridge/hub, which just plugs into ethernet and provides a REST API.

The basic loop, run once per minute is:
- Make one API call which returns the id/on/off/brightness of every bulb
- For each bulb that is on, set its color temperature (this has to be one API call per bulb because there is no way to bulk update a list of bulbs. Bulbs can be put into at most one "room" and you can bulk set a whole room but not a subset of bulbs in that room)
As far as scheduling color temperature goes - I just define a few keyframes based on minutes since midnight local time, and then linearly interpolate to get the color temp. Over 24 hours the steps are so small that the change is basically imperceptible.

Cd00d#
Really clever idea - thank you for sharing!