Home Grown Home Automation — Getting Started
It turned out much easier than I had originally imagined. Just needed to assemble the pieces of the puzzle. And while I waited a few months with COVID lockdowns & home schooling & change of consulting engagements to get some focussed time on Raspberry Pi 4 to put them together, I more or less had figured out things I needed to do.
When you have a solar install, it makes economical (and environmental) sense to run your non-essential high-power devices mainly when you are generating lots of power. And although Oz is blessed by good sunshine most of the time, it hasn’t been very predictable for last year or so, with the rains.
The Plot :
Run the pool pump when the solar install is generating more than 6kW. 1kW would easily get used at home most of the time with refrigerators and gadgets and bare essentials, and 5kW on top is the typical export limit set by the provider.
Actors and their Acts :
- Something to manage and monitor the home automation, discover the smart devices and sensors, and orchestrate certain triggers and conditions into actions.
- Solar inverter real time data to know the exact current power generation.
- Something to turn the power the pool pump on/off.
The Stage :
- Home Assistant has been making a lot of news. Or at least has come up a lot in what I have been reading. Its docker container version was very easy to setup on the Raspberry Pi 4. https://www.home-assistant.io/installation/raspberrypi#install-home-assistant-container. And the initial discovery of most of the existing devices and sensors from its dashboard easily made it look a very promising.
- Next up, solar inverter real time data. I was ready to roll-up my sleeves and reverse-engineer the APIs to get this data from our GoodWe Inverter. The reason to choose GoodWe was because it was the one of the few which could take input from three sets of panels. But then, it may not be the most advanced or popular out there or have very well documented APIs. But I was pleasantly surprised when I began my search for its SEMS portal SDK. I found couple of projects which had managed to extract this data out of the GoodWe Inverters already. And at least one of them (https://github.com/TimSoethout/goodwe-sems-home-assistant) made it available into Home Assistant. HHOOOORRAAYY !!!! All it needed was Home Assistant Community Store installed on top, to be able to point to GoodWe SEMS API as a new source. https://hacs.xyz/docs/installation/installation#home-assistant-container.
- Finally the controller. Something to turn the pool pump on and off. I already had couple of Bunnings ARLEC smart sockets (https://www.bunnings.com.au/arlec-grid-connect-smart-plug-in-socket_p0135440) for oil heaters from winter. Its anyways time to repurpose them given winters are on their way out. And I realised only recently that there is a socket/plug en route to how the pool pump is fed. Easy peasy. But hang on, Bunnings Grid Connect devices isn’t something you did expect Home Assistant to support as an integration. And so it seemed. Some googling again and turns out that Bunnings smart home ecosystem are a rebranding of Tuya devices and app. Now Tuya is popular for home automation and hence supported as an integration OOTB by Home Assistant. So all I needed to do is remove those smart sockets from the Grid Connect app and import them into the TuyaSmart app. Phew!
The Performance :
On a partly cloudy day, it has done what you would expect it to.
Here is the solar generation between 10 am and 2 pm.
And here are the on-off patterns for the pool pump for the same period. The up-triggers were configured to stay stable for 5 minutes before they are turned into actions.
The Sequel :
- Make Home Assistant setup more robust for multiple seasons. Make it more inviting for family (& friends) to have a play. Keep others at bay.
- Add more sensors and triggers and conditions and actions. Make the Raspberry Pi 4 do some substantial work.
- Use actual available home grown power in the whole math. That would mean more of energy consumption sensors, at least for most of high power devices at home. And custom scripts instead of standard forms based on one device to work out the trigger.