by

Project Idea: Smarten up the smart thermostat.

I’ve been messing with Homekit recently.

More specifically I’ve been looking at using Homebridge, a JS package that provides a way to connect your own devices to other Homekit stuff.

Last year I wrote a thing that used a Particle Photon to get the temperature in my living room, and then some Ruby code that ran on a Raspberry Pi to turn on and off my window unit. Essentially a thermostat since the one built in to the unit doesn’t really work.

There are a couple of examples of hooking a Photon into Homebridge, so that whatever data they’re collection shows up inside your Home app.

I like this idea a lot, since it opens the door to using a combo of store-bought sensors and custom made ones. Also, I had to reverse engineer the API (which would make a great blog post) that the Wifi Smart plug my A/C unit is plugged into uses. If I could get things working inside of Homekit then I wouldn’t have to depend on their private & proprietary API not changing.

I would also like to have my Ruby code check more info that just the inside/outside temperature. I’d like it to also look at the UV index, as that can have quite an impact on the temperature indoors. If I got the temperature shoved into Homebridge, and the Smart Plug in there as well, it’d be a lot more manageable code-wise to add another dimension to my K-Nearest Neighbors that I’m using to decide if I want A/C or not.

I was reading a machine learning book when I wrote the code and wanted an excuse to implement something. So the “Should the A/C be on” question is answered by using K-Nearest Neighbors based on past times I’ve specified that the A/C should be on.

So I want to add the UV index to that, and probably a look-ahead to the next hour on the forecast. Currently when the day is warming up the A/C will kick on and off until the middle part of the day at which point the A/C kicks on and the room is too hot for it to cool down. I’d like it to go ahead and notice that it’s going to be too warm later on.

So that’s:

  • move sensor readings to Homekit via Homebridge
  • add UV index to my sensor readings
  • add UV index to my decision matrix
  • add forecast look-ahead to the decision tree

I’ll need to look in to weather the look-ahead would work well as just adding it as a dimension or if I should just perform the calculation again with the forecast temperature. I kind of like the latter.