When I paste that template into the Developer Tools, it returns false. For example when I last ran it master_bathroom_humidity was 80 and hvac_thermostat was 50. So 50+10 >= 80 is clearly false. However, whenever my automation executes, this template fires the turn_off that is after it immediately. Is there something I’m missing?
I didn’t know you could do a default like that, I’ll definitely add that but I don’t think it’s the issue since both sensors have values. I don’t see any errors in the trace. Would the trace json for the full automation help?
Thanks. I should have mentioned I added that line as a last ditch effort. It wasn’t there to begin with. I’ll gladly remove it though. What’s weird is, this automation USED TO work without me changing anything. About the only change is I think I was on an older version of HA, as I had upgraded to a bunch of the 2022.9.x patches and then eventually the 2022.10 version. But if it were a recent HA bug I have to assume a lot of others would be impacted
Without the line, the default (as per the docs) is continue_on_timeout: true and without a timeout, it would mean that the automation would immediately move on to the next action, even though the template was false.
What is confusing me, is that with the line - and no timeout, I would expect the automation to immediately abort because the template is false, and continue_on_timeout: false tells the automation to quit once the timeout has been reached without the template evaluating to true.
That could be what changed. (If indeed something has changed).
It may have had no default before, or some code that quietly fixed invalid values, now no longer does - or something else.
I would personally test it manually before then, by setting the values using the state editor in developer tools. Because you may have to make a Bug Report on Github.
As clearly the automation should have stopped after the template failed to evaluate to true - it should NOT have executed the next action.
And we can clearly see:
The template was evaluated at 2022-10-08T04:19:45.639874+00:00
and one whole microsecond later, when the template had not evaluated to true, it executed the next action anyway: 2022-10-08T04:19:45.640673+00:00
I wouldn’t do float(0) there. You can’t tell the difference between a real 0 value and the error.
Also, if the hvac humidity isn’t reporting for some reason then it will likely never be >= to bathroom humidity (even with +10). With no timeout your automation could be stuck there for a long time!
{% set hvac = states('sensor.hvac_thermostat_current_humidity')|float(-1) %}
{{ hvac < 0 or hvac + 10 >= states('sensor.master_bathroom_humidity')|float(-1) }}