I have a hue wall switch module. I want to know if the switch is closed or open. I can achieve this with "push-button" mode (value 1 or 3), but while pressed it sends "hold" events every 1 second. This does not fit my goals as it will deplete the battery. In "rocker mode" (mode 0 or 2) it seems the zha event does not contain any information about whether the contact is closed or open. Has anybody gotten this to work?
#[ZHA][Hue] Wall Switch Module closed vs open detection
1 messages · Page 1 of 1 (latest)
I worked around that with input boolean helpers and an automation toggling them on and off to store the state and toggles the lights.
My automation is listening for differend zha_events and the ieee address of the switch.
triggers:
- trigger: event
event_type: zha_event
event_data:
command: "on"
id: on
- trigger: event
event_type: zha_event
event_data:
command: off_with_effect
id: off
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- on
- condition: template
value_template: "{{ trigger.event.data.device_ieee == \"00:00:00:00:00:00:00:00\" }}"
sequence:
- action: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.switch_room_1
- action: light.toggle
metadata: {}
data: {}
target:
entity_id: light.room_1
- conditions:
- condition: trigger
id:
- off
- condition: template
value_template: "{{ trigger.event.data.device_ieee == \"00:00:00:00:00:00:00:00\" }}"
sequence:
- action: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.switch_room_1
- action: light.toggle
metadata: {}
data: {}
target:
entity_id: light.room_1
mode: parallel
max: 10
thanks @quiet cypress !
by the way, you can put the device_ieeee filter in the trigger to minimize the trigering of your automation
I am using that automation for multiple switches. If you prefer one automation per switch, you can put that in the trigger indeed.
i don't think the "wall switch module" sends off with effect . but thanks for replying
Mine does in switch mode.
event_type: zha_event
data:
device_ieee: xxx
device_id: xxx
unique_id: xxx
endpoint_id: 1
cluster_id: 6
command: off_with_effect
args:
- 0
- 0
params:
effect_id: 0
effect_variant: 0
origin: LOCAL
time_fired: "2025-08-30T14:40:30.042513+00:00"
context:
id: xxx
parent_id: null
user_id: null