Above you can see a screenshots from my mobile, along with a photos of the dashboard on my tablet and smart watch. if you look at the tablet, the values in the left column at the top are the inside and target temperatures. It then shows whether boost is on or if it’s in auto mode. Below this are 4 squares with an initial so that it’s possible to see who’s in – green, and who’s out – red. This is what’s used to set the temperature. The theory is that if they’re all red then the heating should be off. The middle column has the buttons to control things and the right column shows a live feed from the Pi Zero based camera I have over the front door.
I’ve had a bee in my bonnet for a while now about Hive Home and their reluctance to offer proper geofencing so that your heating automatically gets turned down or off when the house is empty. They offer a sort of dodgy workaround where you get a push notification inviting you to adjust your heating, or you can install a bunch of 3rd party apps to do it but it still looks like it’s done to put you off. Think about it. A company that makes money from the energy you use providing you with a system that will save you money on your energy bills? Nest and Tado have been offering this for years. Hive users have been asking for it for years. Hive won’t do it.
Just for reference, this is the Hive “solution”:
- Leave home – possibly getting into your car to drive to work
- Get a push notification telling you it looks like you’ve left home and inviting you to adjust your heating – by this time you’re negotiating the rush hour traffic
- Open your Hive app
- Adjust your heating temperature
Of course, if there’s 2 kids in the house then they have to have the Hive app on their phone, see the notification when they leave for school/college and remember that they need to turn the heating down to 15 or something. IFTTT doesn’t know who’s in and who’s out so you can’t do it with that.
So, this became a bit of an obsession for me and it’s beginning to pay off!
What I have is a Raspberry Pi that runs a small Python script to look for the Bluetooth MAC addresses of the mobile phones in the house. It does this once a minute and writes a score to a MySQL database on my PythonAnywhere hosting account. This means you can weight the way that it detects and change the temperature accordingly. For example, we’ve got 2 boys in the house who prefer it colder and end up opening the windows in their bedrooms. So if they’re the only ones in I’ll set the temperature to 15 or something. If I’m in or my other half’s in, I’ll set it to 21.
On my Python Anywhere account I have more Python scripts. One of them runs once a minute and uses the Hive API to read all the values from my house into a MySQL table. I’ve also got a web app that I’ve written to control everything and that also writes to the MySQL table. Another part then writes back to Hive. There’s some other bits in the middle to make sure there’s no conflict. For example, if I adjust the temperature using my dashboard, it sets a flag. Then when the sync happens, it uses the temperature that I’ve set to override what Hive thinks it should be.
All the front end for the dashboard does is read and write from the MySQL table. It doesn’t talk to Hive directly. The diagram below hopefully shows it better than my description here – you can click on it to open it in a new window.
When I started this, I knew nothing about Python so the learning curve has been steep. What I have now is a nice dashboard that I have running on a couple of Kindle Fire tablets so that people in the house can adjust the heating as they wish, or it can be put into automatic mode where it’ll adjust the temperature depending on who’s in the house or turn it right down if the house is empty. It also runs through a standard browser and on my smart watch.
What I’ve done at the moment does what I want it to do but there are a few things I want to do to make it better.
- Write a nice little script for a Pi Zero so that others can build the Pi that does the Bluetooth sniffing for themselves – it relies on a couple of things that make it quite techie at the moment
- Add a registration and log in to the website so that others can use the functionality if they have Hive systems – you get a Pi Zero for about 20 quid including a case, memory card and power supply. Download my image, set it up and register on my website. You then have proper geofencing for your heating system
- Convert all the values on the dashboard to use Ajax so that they’re more real-time than they are at the moment
- Add in extra functionality to control lights, change schedules, etc, if you have other Hive devices such as bulbs and sockets
- Add in functionality to integrate with other platforms such as Phillips Hue and Samsung
I’m going to let this run over the winter and see how it affects my gas use.