[ZHA] Philips Hue Tap Dial Switch: toggle / dim multiple lights + event

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

GitHub link

I based this blueprint on a couple of other ZHA blueprints for this device:

Feel free to mix and match, these are the features that my blueprint has that I couldn’t figure out in the other blueprints:

  • each button can be associated with multiple lights. It will toggle all the lights in the same way a light group works: if at least one is on, it turns them all off, and if they are all off, it turns them all on.
  • a light can be associated with more than one button. You could use buttons 1-3 for individual lights and button 4 for all 3 lights at once.
  • the dimmer dial controls the brightness only for the lights that are currently on. If you turn on a light with button 1, then another one with button 2, you can then use the dial to dim up or down only these two
  • as a bonus, if none of the lights is on, the dimmer dial dims up all the lights associated with the 4 buttons starting from 0.
  • Edit: added an event emitted for each light that is toggled. I use that event to suspend motion activation for the lights when switched on.
  name: Hue tap dial switch
  description: Control multiple lights with a Hue tap dial switch
  source_url: https://github.com/GordonFreemanK/ha-blueprints/blob/main/hue_tap_dial_switch.yaml
  domain: automation
      name: Switch
      description: The switch that will trigger the automation
          integration: zha
          manufacturer: Signify Netherlands B.V.
          model: RDM002
          multiple: false
      name: Button 1 lights
      description: The lights to toggle with Button 1
          domain: light
          multiple: true
      name: Button 2 lights
      description: The lights to toggle with Button 2
          domain: light
          multiple: true
      default: []
      name: Button 3 lights
      description: The lights to toggle with Button 3
          domain: light
          multiple: true
      default: []
      name: Button 4 lights
      description: The lights to toggle with Button 4
          domain: light
          multiple: true
      default: []
      name: Brightness
      description: The brightness to turn on the lights at
          min: 0
          max: 100
          unit_of_measurement: '%'
      default: 80
mode: restart
max_exceeded: silent
- platform: event
  event_type: zha_event
    device_id: !input switch
  command: "{{ trigger.event.data.command }}"
  button_1_lights: !input button_1_lights
  button_2_lights: !input button_2_lights
  button_3_lights: !input button_3_lights
  button_4_lights: !input button_4_lights
  - choose:
    - conditions: "{{ command == 'recall' }}"
      - variables:
          scene: "{{ trigger.event.data.args[1] }}"
          lights: >
            {% if scene == 1 %}
              {{ button_1_lights }}
            {% elif scene == 0 %}
              {{ button_2_lights }}
            {% elif scene == 5 %}
              {{ button_3_lights }}
            {% elif scene == 4 %}
              {{ button_4_lights }}
            {% endif %}
          state: "{{ expand(lights) | selectattr('state','eq','on') | list | length > 0 }}"
      - if:
          - condition: template
            value_template: "{{ state }}"
          - service: light.turn_off
              entity_id: "{{ lights }}"
          - service: light.turn_on
              entity_id: "{{ lights }}"
              brightness_pct: !input brightness
      - repeat:
          for_each: "{{ lights }}"
            - event: light_toggled
                state: "{{ not state }}"
                entity_id: "{{ repeat.item }}"
    - conditions: "{{ command == 'step_with_on_off' }}"
      - variables:
          step_mode: "{{ trigger.event.data.params.step_mode }}"
          step_size: "{{ trigger.event.data.params.step_size }}"
      - choose:
        - conditions: "{{ step_mode == 'StepMode.Up' }}"
          - variables:
              lights: >
                {% set lights_all = expand([button_1_lights, button_2_lights, button_3_lights, button_4_lights]) %}
                {% set lights_on = lights_all | selectattr('state','eq','on') | list %}
                {% set lights_used = lights_on if lights_on | length > 0 else lights_all %}
                {{ lights_used | map(attribute='entity_id') | unique | list }}
          - service: light.turn_on
              entity_id: "{{ lights }}"
              brightness_step_pct: "{{ step_size }}"
              transition: 1
        - conditions: "{{ step_mode == 'StepMode.Down' }}"
          - variables:
              lights: >
                {{ expand([button_1_lights, button_2_lights, button_3_lights, button_4_lights])
                  | selectattr('state','eq','on')
                  | map(attribute='entity_id')
                  | unique
                  | list }}
          - service: light.turn_on
              entity_id: "{{ lights }}"
              brightness_step_pct: '{{ -step_size }}'
              transition: 1

Just imported. Seems to be working quite nicely, thank you!

Every button needs to be assigned, which seems to be an unnecessary requirement. I have only two lights at the moment, so I added them twice as a quick workaround.

Strange, the default: [] on buttons 2-4 allows not assigning them (but button 1 is indeed mandatory). I’ve got one configured with only 3 buttons.

Indeed, it works as you described, thanks!

I got the wrong impression from the GUI. There is Entity* field, which seemed mandatory, because of *.
Even when you select it for a moment, but choose nothing, it goes red like an error. :sweat_smile:

First off, that’s an awesome blueprint, so a big thanks to the creator!
Second, two quick questions, please:

  1. If lights are on after a button press, does the event emitted from this blueprint suspend the use/operation of a motion sensor located in the same room?

  2. Could the blueprint be changed to support multiple presses, in the way original hue app does? I’m thinking of adding scenes to each consequent button press…

Thank you in advance!

Thank you for this blueprint!
Unfortunately buttons not working for me, but the dial works as expected - it turns on all four lights and control the dimming for all of them. So I can control only all of my lights at once. I have no clue, why individual button/light switching not working.
Any suggestion?

Hiya sorry for the delay
Events aren’t wired by default, they need to be explicitly subscribed in order to do anything. So it’s entirely up to you how to use it, but yes indeed that’s how I use it: to disable the motion activation in the room.
This is the blueprint I use for this:

It has a little thing added there to subscribe to the HA event emitted when HA starts, so that the motion activation doesn’t stay disabled if you restart HA.

It’s hard to know with little details like this, but since the dial works it seems to have gotten hold of the light IDs, so it sounds possible that you’ve set the brigthness too low (it’s the slider at the bottom of the blueprint when you configure it).

If that’s not the issue, you might have to do a bit of debugging: edit the automation that uses the bluprint, and click the Traces button on the top right of that screen. You get the automation debug information as a state machine. It goes in detail so it might be intimidating…


Maybe a stupid question but after searching for a couple of hours I couldn’t find the correct answer. Every automation or blueprint I have found is using the ZHA or other integrations. I’m using my Hue Bridge and I do see 5 events with the integration. But would like to use the blueprint logic to apply so I can use the four buttons to select the light and dim via rotary.

Does anybody use the Hue Bridge integration?

Any help is appreciated.
Kind regards

I haven’t really tried with the Hue integration, no. To get familiar with the integration events, you have to see what events come through when you go to Developer Tools > Events > Listen to events and subscribe to whatever the Hue integration emits, then see what comes through.

Normally then it would just be a matter of filtering the blueprint inputs on the right brand, and then wiring the right trigger - the rest of the automations should work in a similar fashion whatever the integration.

You’d have first to make sure the devices aren’t directly controlled by the Hue app, which I remember is possible.