Let there be light

(Video of the thing at the bottom but the story adds great context without which you'd wonder why the hell I'd want to do something like this)

I live in Canada, my parents live in the U.A.E, and my grandma lives in India. We speak on Zoom once a week but it's a cheap substitute for real interaction. With this project I wanted to experiment with something in the IoT space that might allow them to interact with my physical space, if even just through some sort of electronic proxy.

Currently I have one Philips Hue bulb in the living room (where my desk is). Using the stock app by Philips I can manipulate it's state (on or off), colour, intensity, and even set up routines or alarms based on custom rules. I wanted to give them access to make changes to that bulbs' state. This wouldn't just be as easy as having them download the app and then connecting to my bulb because the light is connected to my home wifi via a bridge and isn't exposed to the external world (for so many good reasons!). My solution was to create a web portal that made POST requests to a custom node + express backend server that I had running. The server would redirect their requests to the Hue bulb. Hue has a pretty cool and easy to work with API that allows you to make GET requests to see the state of your bulb and PUT requests to change/alter the state as required. There were two issues here I wanted to solve for though.

a) The server had to be running 24/7. Due to the time difference, the request could potentially come in at any time and I needed to be listening for it. I tried putting it up on Heroku, but I'd have to get a paid dyno because when the server went to sleep, the requests would fail and the whole thing would fall apart.

b) The request still had to hit my lights on my home wifi somehow, and a dynamic IP address (the kind that changes every so often thanks to your ISP's) would be a problem.

I solved both by putting my server on a Raspberry Pi. I assigned it a static IP so that things would stay constant internally and the requests would get sent to the right place. The Pi then had to be exposed to the world. So I set up port-forwarding and started looking for solutions to the dynamic IP address issue. Here's what I ended up going with. They essentially solve this problem for me.

So now, my server is constantly running, even when my computer is off (plus it's free!).

For the web portal, I created a simple page that had three buttons. One that symbolized "let's talk!" that changed my light to green, one that said "I'm eating!" that turned my light red, and one that turned my light blue that meant "good night". My family or friends can now use this to send a simple message to indicate really simple emotions to me in a way that seems more real simply because it's changing my physical reality in a way that a video call just doesn't.