I have an automation that triggers successfully when the sensor reads above the set value. However, due to reasons that I am yet to understand, it is not uncommon for the sensor to trigger as a result of change to/from an “unknown” or “unavailable” state.
Check the Traces for your automation, if the “from” state for your false triggers is actually “unknown” or “unavailable”, then use conditional logic to avoid executing the actions when that happens:
condition:
- condition: template
value_template: "{{ trigger.from_state.state not in ['unknown', 'unavailable'] }}"
Apologies for the time to acknowledge. But catching random events is not easy.
Now, I think, I’m still getting triggers (which I would rather not) but at least the Action is not executing.
Can you point me to the description of these “trigger.xxxx” commands. But if such does not exist yet, can you confirm that the strings within the parentheses () are a list? And the string can be any valid value from that sensor? i.e. “1234.56”.
Regards, M.
The problem with this document, is that it does not list the parameters?
So, if I was attempting to use trigger.from_state.state (which is how it is shown)
for the first time, how would I know that there are an unlimited number (are there?) of parameter (‘str1’, ‘str2’, … ‘str_n’) permitted. Is there some other understanding that I need to gain that will open this set of command for me?
Regards, M.
It’s not a “command”, it’s the State Object of the thing that caused the trigger, in its “before” condition.
So trigger.from_state.state is the (string) state of the sensor before it changes and caused the trigger to fire; and trigger.to_state.state is the state of the sensor after it caused the trigger to fire.
In your case, trigger.to_state and states.sensor.smart_meter_electricity_import_unit_rate are the same thing when you look at them; the from_state is a temporary record of what is was beforehand.