I had three devices in my room that I wanted to control and orchestrate in unison:
For example, when working, I like to set my LIFX bulb to a warm hue and turn my corner lamp. However, when I read, I like to turn on just my corner lamp and put on a jazz playlist on my Sonos.
My dream was to easily control all these devices with a simple click of a button.
I knew I wanted to control these IoT devices from multiple devices, such as:
- 1. Flic, a Bluetooth button that can connect to many IoT devices
- 2. My terminal
- 3. My phone
Here is a diagram outlining the architecture of my solution:
The center point of this architecture is the Raspberry Pi. This is a cheap but powerful micro-controller that runs a complete Linux distribution.
The Automation Server, a classic HTTP server, runs on the Raspberry Pi, listening for requests to control the lights/speakers. When these requests arrive, the Raspberry Pi can control the lights and speakers via the APIs provided by these IoT devices.
Once I built the Automation Server, I could build the clients that would issue requests to the Automation Server. I first built a CLI that runs on my local machine that issues requests to the Automation Server, thus controlling the lights/speakers. I also built a Progressive Web App with buttons that would issue requests to the Automation Server. Building a PWA was a simple way to build a UI that could be downloaded to my phone as an app.
Lastly, and most importantly, I set up a Bluetooth Flic button to control the lights. This was more complicated since that button only issues Bluetooth requests. To get around this limitation, I set up a Flic Bluetooth server on the Raspberry Pi that could listen to button clicks from the Flic button. When those requests were received, the Flic server would issue HTTP requests to the Automation Server.