I have several automations which I throttle to prevent them toggling too often.
I do this by having an input datetime *_pause_until, which does exactly what it sounds like. The automation is triggered on its usual events, but also on said datetime, and with a condition to skip the automation if we’re before pause_until.
As a result, the start of each automation looks like this:
(Related WTH: why is there no condition: [date]time?)
…only, sometimes (not always; not never) the automation ends up with the following bizarre & inconsistent trace:
Triggered by said time trigger.
Condition fails (???)
…and then of course the automation misses updates and I’m sad.
This is inconsistent. Triggering due to the time trigger indicates that we’re at (or after) input_datetime.dehumidifier_pump_pause_until, but failing the condition means that we’re before input_datetime.dehumidifier_pump_pause_until.
For now I’m working around this by adding a clause to the condition to check if the input trigger was said pause ((trigger.platform == 'time') or ..., at least assuming no other time triggers), but this seems incorrect regardless.
(Two other things I checked for the sake of argument: pause_until wasn’t updated during the automation run, and the system time didn’t change.)
There are other triggers to the automation too, where the condition won’t always hold.
In this case it’s the time trigger that triggers, which “should” always result in the condition being true as you mention… and yet sometimes the condition evaluates to false.
I’m not sure how that’d be relevant here unless HA was restarted in the middle of the automation (which I’ve checked: it wasn’t - and if it was the automation wouldn’t resume in the middle anyway).
Nevertheless: the input_datetime remained the same.
This is an inconstancy between either a) the input_datetime or b) now(), read in two subsequent steps of the same automation run.
(I have reformatted this slightly. For some reason the YAML copy/paste had the if/then/else out of order. I know it doesn’t technically make a difference, but it certainly makes it more difficult to read…)
Note that this is not the only automation that adjusts input_datetime.dehumidifier_pump_pause_until.
…but the trace does not have any information about the variables.
Am I misunderstanding something?
If you mean adding a variables action - I can’t do so because this is the condition block of the automation, which is run before any actions.
I can try turning the condition block into an initial if/else return in the automation actions I suppose, though that’s a more major change to the automation.
I didn’t know you could define variables in the condition block. This appears to be undocumented. Is it something I can rely on, or should I just use it for debugging?