I have to implement few automations that are very time sensitive and which have condition:s that need to be met.
The issue I have today is that after the Automation is triggered, the sensor state that need to be validated in the conditions sometimes is not up to date and the script is not executed (when it should… if the state would be refreshed).
I could obviously set the scan_interval to 1 sec and that would most likely work, but it is very inefficient, i.e. is consuming a lot of resources, especially when considering that the automation is probably triggered only once a day.
My feature request is to introduce an automatic refresh for all the entities used in the condition:s after the automation is triggered and before validating the conditions themselves. This would guarantee that everything is being validated according to their current state.
Have you tried to move your condition into the action section; and prior to that call homeassistant.update_entity to force the sensors to update?
This way the automation will always fire on the trigger; but delay the condition evaluation to where you have it in the action block… after the manual called update. You maybe able to add another condition in the condition block to further decrease how often this is evaluated.
Thanks @jwelter. l’ll explore that. it sounds like a good idea.
on action 1 I would update the sensor and then on action 2 I would implement a template with IF statement to check the state of the sensor I’ve just updated… right?
It should work but even if it is lower priority I think it makes sense to include this auto_refresh option for the entities in the conditions :). In an automation, who wants to check conditions of an entity that is not up to date?
just tested the binary sensor with platfrom ping (which even gives a bit more info) and it works perfectly so it is either a bug of device tracker (not alowing force update) or a feature for some reason
I know this is an old topic, but could you please post an example how to do this? I have the same problem where my template isn’t updated. Now I added an extra automation before the other automations starts, but I’d rather have it in one automation.