Z2M Philips Hue Dimmer Switch with custom actions

This is a fork from Original version

The original works for the creator and will not be updated according to their comment.

Each button on the remote can be set to whatever action for both _press and _hold events.

The blueprint have been updated to:

  • New mqtt payload using underscore (_) instead of dash (-).
  • Defaults have been added to the inputs so that you don’t have to use them.

Verified to work with Philips Hue switch model #929002398602
image

Github gist
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

blueprint:
  name: Zigbee2Mqtt Hue Dimmer Switch control v3
  description: ''
  domain: automation
  input:
    dimmer_action:
      name: Dimmer MQTT topic
      description: 'type in your Dimmer MQTT topic (i.e. zigbee2mqtt/Dimmer/action)'
      selector:
        text:
    action_on_press:
      name: on_press
      description: select action to run when you press ON
      default: []
      selector:
        action:
    action_off_press:
      name: off_press
      description: select action to run when you press OFF
      default: []
      selector:
        action:
    action_up_press:
      name: up_press
      description: select action to run when you press UP
      default: []
      selector:
        action:
    action_down_press:
      name: down_press
      description: select action to run when you press DOWN
      default: []
      selector:
        action:
    action_on_hold:
      name: on_hold
      description: select action to run when you hold ON
      default: []
      selector:
        action:
    action_off_hold:
      name: off_hold
      description: select action to run when you hold OFF
      default: []
      selector:
        action:
    action_up_hold:
      name: up_hold
      description: select action to run when you hold UP
      default: []
      selector:
        action:
    action_down_hold:
      name: down_hold
      description: select action to run when you hold DOWN
      default: []
      selector:
        action:

trigger:
  - platform: mqtt
    topic: !input dimmer_action
    payload: on_press
    id: dimmer_on
  - platform: mqtt
    topic: !input dimmer_action
    id: dimmer_off
    payload: off_press
  - platform: mqtt
    topic: !input dimmer_action
    id: dimmer_up
    payload: up_press
  - platform: mqtt
    topic: !input dimmer_action
    id: dimmer_down
    payload: down_press
  - platform: mqtt
    topic: !input dimmer_action
    id: dimmer_on_hold
    payload: on_hold
  - platform: mqtt
    topic: !input dimmer_action
    payload: off_hold
    id: dimmer_off_hold
  - platform: mqtt
    topic: !input dimmer_action
    id: dimmer_up_hold
    payload: up_hold
  - platform: mqtt
    topic: !input dimmer_action
    payload: down_hold
    id: dimmer_down_hold

action:
  - choose:
      - conditions:
          - condition: trigger
            id: dimmer_on
        sequence:
          !input action_on_press
      - conditions:
          - condition: trigger
            id: dimmer_off
        sequence:
          !input action_off_press
      - conditions:
          - condition: trigger
            id: dimmer_up
        sequence:
          !input action_up_press
      - conditions:
          - condition: trigger
            id: dimmer_down          
        sequence:
          !input action_down_press
      - conditions:
          - condition: trigger
            id: dimmer_on_hold
        sequence:
          !input action_on_hold
      - conditions:
          - condition: trigger
            id: dimmer_off_hold
        sequence:
          !input action_off_hold
      - conditions:
          - condition: trigger
            id: dimmer_up_hold
        sequence:
          !input action_up_hold
      - conditions:
          - condition: trigger
            id: dimmer_down_hold
        sequence:
          !input action_down_hold
    default: []
mode: restart
4 Likes

I was going to add links and images to the switch model as well as to the github gist repository but this forum won’t allow me to use more than 2 links as a new user.

It is stupid but I will have to come back and update the topic later.

Done…

Hi, if you don’t mind, can you please tell me how to find the ‘Dimmer MQTT topic’? Thanks!

My remote has the Hue button, is it possible to use that as a button too?

It’s the name of your device - mine is like this zigbee2mqtt/Hallway Hue Dimmer/action

Thank you for updating this, been having issues with the older blueprint for ages. Swapped over to this one and it all works perfectly again.

Confirmed to be working with the older hue switches too Philips 324131092621 control via MQTT | Zigbee2MQTT

Hi

I can’t get it working with the older hue switch but working perfectly with the new one, any tips for how you got the old one working?

Is it expected that _press action is executed in all cases, even if you want only _hold to trigger?

EDIT: Had to create my own version of the blueprint to handle hold and press actions separately.

@jhjelmar I noticed the same issue as @JetSerge. In V3, it would trigger both the *_press and *_hold actions whenever the dimmer’s button was held down. They should be mutually exclusive.

@JetSerge, I believe your solution (depending on keeping state in a helper text box) is overly complicated. I believe the correct solution is to just respond to the *_press_release and *_hold_release actions. This avoids the double-triggering issue, and keeps this blueprint as simple as possible.

The small amount of delay between when a press or hold begins and ends is irrelevant. Responding to when a user action completes actually matches how humans expect controls to work IMO. This is how Web/iOS/Android controls work for example. And I believe it’s why Phillips includes these “release” events.

Here’s a V4 version adjusted to react to user actions only once they’re complete: Z2M_Hue_Dimmer_Switch_v4.yaml · GitHub

1 Like

Your keyboard, mouse and TV remote buttons react on press, not on release. I would expect the physical light controller with the buttons to work the same way. My solution is flexible and allows to use both options depending on your personal preferences.

shrug based on how the hardware generates these events, I’m fairly sure respond-on-release is the way Phillips intended these switches to work. but… to each their own!

Hi. Im a newbee to this world. What command should i use for turn the lights on and off and to dim the lights up and down? is it just turn lights on in action field or what to do please help

To toggle the lights or change the brightness:

My dimmer switch automation using this blueprint dispear and when I try to make it again i get following error when trying to save

Message malformed: offset should be format ‘HH:MM’, ‘HH:MM:SS’ or ‘HH:MM:SS.F’ for dictionary value @ data[‘action’][0][‘choose’][4][‘sequence’][0][‘delay’]

any idea what is going wrong here? :frowning:

/edit running hass 2023.3
/Thrawn

Thank you for posting this.

My hue dimmer switch works my lights for a press and blinds for hold. So it was quite annoying to be altering the lights to open the blinds each time.