I recently had solar panels installed and opted to use a SolarEdge hybrid inverter should batteries ever become worth installing (A savings of about $2.50 per day on electricity costs means they are very much not worth it yet). This system has the ability to hook up via Modbus over TCP to pull various stats and as a bonus I discovered that it also has a meter in those stats that show amount of power generated from solar and amount exported/imported from the grid. Using both those we can also then work out how much energy the house is using real time.
HomeAssistant has some nice built in graphs for monitoring energy usage. For example you can get these sort of stats:
I have also created some additional meters that will give me live stats about what is happening:
My system has an 8.5KW inverter with just under 11KW worth of panels. This means that I am not eligible for the pittance the power company offers as a feed in tariff so I’ve decided to try to use the excess solar as smartly as possible. As I already have the values feeding into Home Assistant I can use that data in an automation that detects when excess energy is available.
Pool Pump
One energy hog is the pool pump. It has to run for hours each day and is a good candidate for automation.
The easiest option would be to configure the pump to always be enabled and then to plug it into a smart switch that can be remotely controlled and ideally has its own button so we can also override at the pump as well as through Home Assistant.
A quick trip to Bunnings and I discovered it has Arlec Grid Connect PC190HA smart plugs. These are Tuya devices and contain an ESP8266 inside. I prefer to run my own known firmware so after opening it and soldering on a small header to the MCU I flashed it with ESP@Home and joined it to Home Assistant.
I will eventually update its ESP@Home config so the button can be pressed to toggle between On, Off and long press to enable Auto but for now it just acts as a toggle and the LED will show the plug state.
Aim
I would like to achieve the following:
- The Pump must have a maximum amount of time it can run during the day. I don’t want it to just be on all the time as it could be annoying for me as well as my neighbours.
- I don’t want it flapping between on and off at the whim of the sun. If it changes state then it should remain in that state for at least 10 minutes.
- Provide the ability to see its run time, state and the ability to configure its runtime in Home Assistant.
I would also like to try to write the automations in the NodeRed extension of HomeAssistant as a learning experience. This allows one to draw automations using a flow chart which in theory should be easier to vizualize.
Home Assistant Helpers
We create a few Helper sensors in home assistant:
- Pool Pump Mode – A drop down input with ‘off’, ‘on’, ‘winter’, ‘summer’. This will allow us to choose what mode to run the pump in with the first two forcing it on or off and the latter two being two different automatic settings
- Winter Runtime Number – A number input representing number of hours we want the pump to run when its mode is set to winter
- Summer Runtime Number – A number input representing number of hours we want the pump to run when its mode is set to summer
Automation
Startup
Initialize some variables to prevent something hanging over from a restart:
- Set flow.pump_automatic to false
- Set flow.pump_ignored to false
Pump Mode is Changed
If the pump mode dropdown is changed in Home Assistant:
- Check if forced settings (on, off) and if so we set flow.pump_automatic to false. The pump is then turned on or off.
- If it is set to a non forced setting (winter, summer) we will look up its config (max_runtime), set it into flow.pump_max_runtime and set flow.pump_automatic to true.
Excess Solar Reading Updated
Each time a solar reading occurs:
- Check if the flow.pump_automatic is true.
- Check that flow.pump_ignore is false
- Test if we have greater than 1000W of excess solar for at least 5 minutes. We also test if we have less than 10W of excess solar for at least 5 minutes. If during the 5 minutes this is not true then we abort. This means that in order to trigger either a pump on or pump off we need to have a consistent reading of excess solar.
- Check again that flow.pump_automatic is true just in case something changed during the wait
- Check if the pump is off
- Check that the pump hasn’t run past its maximum configured runtime for the day
- Turn the pump on
- Set flow.pump_ignore to true and 10 minutes later set it back to false. This is to ensure we don’t turn it back off if excess solar disappears suddenly.
If < 10W of excess solar occurs:
- Check again that flow.pump_automatic is true just in case something changed during the wait
- Check that the pump is on
- Turn the pump off
- Set flow.pump_ignore to true. 10 minutes later set it back to false
Pump Runtime Today Changes
This will just make sure that the pump will not run longer than its configured runtime.
Pump Runtime is calculated from the total time the switch controlling the pump is on and is provided by Home Assistant through a History Stats sensor.
Each time this sensor updates:
- Check if flow.pump_automatic is true
- Check if the pump is on
- Check if the pump runtime is greater than its configured maximum
- Turn it off
Home Assistant Dashboard
A very simple dashboard to show:
- If Pump is on or off
- How long its run today
- What mode it is
- Configuration for each mode
Thanks for the great write up, I would like to use your Node Red flow for my pool pump set up. Could you please share your EXPORTED Node Red flow?
I am working through your flow, but using Get Entities for Summer/Winter has me stumped at the moment.
I would like to add the capability to run the pump on OFF-PEAK power if there has not been enough power to reach the max-runtime during the day due to lack of sun or heavy household load.
Thanks