Help me find 'the HA way' to monitor hot water sterilisation

Python programming has ‘pythonic’ ways of doing things, i.e. those which adhere to the ethos of Python rather than just doing the job but possibly inefficiently/inelegantly, and I’m looking for the ‘Home Assistant way’ of dealing with a problem.

We have to sterilise our hot water tank once per week by getting it up above a certain temp (let’s say 60oC). I was originally looking at a sensor to record the ‘time since last sterilisation’ but actually all I’m really interested in is a boolean yes/no as to whether a sterilisation is due now or not. Every solution I can think of comes back to an automation which updates a binary sensor to ‘yes’ every time the water tank is below 60oC for more than seven days. But setting states in automations isn’t a built-in action in HA, which suggests I’m not thinking ‘the right way’ about the problem. I know I can install an add-on to run a Python script to set the state in an automation, but that feels like a fudge and I just wonder if I’m missing some other better way of doing it? Thanks!

Check out template sensors. Template - Home Assistant

Thanks. I’ve already got lots of template sensors set up, including a binary sensor for whether sterilisation is required. The question is about how I set it automatically, given that the switch between yes/no is based on another sensors’ state (temperature) over a period of time rather than at any given instant.

That has nothing to with sterilization. You would need to (little more) than double the temperature for that :point_down:

Proper autoclave treatment will inactivate all resistant bacterial spores in addition to fungi, bacteria, and viruses, but is not expected to eliminate all prions, which vary in their resistance. For prion elimination, various recommendations state 121–132 °C (250–270 °F) for 60 minutes or 134 °C (273 °F) for at least 18 minutes.

In case you have a furnace or boiler they actually often have a forced legionella program and will heat up to certain temperatures at least once a week (others every few days) to stop growth and diminish colonies :fire:

The Threshold Sensor might come in handy for that task :ok_hand:

Thanks. Microbiology PhD here, so in this heat pump/hot water context I’m using “sterilisation” as shorthand - as heat pump manufacturers do - for “legionella control” rather than in the strictest sense (e.g. Sterilization Mode; Quiet Operation - Panasonic WH-SHF09F3E5 Service Manual [Page 66] | ManualsLib)

Threshold sensor looks close to what I need, but I still can’t see any way of triggering one based on time above a certain threshold - it’s either above/below it (or within hysteresis parameters) or it’s not. UK domestic guidance doesn’t have anything specific about legionella in, but you could leave your water at 55oC for 5-6 hours instead of heating it to 60oC, and have the same effect (Legionella and Water Temperature: What You Need To Know). Hence the question about a sensor which is based on time at a certain state, similar to the option on an automation trigger.

Our heat pump does not have an automated sterilisation cycle.

For completeness: I settled on a Threshold sensor to record when the temperature hits 55, and then a binary template sensor that switches to ‘on’ if it’s been more than 7 days since the Threshold sensor was last_changed.

I expect the last_changed attribute actually to reset in various cases - like if you restart HA (to role an update for example). :thinking:

Just in case you own your hardware with the temperature probe completely you should be able to actually have the logic on that device (for e.g. esphome node) so it can work independently from HA :muscle:

Alas, the hardware is not my own - off-the-shelf package with a warranty I don’t want to lose.

The point about last_changed (and last_updated) is a valid one, but since there seems no obvious solution and no appetite to deal with it, I’ll just have to suck it up.

I’ve just put sensors on my hot water tank and have gone with a different approach.

The hot water heating itself is controlled via tado, but it doesn’t know how hot the water actually is, this is based on an analogue thermostat in the tank itself.

I’m aware that it takes more and more power to heat water per degree, and the hotter it is, the quicker that heat also dissipates, so if I can avoid heating the water unecessarily, then all the better.

This is what I have come up with:-

The sensors on the tank will turn off the tado heating via a service call when they reach a specific threshold which I can set. This is done using an automation that tracks the averages temperature of the tank across all the sensors.

Once a week, there is a condition in the automation NOT to intervene, which leaves tado to run on its default schedule. This is guaranteed to get the tank fully up to temperature, with the analogue thermostat set to 65 degrees.