I have 30 simple lights buttons at my house connected to Home Assistant. They are represented as sensors which have RELEASED/PRESSED
states.
I have my automations currently implemented with AppDaemon where I was able to do some simple mapping to avoid duplications of automations.
I plan to switch to Home Assistant native YAML automations and I am looking for the best way to do that.
I would like it to be concise and avoid creating separate automation for each pair of sensor-light.
I’ve found that one option to do that is to use “chooser” in automation so I came up with something like this (example for 2 lights):
- alias: Toggle lights
description: 'Toggle lights on button press'
trigger:
- platform: state
entity_id:
- sensor.button_workshop
- sensor.button_bathroom
action:
- choose:
- conditions:
- condition: state
entity_id: sensor.button_workshop
state: PRESSED
sequence:
- service: light.toggle
entity_id: light.workshop
- conditions:
- condition: state
entity_id: sensor.button_bathroom
state: PRESSED
sequence:
- service: light.toggle
entity_id: light.bathroom
default: []
I am wondering if there is any better/alternative way of specifying such a simple automation for multiple entities.