Climate HVAC mode Condition not working

Hi Experts,

I really struggle al lot getting an automation configured on home assistant version
core-2021.6.6

I try to implement an on/off toggle of my air condition using two automations that evaluate the current hvac state to act accordingly (set to cool if state is ‘off’ set to ‘off’ if state is cool)

condition: device
device_id: 8f0f14a954cb628a76711b2eef8b4dac
domain: climate
entity_id: climate.klima_schlafzimmer
type: is_hvac_mode
hvac_mode: cool

But even when the state of climate.klima_schlafzimmer is set to cool (as I had a look in the dev tools) the condition is always evaluate to false as I can see in the trace.

Any ideas?

Thanks in advance!
Marco

Please post all of the automation’s code as formatted YAML (see guideline 11 in the FAQ).

Sorry, here you go:

- id: '1623938333587'
  alias: Klima Schlafzimmer aus
  description: ''
  trigger:
  - platform: device
    device_id: 620f5b5dd08ecf170b2d22712cf36cf5
    domain: shelly
    type: double
    subtype: button
  condition:
  - condition: device
    device_id: 8f0f14a954cb628a76711b2eef8b4dac
    domain: climate
    entity_id: climate.klima_schlafzimmer
    type: is_hvac_mode
    hvac_mode: cool
action:
  - service: climate.set_hvac_mode
    target:
      device_id: 8f0f14a954cb628a76711b2eef8b4dac
    data:
      hvac_mode: 'off'
  mode: single

It’s preferable if you post it as formatted YAML. It in its current form, it’s difficult for anyone to detect syntax errors like improper indentation.

Either use code blocks (type three consecutive back-quotes ``` on a separate line before the code and another three on a separate line after the code) or use the forum’s formatting command (select the YAML code and click the </> icon in the menu).

Sorry again. I dont think its a formating issue since the core is not complaining. Also this code was created by the UI.

Try this condition block instead:

  condition:
    - condition: state
      entity_id: climate.klima_schlafzimmer
      state: 'cool'

Your action indentation is wrong as pasted above.

If this fails to work then there may be something unusual about the climate.klima_schlafzimmer entity.

- id: '1623938333587'
  alias: Klima Schlafzimmer aus
  description: ''
  trigger:
  - platform: device
    device_id: 620f5b5dd08ecf170b2d22712cf36cf5
    domain: shelly
    type: double
    subtype: button
  condition: '{{ is_state("climate.klima_schlafzimmer", "cool") }}'
  action:
  - service: climate.set_hvac_mode
    target:
      entity_id: climate.klima_schlafzimmer
    data:
      hvac_mode: 'off'
  mode: single
2 Likes

Thank you very much. Works just great! Wondering what the issue with the zu generated version is…