orb.breq.dev

Web-based control of my desk light using HomeAssistant

created
  • home automation
  • python

Sitting right next to my desk as I type this is an IKEA FADO lamp fitted with an RGBW LED bulb. Among friends, it's become affectionately known as "the orb" due to its unique shape.

Link to this section Implementation

This project uses quite a few moving parts to pipe lighting data through from the user's browser into a smart light bulb. I'll trace the flow through each of these components.

The user chooses a color through a basic web UI written in vanilla HTML, CSS, and JS. There's a sketch of the orb that I made in Inkscape to provide a preview.

The UI makes calls to a Flask-based backend, which turns around and calls HomeAssistant. This layer exists only to allow unauthenticated users to call these two specific methods on the HomeAssistant API (since the Flask app keeps a bearer token around). I deployed this on Dokku, which is a stack I've developed a strong familiarity with.

While I initially tried to make this project work with Google Home, I couldn't find an API that would allow me to invoke commands programmatically. Ava and I had been looking for an excuse to migrate to HomeAssistant for a while, and this was it! We found the setup process to be quite straightforward: most of our smart devices are Matter bulbs, which could easily be added to both Google Home and HomeAssistant.

HomeAssistant gives each entity an "Entity ID", which makes programming easy. The orb light is just lights.orb! While finding the right documentation was a bit difficult, invoking actions on entities through the REST API was overall easy and straightforward.

We've deployed HomeAssistant to a Proxmox server running in our home mini-rack. Since our HomeAssistant instance is publicly routable at homeassistant.home.breq.dev, no special considerations were needed for piping together the Flask app deployed in the cloud with HomeAssistant running in our home network.

Link to this section Results

In and of itself, the orb demo isn't that interesting, especially because you need to actually be in front of the light to see it working (and if you're already physically in my apartment, you can just use the Google Home to set the light). That said, it's a fun party trick, and I enjoyed finally being able to interact with my smart home devices easily from code! I'm definitely looking forward to doing more smart home projects in the future.