Help - Automation, action based on sensor_id or entity_id

Trying to setup a automation that could apply on my 3 climate entities.
I want the ‘climate’ action triggered by the corresponding sensor.

Here where I am today after multiple tries, but not working so far even I think I’m close.

I took care to name my entities with same name when they are supposed to work together.

My climate are named ‘climate.thermostat.name1’ name2 etc…

alias: Climate turn off when window open
description: ""
  - platform: state
      - binary_sensor.window_name1_opening
      - binary_sensor.window_name2_opening
      - binary_sensor.window_name3_opening
    from: "off"
    to: "on"
      hours: 0
      minutes: 0
      seconds: 0
condition: []
  - service: climate.turn_off
    metadata: {}
    data: {}
      entity_id: |
        climate.thermostat_{{ trigger.to_state.object_id.split('_')[3] }}
mode: single

Indexing counts from 0. name1 is the third item, which is [2].

  - service: climate.turn_off
      entity_id: climate.thermostat_{{ trigger.entity_id.split('_')[2] }}

1 Like

Brilliant ! Works like a charm
Thanks for the developer tool, I will do good use of it.

1 Like