Skip to content

Instantly share code, notes, and snippets.

@Didgeridrew
Created March 30, 2024 01:21
Show Gist options
  • Save Didgeridrew/6f5eb5e86e6e251b750c49e493cc074b to your computer and use it in GitHub Desktop.
Save Didgeridrew/6f5eb5e86e6e251b750c49e493cc074b to your computer and use it in GitHub Desktop.
alias: Office Wall Switch
description: ""
trigger:
- platform: state
entity_id:
- switch.office_wall_switch_1
- light.office_ceiling_light
- switch.office_wall_switch_2
- climate.office_ac
- switch.office_wall_switch_3
- light.master_bedroom_ceiling_light
- switch.office_wall_switch_4
- climate.master_bedroom_ac
condition:
- condition: template
value_template: "{{ not is_state(second, trigger.to_state.state) }}"
action:
- service: homeassistant.turn_{{ trigger.to_state.state }}
data:
entity_id: "{{ second }}"
mode: restart
max_exceeded: silent
variables:
pairs:
pair_1:
- switch.office_wall_switch_1
- light.office_ceiling_light
pair_2:
- switch.office_wall_switch_2
- climate.office_ac
pair_3:
- switch.office_wall_switch_3
- light.master_bedroom_ceiling_light
pair_4:
- switch.office_wall_switch_4
- climate.master_bedroom_ac
second: "{{ (pairs.values() | select('search', trigger.entity_id) | first) | reject('eq', trigger.entity_id) | join()}}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment