Oh my, I must be dreaming right now. I could have sworn I’ve woken up today already…
Thank you for taking your time to write that.
To add to the topic, here’s a real-life, serious, non-made-up, not-just-playing-around example:
Intention: Keep the temperature inside the formicarium between 28°C and 29°C during the day and 25°C and 26°C during the night.
Unspoken implied intention: If it’s warmer than allowed but the heating is off, it’s fine.
Initial, flawed implementation:
Name: Turn on (Night)
When: Sensor Temperature changes to below 25
And if: -
Then do: Turn on Heating
Name: Turn on (Day)
When: Sensor Temperature changes to below 28
And if: Confirm sun after sunrise before sunset
Then do: Turn on Heating
Name: Turn off (Night)
When: Sensor Temperature changes to above 26
And if: Confirm sun after sunset before sunrise (Note: I haven't yet tested if this works, UI feedback would be appreciated)
Then do: Turn off Heating
Name: Turn off (Day)
When: Sensor Temperature changes to above 29
And if: -
Then do: Turn on Heating
Missed cases:
- At sunset, heating is on and temperature is above 26°C. “Turn off (Night)” won’t activate.
- At sunrise, heating is off and temperature is below 28°C, “Turn on (Day”) won’t activate
- Turning on the system while the temperature and/or heating state is outside bounds
I made this mistake on the same day I discussed exactly this type of issue here in length. Sure, it was immediately obvious why the heating didn’t turn off yesterday, but it was more or less luck that the conditions were right. If the heating had been off already (or was’t still power-limited and had been able to hit the 29° at night, or if I hadn’t left out the unnecessary "And If"s), I might not have noticed and could have trusted this. This could have worked as intended for weeks until conditions were just right.
I solved it by adding two addition “When: Sunset/Sunrise; And if: temp too high/low; Then do: Turn on/off heating” automations. (And ignored the “cold start” one.)
This again is something, where a state-based instead of event-based definition comes more natural to humans. when the temperature IS above 26 AND it IS night
, not (when the temperature RISES to above 26 AND it IS night) OR (when it BECOMES night AND the temperature IS above 26
. For the computer, converting from the former to the latter form is trivial. For a human…now that’s why we have programmers to translate business requirements into code.
Disclaimer: There are probably better triggers and conditions to use. That’s not the point; fixing the mistake is trivial. Not making it and/or recognising it while writing the automation is.
I have contemplated adding automations to control the room temperature with the (reversible) AC, central heating and electric blinds if the local heating isn’t enough or it really gets too hot, but that’d be a pain to express trigger-based. It also would be just for fun, not for need, as I expect to keep the room temp within human-acceptable bounds anyway. I sit within arm’s reach of that temp sensor all day…