Refactor Home Assistant Hue switch automations to use hue_event for improved reliability
* Replace multiple device-based automations with a single event-driven automation * Eliminate duplicate `unique_id` conflicts * Switch from device actions to service calls (`cover.open_cover`, `cover.close_cover`, `light.turn_on/off`) * Add support for: * Short press (button 1) → open garage * Long press (button 1) → close garage * Short press (button 4) → turn off all lights * Long press (button 4) → turn on all lights * Set `mode: restart` to improve responsiveness under rapid input * Simplify structure for easier maintenance and debugging Result: more stable and predictable Hue switch behavior
This commit is contained in:
@@ -1,68 +1,61 @@
|
|||||||
- id: '1691939802290'
|
- id: hue_switch_garage_and_lights
|
||||||
alias: Åbn garage ved tryk på 1
|
alias: Hue switch - garage og lys
|
||||||
description: ''
|
mode: restart
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
- device_id: 5f6b41e54f3226acd9c9ab54a3acb527
|
- platform: event
|
||||||
domain: hue
|
event_type: hue_event
|
||||||
platform: device
|
event_data:
|
||||||
type: initial_press
|
id: 5f6b41e54f3226acd9c9ab54a3acb527
|
||||||
subtype: 1
|
|
||||||
unique_id: 4b8a056e-973f-48cf-8a19-3586f6b05dcf
|
|
||||||
condition: []
|
|
||||||
action:
|
action:
|
||||||
- device_id: 3bc3eab99b46dae3e469bfa4060ce0f5
|
- choose:
|
||||||
domain: cover
|
|
||||||
entity_id: 4bd9c13b7bb0cc3245e38211ded2be92
|
# --- GARAGE ---
|
||||||
type: open
|
|
||||||
mode: single
|
# Kort tryk på knap 1 → Åbn garage
|
||||||
- id: '1691941083623'
|
- conditions:
|
||||||
alias: Sluk alt lys ved tryk på 0
|
- condition: template
|
||||||
description: ''
|
value_template: >
|
||||||
trigger:
|
{{ trigger.event.data.type == 'initial_press'
|
||||||
- device_id: 5f6b41e54f3226acd9c9ab54a3acb527
|
and trigger.event.data.subtype == 1 }}
|
||||||
domain: hue
|
sequence:
|
||||||
platform: device
|
- service: cover.open_cover
|
||||||
type: initial_press
|
target:
|
||||||
subtype: 4
|
entity_id: cover.anne
|
||||||
unique_id: f97d54a1-2283-4fb0-8709-b873a310732b
|
|
||||||
condition: []
|
# Langt tryk på knap 1 → Luk garage
|
||||||
action:
|
- conditions:
|
||||||
- service: light.turn_off
|
- condition: template
|
||||||
data: {}
|
value_template: >
|
||||||
target:
|
{{ trigger.event.data.type == 'long_press'
|
||||||
entity_id: light.alle_lys
|
and trigger.event.data.subtype == 1 }}
|
||||||
mode: single
|
sequence:
|
||||||
- id: '1691941222856'
|
- service: cover.close_cover
|
||||||
alias: Tænd alt lyset ved langt tryk på 0
|
target:
|
||||||
description: ''
|
entity_id: cover.anne
|
||||||
trigger:
|
|
||||||
- device_id: 5f6b41e54f3226acd9c9ab54a3acb527
|
|
||||||
domain: hue
|
# --- LYS ---
|
||||||
platform: device
|
|
||||||
type: long_press
|
# Kort tryk på knap 4 → Sluk alt lys
|
||||||
subtype: 4
|
- conditions:
|
||||||
unique_id: f97d54a1-2283-4fb0-8709-b873a310732b
|
- condition: template
|
||||||
condition: []
|
value_template: >
|
||||||
action:
|
{{ trigger.event.data.type == 'initial_press'
|
||||||
- service: light.turn_on
|
and trigger.event.data.subtype == 4 }}
|
||||||
data: {}
|
sequence:
|
||||||
target:
|
- service: light.turn_off
|
||||||
entity_id: light.alle_lys
|
target:
|
||||||
mode: single
|
entity_id: light.alle_lys
|
||||||
- id: '1692023138692'
|
|
||||||
alias: Luk garage ved langt tryk på '1'
|
# Langt tryk på knap 4 → Tænd alt lys
|
||||||
description: ''
|
- conditions:
|
||||||
trigger:
|
- condition: template
|
||||||
- device_id: 5f6b41e54f3226acd9c9ab54a3acb527
|
value_template: >
|
||||||
domain: hue
|
{{ trigger.event.data.type == 'long_press'
|
||||||
platform: device
|
and trigger.event.data.subtype == 4 }}
|
||||||
type: long_press
|
sequence:
|
||||||
subtype: 1
|
- service: light.turn_on
|
||||||
unique_id: 4b8a056e-973f-48cf-8a19-3586f6b05dcf
|
target:
|
||||||
condition: []
|
entity_id: light.alle_lys
|
||||||
action:
|
|
||||||
- device_id: 3bc3eab99b46dae3e469bfa4060ce0f5
|
|
||||||
domain: cover
|
|
||||||
entity_id: 4bd9c13b7bb0cc3245e38211ded2be92
|
|
||||||
type: close
|
|
||||||
mode: single
|
|
||||||
|
|||||||
Reference in New Issue
Block a user