Controlling an electric water heater with Home Assistant

The electric water heater in our summer house is a standard 110-liter Metro Therm type 644 with a 3 kW heating element. The summer house is insulated for year-round use and has a solar panel system. We use it often, including in winter. The starting point for an automation was purely financial: I wanted to save money by letting the tank heat up using surplus solar power in summer – and cheap night-time electricity in winter, when the sun barely contributes.

Sonoff Zigbee temperature sensor, incl. probe mounted in a thermowell on the water heater

Along the way, I discovered it wasn’t quite as simple as that. There was also the risk of Legionella bacteria to consider – they thrive best in water between roughly 25 and 45 degrees. If control were based solely on solar surplus, the tank could easily end up switched off for long stretches during cloudy or winter weather, and thereby risk sitting right in that temperature band. The point of an automation is to save money, but it has to happen safely, so the savings never come at the cost of the water actually getting hot enough, often enough. For that very reason, the automation runs year-round, without interruption – we never fully cut the power, not even during periods when the house stands empty.

To get actual numbers on the temperature drop when power to the tank was off, I calculated how much heat a fully heated tank (56°C) actually loses over 24 hours without power, at a realistic winter temperature of 9°C in the room where the tank stands (the heat pump in another room is set to 10°C when we’re not at the summer house, and all doors are open). With a calculated heat loss of 1.8 kWh per day, the temperature after 24 hours without heating ends up around 43°C – right in the upper part of that same temperature band Legionella thrives in. That confirmed that a fixed daily heating cycle is absolutely necessary if the house stands unoccupied during a cold period.

The third consideration is something entirely practical: there needs to be hot water in the house when we’re there – including after a shower. If we draw a large amount of hot water, the tank needs to reheat afterward, so hot water is ready for next time, without anyone finding out too late in the shower.

Calculated over a full year of operation – standby losses plus the energy for the water we actually use during stays – the total annual energy consumption for the water heater comes to around 1000 kWh. That figure is the same regardless of whether it’s controlled or not – it’s the same amount of water and the same heat loss that needs to be covered. What the control changes is when those 1000 kWh are purchased, or whether they’re covered by solar surplus. Compared with not controlling by time or sun at all, the automation is estimated to save in the range of 500 DKK a year.

The result was three rules, each solving its own problem.

The three rules

Use the solar surplus. Every 10 minutes, the system checks whether the solar panels are producing more than the house is currently using. If the surplus is above 3 kW, and the temperature is below 54°C at the same time, power is switched on and heats the water up to 56°C. The saving lies in the fact that surplus power would otherwise just be exported to the grid at a low settlement price – using it instead to heat the water saves the full retail price I would otherwise have had to pay to heat the water at a later point. The 2°C hysteresis is there to prevent the relay from switching on and off too often.

Charge if necessary during the night hours. Every night, the cheapest hour within the 00:00-06:00 window is found, based on the actual electricity prices for the coming 24 hours. If the tank is below 56°C at that point, power is switched on, and switched off again at 56°C or by 06:00 at the latest. This is partly a hygiene measure against Legionella (a guaranteed daily opportunity for heating), and partly a savings element – within the night window, the rule hits the actual cheapest hour, rather than a fixed clock time.

Hot water after use. I have a temperature sensor directly in the tank, mounted in a thermowell on the underside of the tank, giving the actual tank temperature. If the tank temperature drops below 46°C, power is switched on. When the temperature reaches 56°C again, it’s switched off. This is a simple thermostat control: the tank is heated exactly as long as it takes to reach the target.

All three rules can always be manually overridden with a simple switch in the app (On/Off/Automatic). If “On” is used, though, it’s the physical thermostat alone that sets the limit – and as mentioned, that’s turned up so that “On” heats well above the 56°C the rules otherwise use. The switch can therefore be used to “flush” the tank, but shouldn’t be left on for extended periods due to the risk of scalding and faster limescale buildup. If “On” is to be used for normal levels, the physical thermostat needs to be turned down first. Conversely, “Off” shouldn’t be left active for extended periods either – without power, the temperature will eventually fall into the Legionella band.

One important detail behind all of this: The tank’s own built-in thermostat is deliberately turned up well above the 56°C the software works with. Without that, the tank’s physical thermostat could cut the power itself in the middle of a cycle – and thereby effectively decide when and how much gets heated, independent of my three rules. By raising the physical limit, it now functions purely as a passive safety net, which would only step in if something in the software control itself were to fail. All day-to-day temperature control therefore effectively happens in Home Assistant, not in the tank itself.

Shelly Pro 1

The equipment behind the solution

  • Metro Therm model 110 type 644 electric water heater
  • Shelly Pro 1 – controls a multi-pole certified contactor (Siemens Insta Modul contactor) that carries the actual power to the heating element; the Shelly only sends a low-voltage signal to the contactor coil. It’s standard installation practice for a certified contactor to carry the load.
  • Temperature sensor in a thermowell directly in the tank (Sonoff Zigbee temperature sensor, incl. probe) – provides the actual tank temperature to the comfort rule
  • The Strømligning integration (HACS) in Home Assistant – provides hour-by-hour electricity prices for the current and coming day, used to find the cheapest night hour with Danish electricity suppliers.
  • The installation and panel work require correct wiring and compliance with applicable electrical regulations. This installation is not suitable as a DIY project unless carried out by, or under the responsibility of, a licensed electrician.

Status now

The water heater now runs with the three rules as described: the price-driven night cycle, the temperature-driven reheating, and the solar utilization every 10 minutes – running side by side without interfering with one another.