My goal: Trigger scenes from Homekit
My idea: Create boolean inputs that can be toggled from homekit and based on those run automations.
**My solution: **
- Create boolean inputs and label them as "Homekit triggers"
- Create an automation that listens to state changes
-
- Filter if state change is on
-
- Filter if state change happened on an entity that is part of homekit triggers
-
- Flip all "Homekit triggers" off except the one that started the automation
My question:
Is this the best approach to this problem? Since I am fairly new to HA, I am not sure if I am overdoing it and there is an easier approach. The solution right now works, I trigger one of the inputs, others flip off. I can build automations on top of it. I would like it, if the others turned off a bit faster.
- Flip all "Homekit triggers" off except the one that started the automation
alias: Toggle all homekit triggers
description: ""
triggers:
- trigger: event
event_type: state_changed
event_data: {}
conditions:
- condition: template
value_template: "{{ is_state(trigger.event.data.entity_id, \"on\") }}"
alias: Check if state is on
- condition: template
value_template: |2-
{{ label_entities("Homekit trigger")
| expand
| selectattr("entity_id", "in", [trigger.event.data.entity_id])
| list
| count > 0 }}
alias: Check if it is a homekit trigger
actions:
- action: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: |
{{ label_entities("Homekit trigger")
| expand
| rejectattr('entity_id', 'in', [trigger.event.data.entity_id])
| map(attribute='entity_id')
| list }}
enabled: true
alias: Toggle off all homekit triggers except the last one that got triggered
mode: single