Philips Hue Dimmer Switch v2 (Zigbee2MQTT)

I tried several existing blueprints and none worked as I wanted. Here is my take on it.

See description for the details.

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

To have different actions on short press and on hold (long press), use ‘button release’ (*_press_release) and ‘button hold once’ (*_hold_once) commands, as ‘press’ (*_press) will always trigger before ‘button hold’ (*_hold).

When you hold a button, ‘button hold’ (*_hold) command is repeated roughly once per second. This may not work as desired with actions like toggling light/switch.

If you want an action to run only once when the button hold action is registered, use ‘button hold once’ (*_hold_once). It’s better than using ‘button hold release’ as the result can be observed before releasing the button after holding.

As ‘button hold’ action is repeated by the device while you keep holding the button, it’s a good way to run actions which increment / decrement some value (such as light dimming).

To make it react as soon as the button is pressed, copy the same action to ‘button press’ (press action occurs immediately, while hold action occurs after a delay).

Make sure to manually create a separate Text Helper per dimmer device and define its entity in the automation. It’s used to store the last controller event to filter possible empty events and handle ‘button hold once’ actions.

4 Likes

Thank you for this blueprint, i’ve been using it for a while, sadly after updating to home assistant core 2023.1.x, having this blueprint installed results in a notification asking me to check the automation and default_config logs and my automations page is completely empty with no automations working.

The logs point at a very generic “dependency error”.

Has anybody experienced this as well? Is there a long-term fix to it? For now, I rolled back to 2022.12.9, which seems to fix the issue.

I have no errors with this blueprint and the following HA versions:

Home Assistant 2023.1.7
Supervisor 2022.12.1
Operating System 9.4
Frontend 20230110.0 - latest

Works exactly the same as before.

Thank you for answering.
That‘s interesting to hear, it‘s quite weird because i have no issue when on 2023.1.x and uninstalling the plugin, but the notification appears and all automations stop working, the moment i reinstall this blueprint.
I‘ll keep digging.

any idea on hos to fix this?

Logger: homeassistant.components.automation
Source: components/automation/config.py:207
Integration: automation (documentation, issues)
First occurred: 27 January 2023 at 17:58:28 (2 occurrences)
Last logged: 27 January 2023 at 17:58:28

Blueprint ‘Philips Hue Dimmer switch v2 (Zigbee2MQTT)’ generated invalid automation with inputs OrderedDict([(‘action_sensor’, ‘sensor.attic_hue_dimmer_switch_action’), (‘helper_last_controller_event’, ‘input_text.atticdimmerswitchlastevent’), (‘on_press’, [OrderedDict([(‘device_id’, ‘’), (‘domain’, ‘’), (‘entity_id’, ‘’)])])]): Integration ‘’ not found. Got {‘mode’: ‘restart’, ‘max_exceeded’: ‘SILENT’, ‘trigger’: [{‘platform’: ‘event’, ‘event_type’: [Template(“state_changed”)], ‘event_data’: {‘entity_id’: ‘sensor.attic_hue_dimmer_switch_action’}}], ‘condition’: [{‘condition’: ‘template’, ‘value_template’: Template("{{ trigger.event.data.new_state.state not in ("", “None”) }}")}], ‘action’: [{‘variables’: <homeassistant.helpers.script_variables.ScriptVariables object at 0x7fa65bd600>}, {‘service’: ‘input_text.set_value’, ‘data’: {‘entity_id’: 'in…
Blueprint ‘Philips Hue Dimmer switch v2 (Zigbee2MQTT)’ generated invalid automation with inputs OrderedDict([(‘action_sensor’, ‘sensor.my_room_hue_dimmer_switch_action’), (‘helper_last_controller_event’, ‘input_text.myroomdimmerswitchlastevent’), (‘on_press’, [OrderedDict([(‘device_id’, ‘’), (‘domain’, ‘’), (‘entity_id’, ‘’)])]), (‘up_press’, [OrderedDict([(‘type’, ‘turn_on’), (‘device_id’, ‘86a2f4ccd2bcd95d8bb0b035f1e5040a’), (‘entity_id’, ‘switch.open_my_blinds’), (‘domain’, ‘switch’)])]), (‘down_press’, [OrderedDict([(‘type’, ‘turn_on’), (‘device_id’, ‘749725e49387b99bc33392da3a1b2e3b’), (‘entity_id’, ‘switch.close_my_blinds’), (‘domain’, ‘switch’)])]), (‘off_press’, [OrderedDict([(‘type’, ‘turn_on’), (‘device_id’, ‘303994b7c268b4c8eb34aed374b24353’), (‘entity_id’, ‘switch.close_my_window’), (‘domain’, ‘switch’)])])]): Integration ‘’ not found. Got {‘mode’: ‘restart’, ‘max_exceeded’: ‘SILENT’, ‘trigger’: [{‘platform’: ‘event’, ‘event_type’: [Template(“state_changed”)], ‘event_data’: {‘entity_id’: ‘sensor.my_room_hue_dimmer_switch_action’}}], ‘condition’: [{‘condition’: ‘template’, ‘value_template’: Template("{{ trigger.event.data.new_state.state not in ("", “None”) }}")}], ‘action’: [{‘variables’: <homeassistant.helpers.script_variables.ScriptVariables object at 0x7fa629fe50>}, {‘service’: ‘input_text.set_value’, ‘data’: {'entity_…

Does it help if you remove all the automations based on this blueprint and then add a new one from scratch?

I tried that when the issue first appeared and it didn‘t help. I tried it again yesterday and for now it seems to have fixed it - thank you for the suggestion.

This works really very nicely! Thank you so much!

Do you think that there is any way to control the speed (repetition intervals) so we can make brightness changes smoother?

Hi Jet,
Being a newcomer to HA I fell upon this blueprint but I’m not sure how to make the file and what to put in it? Searched for other content on it without any look. Would it be possible for you to give some instructions on this point?

Go to http://homeassistant.local:8123/config/helpers, add a new Text helper like this:

1 Like

Hardware itself repeats hold button events. You can probably create your own automation that will start a timer which repeats at the desired interval on the first hold event (hold_once) and then stops the timer when the button is released after hold (hold_release).

Wow, does just what I want, thanks :grinning:

thanks for the Blueprint and explanation about the helper.
Currently, the helper correctly recognizes all the state changes/button presses, however the automation itself doesn’t seem to ever get past the condition section, result for this is always false:

condition: template value_template: '{{ trigger.event.data.new_state.state not in ("", "None") }}'

And so none of the configured actions take place. Any ideas?

Do you use the supported switch via z2m integration? It looks like events are not delivered correctly for some reason.

I’m new to HA and zmqtt and stuff. I understand how to create basic automation and use with blueprint, but here I’m a bit lost. It doesn’t work bc I didn’t do the text helper stuff, can someone help me with that ? I absolutely don’t know what it is, and how to use it.

Thanks in advance, and thanks a lot for the blueprint.

I just found the helpers in HA, I read too fast, my bad, but I’m still not sure what to put into it (since imgur image no longer exists).

The link was broken, I edited that comment and added the image.

1 Like

Hi, thanks a lot, it seems to work now. I have a question though, is it possible to have toggle for scene with Hue Button like in the original one ?

I want to be able to just click Hue Button and it switch to next scene. And if I have for instance 4 scenes, when I’m at the fourth scene, when tapping the Hue Button it will switch to first scene.

I’m not sure how to do this, or if it’s possible.

Thanks for your time.

You might want to google for the solution, for example, check this thread.

1 Like
My setup:
Raspberry Pi 4B+ 4GB
Core: 2024.1.2
Supervisor: 2023.12.0
Operating System: 11.3
Frontend: 20240104.0
Zigbee2MQTT: 1.35.1-1
Mosquitto Brocker: 6.4.0
ITead Sonoff Zigbee 3.0 Dongle-P: Firmware 20230507
Philips Hue Dimmer Switch Modell: RWL022
Philips Hue Dimmer Switch Firmeware: 2.45.2_hF4400CA

Dear Serge

I do have a problem with setting up your blueprint.
I followed your description but in the trace screen of the automation I get only this error message.

Error: UndefinedError: 'dict object' has no attribute 'event'

And the step config says:

variables:
  helper_last_controller_event: input_text.philips_hue_dial_switch_last_pressed
  command: '{{ trigger.event.data.new_state.state }}'
  prev_command: '{{ states(helper_last_controller_event) }}'

As possible “sensors” I can only choose from thoese:

sensor.philips_hue_dimmer_switch_zigbee2matt_battery
sensor.philips_hue_dimmer_switch_linkquality
sensor.philips_hue_dial_switch_zigbee2mqtt_action_time

My config looks like this:

mode: restart
max_exceeded: silent
trigger:
  - platform: event
    event_type: state_changed
    event_data:
      entity_id: sensor.philips_hue_dial_switch_zigbee2mqtt_action_time
condition:
  - condition: template
    value_template: '{{ trigger.event.data.new_state.state not in ("", "None") }}'
action:
  - variables:
      helper_last_controller_event: input_text.philips_hue_dial_switch_last_pressed
      command: '{{ trigger.event.data.new_state.state }}'
      prev_command: '{{ states(helper_last_controller_event) }}'
  - service: input_text.set_value
    data:
      entity_id: input_text.philips_hue_dial_switch_last_pressed
      value: '{{ command }}'
  - choose:
      - conditions:
          - '{{ command == "on_press" }}'
        sequence:
          - service: scene.turn_on
            metadata: {}
            target:
              entity_id: scene.kueche_licht_ein
      - conditions:
          - '{{ command == "on_press_release" }}'
        sequence: []
      - conditions:
          - '{{ command == "on_hold" }}'
        sequence: []
      - conditions:
          - '{{ command == "on_hold_release" }}'
        sequence: []
      - conditions:
          - '{{ command == "up_press" }}'
        sequence: []
      - conditions:
          - '{{ command == "up_press_release" }}'
        sequence: []
      - conditions:
          - '{{ command == "up_hold" }}'
        sequence: []
      - conditions:
          - '{{ command == "up_hold_release" }}'
        sequence: []
      - conditions:
          - '{{ command == "down_press" }}'
        sequence: []
      - conditions:
          - '{{ command == "down_press_release" }}'
        sequence: []
      - conditions:
          - '{{ command == "down_hold" }}'
        sequence: []
      - conditions:
          - '{{ command == "down_hold_release" }}'
        sequence: []
      - conditions:
          - '{{ command == "off_press" }}'
        sequence: []
      - conditions:
          - '{{ command == "off_press_release" }}'
        sequence: []
      - conditions:
          - '{{ command == "off_hold" }}'
        sequence: []
      - conditions:
          - '{{ command == "off_hold_release" }}'
        sequence: []
  - choose:
      - conditions:
          - '{{ command == "on_hold" and prev_command == "on_press" }}'
        sequence:
          - service: scene.turn_on
            metadata: {}
            target:
              entity_id: scene.kueche_licht_aus
      - conditions:
          - '{{ command == "up_hold" and prev_command == "up_press" }}'
        sequence: []
      - conditions:
          - '{{ command == "down_hold" and prev_command == "down_press" }}'
        sequence: []
      - conditions:
          - '{{ command == "off_hold" and prev_command == "off_press" }}'
        sequence: []
id: '1704654875271'
alias: Philips Hue Dimmer switch v2 (Zigbee2MQTT)
description: ''

Thank you for your feedback.
Kind regards
Thomas