State trigger in automation not working

Hi,

i have a climate device that changes an attribute named “temperature” from “0” to “30” if i turn it to maximum heating.

In an automation i want to use the “state” trigger to trigger an action. But the trigger doesn´t work.

This is the automation:

- id: '1630856677211'
  alias: Heizungen Handtücher trocknen Start
  description: ''
  trigger:
  - platform: state
    entity_id: climate.az_jens
    to: '30'
    from: '0'
    attribute: temperature
  condition: []
  action:
  - type: toggle
    device_id: 9ac82b202e2e5a739d0631a5dd7420b0
    entity_id: switch.az_jens_lampe_on_off
    domain: switch
  mode: single

This is just a test and not the final automation. But it´s not triggering. I´ve checked in the dev tools the device state and i see that exactly this attribute changes. Same in the event listener for “state_changed”.

Does anybody has an idea what the problem is?

Thanks
Jens

Welcome!

You could try another action method:


action:
  - service: switch.turn_on
    target:
      entity_id: switch.az_jens_lampe_on_off

Thank you for the reply!

How should your idea help with the trigger not working? :slight_smile: The action is working fine. :+1:

Maybe because today it’s not my best day :crazy_face:

What if you skip the attribute and the from and only use

to: '30'

?

That will only trigger if that attribute goes from exactly the string 30 to exactly the string 0. It won’t if the attribute has the value 30.0 for example.

No problem. :smiley: I´m happy for any ideas. :slight_smile:

Your suggestion is also not working.

Thank you for your reply! I´ve added screenshots from the dev tools below. That´s exactly what i see there.

0 30

When you test the attribute in Dev Tools → Template, what is the output?

Can you try this?

trigger:
  - platform: state
    entity_id: climate.az_jens
    to: heat

Make sure when you try, the state at the beginning must be off. Then, you change the mode to heat.

If i use

{{ state_attr('climate.az_jens', 'temperature') }}

i´m getting result type “number” and “0”.

That worked! What do you want to know with this test? :slight_smile:

This is also working now! The “temperature” attribute was still in the automations.yaml file after i edited it in the frontend (i deleted it there and it wasn´t visible anymore).

After i tried adding the “temperature” attribute it´s not working anymore. Even if i restored it to something that worked… Now i´m really confused. Even tried deleting the automation and adding a new one withe the settings that worked. Am i missing something? What is wrong?

Sorry for the spam. One thing i learned is: I have to reload the automations.yaml after editing it manually. I tried again and only “heat” is working. “30” isn´t.

Quite the opposite, it is a very interesting issue. This one works also:


trigger:
  - platform: numeric_state
    entity_id: climate.yourclimate
    attribute: temperature
    above: '29.9'

1 Like

I can confirm that this also works. But i would like to use the “state” and not “numeric_state” because i want to have a specific change. From “0” to “30”. This one would also trigger if i change it from “20” to “30”.

That is of course true.

Try this and see if it works the way you want:

- id: '1630856677211'
  alias: Heizungen Handtücher trocknen Start
  description: ''
  trigger:
  - platform: state
    entity_id: climate.az_jens
    attribute: temperature
  condition:
    condition: and
    conditions:
      - "{{ trigger.from_state.attributes.temperature == 0 }}"
      - "{{ trigger.to_state.attributes.temperature == 30 }}"
  action:
  - type: toggle
    device_id: 9ac82b202e2e5a739d0631a5dd7420b0
    entity_id: switch.az_jens_lampe_on_off
    domain: switch
  mode: single