automation: turn it off if it’s already hot
The Sonoff POWR2 can be used as the timer on a hot water immersion heater. This model also measures electricity as volts, amps and current. I’ve flashed its wifi chip with different firmware so that I can set a heating schedule and access the energy readings. That’s described on this page but today I have another purpose.
For years, my immersion heater timer turned on during the night and turned off in the morning. That provided enough hot water till the next day but sometimes it needed a boost. So what do you think happens when the heater is turned on and left running through the night? Answer: the water in a tank heats up and after about two hours, a thermostat stops it heating. The tank cools and after 2-3 hours the thermostat calls and gets 5 – 10 minutes of heating. This continues (stupidly) through the night. Advice? Adjust the timer to start heating water an hour before you need it. But there’s better.
Turn the water heater off when the water is hot
Home Assistant will run my automation script that waits for the water heater current to drop. In summary, turn on the immersion heater at say, 5am; turn it off at 7am but if the water is hot before then turn it off anyway. Here’s the code:
alias: water heater turn off # WAIT UNTIL WATER HEATER CURRENT DROPS BELOW 8 amps FOR 5 MINUTES trigger: - entity_id: sensor.water_heater_current below: '8' for: 00:05:00 platform: numeric_state # DON'T DO ANYTHING IF THE HEATER ISN'T ON ANYWAY condition: - condition: state entity_id: switch.sonoff_water_heater_relay state: 'on' # TURN OFF THE WATER HEATER action: - data: entity_id: switch.sonoff_water_heater_relay service: switch.turn_off # WHILE TESTING USE A SMART BULB TO SHOW SUCCESS DELETE LATER - data: brightness: 5 color_name: green entity_id: light.corner_lamp service: light.turn_on
The hot water ‘boost’ button
When people stay over, there’s not enough hot water. Unfortunately if I turn the timer to always heat, I’ll forget to turn it off. A solution is to write a ‘boost’ script. The boost script turns on the water once – when you press the button (photo) or when you press a button in Home Assistant. Turning off is taken care of by the automation above.
water_heater_boost: alias: heat water till hot sequence: # START HEATING WATER - data: entity_id: switch.sonoff_water_heater_relay service: switch.turn_on # WAIT A FEW MINUTES - delay: 00:05:01 # IS THE CURRENT ALREADY BELOW 8 amps - below: '8' condition: numeric_state entity_id: sensor.water_heater_current # FAILSAFE - TURN OFF HEATER JUST IN CASE IT IS - data: entity_id: switch.sonoff_water_heater_relay service: switch.turn_off
Scripts in Home Assistant.
A script looks a bit like an automation but it runs only when you tell it to run. An automation is always active, as it waits for say, a time to trigger some action. The distinction between them became clearer over time.