Like most advanced Home Assistant users, I have a lot of automations running. Most are simple things, like good morning routines, automatic door locks, and smart button triggers for various devices. Some, however, are much more advanced. Presence sensors with various triggers that keep room lights on under very specific conditions. Or advanced air quality data processing and alert logic, adapted for all four seasons of the year.

But my favorite and most useful Home Assistant automation is not the flashiest one I run. It is a simple energy-saving automation for a solar water heater and its circulating pump. I think it is the automation that has had the biggest impact on my convenience, comfort, and overall home energy savings.
This is why I decided to share it.
The solar thermal system
I have a solar thermal system on my roof that heats water for my entire house. This is not a photovoltaic system that generates electricity. This is just a set of panels with copper pipes for heating water. The system uses a closed loop filled with a heat transfer antifreeze fluid, that never mixes with the water people actually use.

A simple water pump circulates that fluid between the roof panels and two water boilers installed in my basement. The fluid picks up heat on the roof, carries it down to the boilers, transfers that heat into the stored water, and goes back up to do it again. Very simple, very effective. When the sun is shining, at least.
This kind of setup is usually called a solar thermal water heating system, and the pump is referred to as a circulation pump or water pump rather than a compressor heat pump. The important part for this article is simpler than the actual terminology. The pump only needs to run when there is enough sun to make circulating the fluid worthwhile.
The problem with running it on a schedule
Ever since this system was installed, the pump ran on a basic mechanical timer which was never accurate. Sunrise and sunset shifted throughout the year, and a fixed timer schedule did not shift with them. It always needed adjusting and fiddling, which meant a trip to the basement. And I still got random on and off cycles that did not match the actual sunlight outside.
As the timer had no remote control at all, the bigger problem showed up on rainy or cloudy days. If it started raining, my only option was to walk down to the basement and switch the pump off by hand. If I was not home when the weather turned, the timer just kept running on schedule regardless.
A few hours of heavy rain with the pump still cycling was enough to cool the entire hot water of both boilers, and I would come home to cold water with no idea it had happened until I noticed. This was such a huge energy waste and the solution was simple.
A smart plug to the rescue
Initially, I installed a simple Tuya Zigbee smart plug to the water pump and built an automation around it in Home Assistant. Later on, I upgraded the plug to the Sonoff S60ZBTPF for energy metering, but the logic remained simple and worked wonderfully.
- Trigger the pump on an hour after sunrise, using the sun entity so the time shifts automatically with the season, and waiting out the weakest part of the morning light.
- Trigger the pump off an hour before sunset, using the sun entity so the time shifts automatically with the season, turning off an hour early since there’s barely any sunlight in the last hour.
- Add a condition using the weather entity so the pump does not turn on, or shuts back off, whenever the current condition is cloudy, foggy, rainy, snowy, hailing, or a rainy thunderstorm.
- Watch the weather entity continuously, not just at sunrise, so a shift in conditions during the day turns the pump off or back on right away instead of waiting for the next sunrise or sunset trigger.

The weather condition matters the most in this automation. On a cloudy, rainy, or snowy day, the panels on the roof are not gaining much heat, if any. Running the pump at all times does not just waste electricity, it actively pulls heat out of the boilers and cools everything down.
Watching the weather entity continuously, rather than only checking it once at sunrise, means a rain shower that clears up by noon does not leave the pump sitting off for the rest of the day either. It reacts to the actual weather in real time, not just to whatever the sky looked like at sunrise.
The automation in YAML
Here is the automation itself, written with trigger IDs and actions as top level lists. You can adjust it by changing the entities if you have a similar system yourself.
alias: Solar Pump Water Heater - Sunrise/Sunset
description: Turns the solar loop pump on an hour after sunrise and off an hour before sunset, skipping rain and cloudy days
triggers:
- trigger: sun
event: sunrise
offset: "01:00:00"
id: sunrise
- trigger: sun
event: sunset
offset: "-01:00:00"
id: sunset
- trigger: state
entity_id: weather.home
id: weather_changed
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id: sunrise
- condition: not
conditions:
- condition: state
entity_id: weather.home
state:
- cloudy
- fog
- hail
- lightning-rainy
- pouring
- rainy
- snowy
- snowy-rainy
sequence:
- action: switch.turn_on
target:
entity_id: switch.solar_pump_plug
- conditions:
- condition: trigger
id: sunset
sequence:
- action: switch.turn_off
target:
entity_id: switch.solar_pump_plug
- conditions:
- condition: trigger
id: weather_changed
- condition: state
entity_id: weather.home
state:
- cloudy
- fog
- hail
- lightning-rainy
- pouring
- rainy
- snowy
- snowy-rainy
- condition: sun
after: sunrise
after_offset: "01:00:00"
before: sunset
before_offset: "-01:00:00"
sequence:
- action: switch.turn_off
target:
entity_id: switch.solar_pump_plug
- conditions:
- condition: trigger
id: weather_changed
- condition: not
conditions:
- condition: state
entity_id: weather.home
state:
- cloudy
- fog
- hail
- lightning-rainy
- pouring
- rainy
- snowy
- snowy-rainy
- condition: sun
after: sunrise
after_offset: "01:00:00"
before: sunset
before_offset: "-01:00:00"
sequence:
- action: switch.turn_on
target:
entity_id: switch.solar_pump_plug
mode: singleThe first rule handles the delayed sunrise case and checks that the weather is not currently bad before turning the pump on. The second rule handles the delayed sunset and always turns the pump off.
Right at sunrise or sunset, the sun sits at zero degrees elevation and pushes through the thickest slice of atmosphere it will hit all day. There is barely any thermal energy reaching the roof at that moment, so triggering the pump exactly at sunrise just circulates cold fluid for no reason. Rather than calculating actual sun elevation, I gave both triggers a one hour offset. The pump waits until an hour after sunrise to start, and shuts off an hour before sunset, missing the weakest part of the day on both ends. I found it works quite reliably.
The third and fourth rules both run off the same weather trigger and solve the fixed timer problem between them. It watches the weather entity directly, and if it reports cloudy, fog, hail, pouring, rainy, snowy, snowy-rainy, lightning-rainy while the sun is already up, it shuts the pump off immediately instead of waiting for me to notice or walk to the basement. The fourth rule handles the opposite case. As soon as the weather entity reports anything outside that list while the sun is still up, the pump turns back on right away, so a rain shower at 8am that clears up by noon does not leave the pump sitting off for the rest of the day.
Why this is the automation that stuck
I no longer touch this solar water heating system. It follows the sun instead of a fixed clock, and it skips itself entirely on days when running would do more harm than good. The random on and off cycles are gone, the boilers hold heat more consistently, and I have not had to manually adjust anything since I set it up with proper trigger IDs.
Compared to the more advanced automations I run for presence and air quality, this one is almost embarrassingly simple. Three triggers, two tied to the sun and one to the weather, plus a simple Zigbee smart plug. That simplicity is exactly why it is the automation I would rebuild first if I lost everything else. And to be honest, I hate to going to the basement. For anything.










Or how about installing a temperature sensor (or a few for redundancy) for actual on-premise data?
If boiler intake temperature is lower than the water in the boiler, the pump stops. Just one rule with a measurement of difference. It also doesn’t need internet.
It won’t get more robust and simpler than that.
I thought about this too, but the thing is, my country has something like 260-280 sunny days in a year.
So I need the pump running most of the time, no need to add hardware and measure temperature.
The weather thing is more like a safety net, for the wet and rainy days.