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:
2026-03-17 16:22:35 +01:00
parent f1967f24cd
commit 1f261ee8d2
+53 -60
View File
@@ -1,68 +1,61 @@
- id: '1691939802290'
alias: Åbn garage ved tryk på 1
description: ''
- id: hue_switch_garage_and_lights
alias: Hue switch - garage og lys
mode: restart
trigger:
- device_id: 5f6b41e54f3226acd9c9ab54a3acb527
domain: hue
platform: device
type: initial_press
subtype: 1
unique_id: 4b8a056e-973f-48cf-8a19-3586f6b05dcf
condition: []
action:
- device_id: 3bc3eab99b46dae3e469bfa4060ce0f5
domain: cover
entity_id: 4bd9c13b7bb0cc3245e38211ded2be92
type: open
mode: single
- id: '1691941083623'
alias: Sluk alt lys ved tryk på 0
description: ''
trigger:
- device_id: 5f6b41e54f3226acd9c9ab54a3acb527
domain: hue
platform: device
type: initial_press
subtype: 4
unique_id: f97d54a1-2283-4fb0-8709-b873a310732b
condition: []
- platform: event
event_type: hue_event
event_data:
id: 5f6b41e54f3226acd9c9ab54a3acb527
action:
- choose:
# --- GARAGE ---
# Kort tryk på knap 1 → Åbn garage
- conditions:
- condition: template
value_template: >
{{ trigger.event.data.type == 'initial_press'
and trigger.event.data.subtype == 1 }}
sequence:
- service: cover.open_cover
target:
entity_id: cover.anne
# Langt tryk på knap 1 → Luk garage
- conditions:
- condition: template
value_template: >
{{ trigger.event.data.type == 'long_press'
and trigger.event.data.subtype == 1 }}
sequence:
- service: cover.close_cover
target:
entity_id: cover.anne
# --- LYS ---
# Kort tryk på knap 4 → Sluk alt lys
- conditions:
- condition: template
value_template: >
{{ trigger.event.data.type == 'initial_press'
and trigger.event.data.subtype == 4 }}
sequence:
- service: light.turn_off
data: {}
target:
entity_id: light.alle_lys
mode: single
- id: '1691941222856'
alias: Tænd alt lyset ved langt tryk på 0
description: ''
trigger:
- device_id: 5f6b41e54f3226acd9c9ab54a3acb527
domain: hue
platform: device
type: long_press
subtype: 4
unique_id: f97d54a1-2283-4fb0-8709-b873a310732b
condition: []
action:
# Langt tryk på knap 4 → Tænd alt lys
- conditions:
- condition: template
value_template: >
{{ trigger.event.data.type == 'long_press'
and trigger.event.data.subtype == 4 }}
sequence:
- service: light.turn_on
data: {}
target:
entity_id: light.alle_lys
mode: single
- id: '1692023138692'
alias: Luk garage ved langt tryk på '1'
description: ''
trigger:
- device_id: 5f6b41e54f3226acd9c9ab54a3acb527
domain: hue
platform: device
type: long_press
subtype: 1
unique_id: 4b8a056e-973f-48cf-8a19-3586f6b05dcf
condition: []
action:
- device_id: 3bc3eab99b46dae3e469bfa4060ce0f5
domain: cover
entity_id: 4bd9c13b7bb0cc3245e38211ded2be92
type: close
mode: single