AC vents closed or open

Hi there.

I am wanting to have my HVAC duct in my main bedroom open / closed depending on if the winsow is open or closed.

I have this automation but i dont know if i have done it right and I havent made an automatib using trigger id by myself before.

thanks in advance!

alias: Central Heating Master Bedroom (off)
description: if window open, vent closes
trigger:
  - platform: state
    entity_id:
      - binary_sensor.master_bedroom_window_sensor_door_2
    to: "on"
    for:
      hours: 0
      minutes: 3
      seconds: 0
    id: "off"
  - platform: state
    entity_id:
      - binary_sensor.master_bedroom_window_sensor_door_2
    to: "off"
    id: "on"
    for:
      hours: 0
      minutes: 3
      seconds: 0
condition: []
action:
  - service: switch.turn_{{ trigger.id }}
    target:
      entity_id: switch.daikinap60215_master_room
mode: single

Yes that should work. It is best to get into the habit of quoting single line templates though. e.g.

  - service: "switch.turn_{{ trigger.id }}"

If your single line template does not start with a string it must be quoted. So best to just always quote single line templates.

Another way to do your automation would be:

alias: Central Heating Master Bedroom (off)
description: if window open, vent closes
trigger:
  - platform: state
    entity_id:
      - binary_sensor.master_bedroom_window_sensor_door_2
    not_to:
      - unknown
      - unavailable
    for:
      hours: 0
      minutes: 3
      seconds: 0
condition: []
action:
  - service: "switch.turn_{{ 'on' if trigger.to_state.state == 'off' else 'off' }}"
    target:
      entity_id: switch.daikinap60215_master_room
mode: single

Thanks Ledge! I’ll give it a whirl!