Hi there,
i am trying to make a Blueprint for the ‘new’ Wall Switches of HUE and Zigbee2MQTT.
these units are designed to make 2 conventional buttons smart.
Each button is a normally open contact that sends their action via Zigbee → MQTT.
As soon as you press either button is sends left_press or right_press.
If you hold the key it sends left_hold or right_hold.
As soon as you realse the button it sends left_hold release or right_hold_release.
I would like to use them not only as on/of switches but as a dimmer.
My idea:
Left button press = light on
Left button hold = dim up
right button press = light off
right button hold = dim down
I got it working so far but since for the right button you always get an right_press (light off) before getting righ_hold i had to introduce a wait for trigger to overcome that the light turns off before dimming down.
The downside to that is that because of this each action waits the ‘wait for trigger’ 0.9 seconds…
I would love to have it more reactive.
Do you have any thoughts/ideas on how to make this better?
Any help would be greatly appreciated!
blueprint:
name: Hue Wall Switch Module
description: 'Blueprint for Home Assistant for the Hue Wall Switch using zigbee2mqtt.'
domain: automation
input:
switch:
name: Switch
description: Action sensor of Hue Wall Switch to use
selector:
entity:
domain: sensor
integration: mqtt
press_left:
name: Press left button
description: Action to run on left button press
default: []
selector:
action: {}
hold_left:
name: Hold left button
description: Action to run on holding left button
default: []
selector:
action: {}
release_left:
name: Release left button
description: Action to run on releasing left button
default: []
selector:
action: {}
press_right:
name: Press right button
description: Action to run on right button press
default: []
selector:
action: {}
hold_right:
name: Hold right button
description: Action to run on holding right button
default: []
selector:
action: {}
release_right:
name: Release right button
description: Action to run on releasing right button
default: []
selector:
action: {}
# hold_button_delay:
# name: Right Hold button delay
# description: Max delay that the automation waits for a right_hold message.
# this can be required to prevent the right_press action to be executed before the right_hold message arrives.
# default: 800
# selector:
# number:
# min: 100.0
# max: 1500.0
# unit_of_measurement: milliseconds
# mode: box
# step: 10.0
mode: single
max_exceeded: silent
trigger:
- platform: state
entity_id: !input switch
to:
- "left_press"
- "left_hold"
- "left_hold_release"
- "right_press"
- "right_hold"
- "right_hold_release"
action:
- variables:
command: "{{ trigger.to_state.attributes.action }}"
- wait_for_trigger:
- platform: state
entity_id: !input switch
to: "right_hold"
timeout: 0.9
continue_on_timeout: true
- choose:
- conditions:
# when button right_hold did not come withing the timeout
- condition: template
value_template: "{{ wait.trigger == none }}"
sequence:
- choose:
- conditions: '{{ command == ''left_press'' }}'
sequence: !input press_left
- conditions: '{{ command == ''left_hold'' }}'
sequence: !input hold_left
- conditions: '{{ command == ''left_hold_release'' }}'
sequence: !input release_left
- conditions: '{{ command == ''right_press'' }}'
sequence: !input press_right
- conditions: '{{ command == ''right_hold_release'' }}'
sequence: !input release_right
# right_hold within timout
default:
- choose:
- conditions: []
sequence: !input hold_right