Setting up automation on thermostat

Hello all.

I’am brand new user of HA (just a couple of days experience) On raspi 3B .

After succesfully setting up zigbee buttons / switchs / thermostat, etc, I made my firsts automations without too much problem, but I stuck on the following:

I have a zigbee thermostat controling house heating, and i would like to add a switch working in parallel with the heater (switch on when heating, switch off otherwise ).

I create the following automation:

alias: thermostat on
description: “”
trigger:
** - platform: device**
** device_id: 01ae89bab6eddb0afded7897dc1011af**
** domain: climate**
** entity_id: 0b93d3e2cbb3325f38c97da90b51f0a5**
** type: hvac_mode_changed**
** to: heat**
condition: []
action:
** - service: switch.turn_on**
** metadata: {}**
** data: {}**
** target:**
** entity_id: switch.0xa4c138f2f62078d6**
mode: single

I suspect the type “hvac_mode_changed” has to changed to “Running state”, but I was not able to do that.

Any help would be apreciated.

Best regards,

Didier

First off, please format your YAML properly in the forum, it’s very difficult to read what you have pasted. See item 11 in this post:

Second, your automation will likely be based on the hvac_mode as it’s the attribute that indicates if you are off, cooling, heating, etc. So your trigger will be something like this:

platform: state
entity_id:
  - climate.the_name_of_your_climate_entity
attribute: hvac_action
from: idle
to: heating

Hello CO_4X4, Thanks for your answer.

Unfortunatly, I already tryed this . As what i have read somewhere, hvac_mode_changed indicate if the unit is in cooling /heating/ ventilation… mode, but not reflect if it is currently ON or OFF so no triggering .

In my case, the thermostat is TS0601 _TZE204_lzriup1j .

description: ""
trigger:
  - platform: state
    entity_id:
      - climate.0xa4c138fcb49b0e00
    attribute: hvac_action
    from: idle
    to: "on"
condition: []
action:
  - service: switch.turn_on
    metadata: {}
    data: {}
    target:
      device_id: 2c4bc071d2e387fbc86b9c7f9722ddd5
mode: single

After a lot of try, i found a working way (I post it here, in case it can help someone):

alias: thermostat on
description: ""
trigger:
  - platform: state
    entity_id:
      - climate.0xa4c138fcb49b0e00
    attribute: running_state
    to: heat
    from: idle
condition: []
action:
  - service: switch.turn_on
    metadata: {}
    data: {}
    target:
      device_id: 2c4bc071d2e387fbc86b9c7f9722ddd5
mode: single