#Template Condition not working when State TO is different to FROM

1 messages · Page 1 of 1 (latest)

dusky talon
#

Hi,

The state of the below sensor change from:

"Partly cloudy. High chance of showers. "
to
"Showers easying. Winds northerly"

but my automation didn't trigger because it stopped at the condition:

  - trigger: state
    entity_id:
      - sensor.weather_extended_text_0
conditions:
  - condition: template
    value_template: "{{ trigger.to_state.state != trigger.from_state.state }}"```

I want to make it so the automation only runs when the state of my sensor changes to something different to its previous state.

Anyone know what I am doing wrong?

TIA 🙂
#

Template Condition not working when State TO is different to FROM

vagrant shoal
#

Why do you need the condition? it should only trigger when the state of the entity changes... if there are attributes you can set "to: null" and then it will ignore attributes

dusky talon
#

the integration updates the state every 10 minutes even though the state is exactly the same

vagrant shoal
#

That shouldn't count as a state change though

dusky talon
#

you would think so but it triggers my automation every 10 minutes

#

or whenever the fake state change happes

vagrant shoal
#

fair enough

#

does the sensor have state attributes?

#

maybe a "last updated" timestamp or something

dusky talon
#

I didnt notice until I put a step interval counter and saw that it was trigger my AI 100+ times a day

vagrant shoal
#

yeah, so that's what's triggering the state trigger

#

if you set to: null it will ignore attributes and only go off the text of your state

dusky talon
#

sorry I don't really understand

vagrant shoal
#

the sub bullet point on the 2nd one

dusky talon
#

do I put it as to: null?

#
entity_id:
  - sensor.weather_extended_text_0
to: "null"
vagrant shoal
#

i think that works - normally i'd do

trigger: state
entity_id:
  - sensor.weather_extended_text_0
to: 
  - null

though

dusky talon
#

thats what the UI did

vagrant shoal
#

then do that 🙂

dusky talon
#

to me it looks like when that sensor turns to 0 or nothing haha

#

I didnt know null meant anything BUT when attributes change

vagrant shoal
#

yeah it's a weird edge case.. personally i'd prefer it if there was an "include_attributes" key you could set to false

dusky talon
#

agree!

dusky talon
#

The state changed but the automation didn’t trigger with null as the state