I’m using the Github integration to keep track of any Os-Agent updates. I’ve setup an automation to create a persistent notification whenever the tag attribute of the relevant sensor changes (which means there is an update).
But whenever there is a wifi hiccup or a reboot or something out of the ordinary the tag briefly turns to “unavailable”. Which in turn creates the wrong notification that there is an update, since the tag has indeed changed briefly.
I’ve tried to setup a bunch of conditions which prevent the execution to no avail.
I’ve seen this in multiple threads for various reasons and it seems there is a request of many to just add an “ignore the previous state of the sensor if it is unavailable” or equals to whatever we want.
Examples (there are at least 10-15):
Can someone offer a relative straightforward solution for this that just works without having to write a bunch of complicated stuff? “Ignore the previous state of the sensor if state=whatever” so that it’s added as a condition and the automation prevented. Thanks!
The value should always be numeric (let’s say 1.2 changes to 1.3). Then the automation should be fired.
But it should not be fired when it changes from “unavailable” to “numeric”.
It seems that a value template condition, such as "value_template: '{{ trigger.from_state.state != "unavailable" }}'
is the recommended way but the condition passes through when I’m coming from “unavailable”, I don’t know why.
Yup. That’s the answer. So trigger.from_state.state goes for the whole entity, but trigger.from_state.attributes.your_attribute_here is for a single attribute?
Where is trigger.from_state.attributes.your_attribute_here actually documented? I can’t find it here Automation Trigger Variables - Home Assistant
I know this must be documented somewhere but final question: Is there a proper way (syntax wise) to add both “unavailable” and “unknown” in a single value template condition (in visual editor)? Or 2 conditions must necessarily be created?
I tried putting:
- "{{ trigger.from_state.attributes.your_attribute_here not in ['unknown', 'unavailable'] }}"
- "{{ trigger.to_state.attributes.your_attribute_here not in ['unknown', 'unavailable'] }}"
in a single condition and the automation is always stopped (but without an error, just stopped).
I’m trying just {{ trigger.from_state.attributes.tag != "unavailable", "unknown" }}
within visual editor but it does not work.
My syntax is wrong.
I’m trying to have just a single condition instead of 2 (for educational purposes )