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!
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
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
The Threshold Sensor might come in handy for that task
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).
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