5 ms·
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 jffry 5y ago
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.
- ryanchants 5y agoI've been wanting to build something like your light system. What smart lights do you use?
- jffry 5y agoHue 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/ 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).
- arthurofbabylon 5y agoSuper curious about the inter-workings of this system
- jffry 5y agoHere you go! Happy to answer any other questions not answered in my other two comments: - https://news.ycombinator.com/item?id=31026875 https://news.ycombinator.com/item?id=31026875 - https://news.ycombinator.com/item?id=31026979 https://news.ycombinator.com/item?id=31026979 Fortunately this was fairly easy to implement since Hue bridges provide a locally-accessible actually-documented REST API for me to use!
- jsf01 5y agoI 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 5y agoIt'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 5y agoReally clever idea - thank you for sharing!