Blueprint challenge Hue Wall Switch

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 
1 Like

Thanks, I just got the hue wall switch and I can use it. This blueprint also does exactly what I wanted to do with it in the first place.

Great to hear that, hope to improve the speed of it sometime soon with the help of the community!

I’m having a similar issue: I want to turn on my light with a short press, and turn it on dimmed with a long press. However, using the philips hue bridge the short_release comes with a delay of 1 second, so it’s a bit laggy and I’m thinking about using a way to already react on the inital_release.
Is it the same with zigbee->MQTT, or is the Release left_hold_release event there instantaneous when you release the switch?

Have a look at this one…works kindah the same

Did you figure something out here? I’m looking to do something similar, but more like its defaultk with the hue bridge. I use it with a single rocker (or actually a powered dual rocker where the other one is actually powered) so can only use 1 rocker, so looking for it to hold to dim and then hold again to brighten and short press is either on or off.

Maybe trying this will avoid conflict between lightning and dimming actions :

Left_press_release = light on
Left_hold = dim up
Right_press_release = light off
Right_hold = dim down

1 Like

Hi @neilimixamo, that works great! Thanks!!

1 Like

Is there anyway to make this work with SkyConnect (ZHA)?

How are you able to use this blueprint with a Hue Bridge? I am using the Hue Bridge myself and i cannot for the life of me get the Wall Switch to work…