Pool on Solar
We own a pool, and we recently installed Tesla solar panels and batteries. Our goal was to automate the activation / deactivation of the pool cleaning system so that it only runs when excess solar power is available at our place, instead of drawing electricity from the grid or our home batteries. In technical terms, this is called “time shifting” of the load, which is a way to lower carbon emissions, by using electricity when it comes from low carbon sources (the sun).
This is a feature inspired by “Charge on Solar” from Tesla, where software ensures that your car charges only when there is excess solar production at your home:
We wanted to do the same for another big consumer of electricity: the pool pumps. Used for filtering, cleaning and pushing water through solar heating panels, they consume around 4kW when on. Luckily, a connected controller existed for our pool system.
The idea is rather simple: On a schedule, fetch the current energy production from the Tesla solar system, and if the difference between solar electricity production and home electricity consumption is above a certain threshold, turn on the pumps. Turn them off if there isn't enough excess power. We call this “Pool on Solar”.
In the end, this is the result:
It turns out that both our pool equipment and Tesla solar system are controllable by making API calls to remote servers, so we decided to host this home automation in the cloud (Google Cloud) for simpler maintenance instead of running it on a local server.
The architecture is very simple: a Cloud Run job runs every 15 minutes via Cloud Scheduler. It loads Tesla and iAquaLink credentials from Secret Manager. We use the teslapy
Python module to get a live status of energy production at our house, then the iaqualink
Python module to turn on/off the equipment. All parameters are configurable (proto) and stored in a proto txt file, mounted in the container via a Cloud Storage volume mount, and parsed when the job is executed.
Because our outdoor lighting is also controlled using the same equipment, we added some extra code to turn on the lights when the sun sets and when there's sufficient battery capacity left, using the suntime Python module and the latitude and longitude of our city.
Find the code of Pool on Solar on GitHub and feel free to use it if you have a similar home setup.