Philips Hue Tap Dial Switch - ZHA

hi all.
would anybody be able to help - i would like to use this blueprint but to control only one light with each button linked to one colour.
in other words, i would like first button to turn a light blue, second button the same light but green, etc.
I would also like the “Current Light” to adjust the brightness of the chosen colour.

any idea how i could accomplish that?

You wouldn’t be able to do that with this blueprint as it is. But you could modify the blueprint to take actions instead of just lights. Then you could setup those actions to be turning on the light with a colour.

Thanks @apollo1220
could you point me in the right direction how to modify the blueprint? I know how to access the blueprint but what should I modify?

You would need to replace the light selectors with action selectors, something like

    press_action:
      name: Press Action
      description: Action to perform on Press.
      default: []
      selector:
        action: {}

Then to use the actions, something like this

- choose:
  - conditions:
    - condition: template
      value_template: '{{ trigger.event.data.command == "single" }}'
    sequence: !input 'press_action'

Those examples are copied out of one of my other blueprints, so don’t expect them to directly relate to this blueprint

Thanks @apollo1220
I unfortunately couldn’t get this to work.
Any chance I could ask you to help me with this in exchange for some coffees or a donation of some kind?

You’d want to do something like this

blueprint:
  name: Philips Tap Dial Switch - Actions
  description: ''
  domain: automation
  input:
    remote:
      name: Philips Hue Tap Switch
      selector:
        device:
          integration: zha
          manufacturer: Signify Netherlands B.V.
          model: RDM002
    first_action:
      name: First Button
      description: Action to perform on Press.
      default: []
      selector:
        action: {}
    second_action:
      name: (OPTIONAL) Second Button
      description: Action to perform on Press.
      default: []
      selector:
        action: {}
    third_action:
      name: (OPTIONAL) Third Button
      description: Action to perform on Press.
      default: []
      selector:
        action: {}
    forth_action:
      name: (OPTIONAL) Forth Button
      description: Action to perform on Press.
      default: []
      selector:
        action: {}
    dimming_light:
      name: (OPTIONAL) Dimming Light
      description: Light to be dimmed by turning dial.
      default:
      selector:
        entity:
          domain: light
    dim_scale:
      name: Diming Scale
      description: Scale factor for the dimming. This value will be multiplied by the value given from the dial. So lower number, more gradual dimming. Larger number, faster dimming.
      default: 1.0
      selector:
        number:
          min: 0.0
          max: 5.0
          step: 0.01
mode: restart
max_exceeded: silent
variables:
  first_action: !input "first_action"
  second_action: !input "second_action"
  third_action: !input "third_action"
  forth_action: !input "forth_action"
  dimming_light: !input "dimming_light"
  dim_scale: !input "dim_scale"
trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input "remote"
action:
  - variables:
      command: "{{ trigger.event.data.command }}"
      args: "{{ trigger.event.data.args }}"
      params: "{{ trigger.event.data.params }}"
      scene: "{{ trigger.event.data.params.scene_id }}"
      step_mode: "{{ trigger.event.data.params.step_mode }}"
      step_size: "{{ trigger.event.data.params.step_size }}"
  - choose:
      - conditions:
          - "{{ command == 'recall' }}"
          - "{{ scene == 1 }}"
        sequence: !input 'first_action'
      - conditions:
          - "{{ command == 'recall' }}"
          - "{{ second_action != none }}"
          - "{{ scene == 0 }}"
        sequence: !input 'second_action'
      - conditions:
          - "{{ command == 'recall' }}"
          - "{{ third_action != none }}"
          - "{{ scene == 5 }}"
        sequence: !input 'third_action'
      - conditions:
          - "{{ command == 'recall' }}"
          - "{{ forth_action != none }}"
          - "{{ scene == 4 }}"
        sequence: !input 'forth_action'
      - conditions:
          - "{{ command == 'step_with_on_off' }}"
          - "{{ step_mode == 'StepMode.Up' }}"
          - "{{ dimming_light != none }}"
        sequence:
          - service: light.turn_on
            target:
              entity_id: !input 'dimming_light'
            data:
              brightness_step_pct: "{{ step_size * dim_scale }}"
              transition: 1
      - conditions:
          - "{{ command == 'step_with_on_off' }}"
          - "{{ step_mode == 'StepMode.Down' }}"
          - "{{ dimming_light != none }}"
        sequence:
          - service: light.turn_on
            target:
              entity_id: !input 'dimming_light'
            data:
              brightness_step_pct: "{{ -step_size * dim_scale }}"
              transition: 1

@apollo1220 Thank you very very much! this looks like it will work perfectly (im not home this weekend but will try when home).

Do you have a buy me a coffee account or something for a small token of thanks?

No I don’t. Don’t worry about it

@apollo1220 thanks a lot for this blueprint! I slightly adjusted it to suit my situation, only the first 3 buttons turn on a light, while the fourth button turns off the light selected previously. I removed the toggle option. I couldn’t achieve this without your blueprint. Thanks!

I am still struggling with one thing, hope you can help. I don’t want to turn off the selected light when dimming. If it reaches 1% it should be the final position. Should this be more of a condition? Maybe adding - '{{ state_attr('current_light, 'brightness') => 1) ?

I am not experienced with coding and try to do my best, but I am more lucky than skilled I guess.

Would this be the right way?:

  - conditions:
    - '{{ command == ''step_with_on_off'' }}'
    - '{{ step_mode == ''StepMode.Down'' }}'
    sequence:
    - choose:
      - conditions: 
        - '{{ current_light != none }}'
        - '{{ state_attr('current_light, 'brightness') => 1)' 
      sequence:
        - service: light.turn_on
          target: '{{ lights[states(current_light)] }}'
          data:
            brightness_step_pct: '{{ -step_size * dim_scale }}'
            transition: 1
      default:
      - service: light.turn_on
        target: !input first_light
        data:
          brightness_step_pct: '{{ -step_size * dim_scale }}'
          transition: 1

The part where the lights don’t turn off is also what I would like to see.

You are on the right track with checking the current brightness level. But due to the step_size and dim_scale, you need to take those into account in the comparison as well instead of just comparing against 1.

Hi there,

nice blueprint! How can I make adjustment to the initial values for transition, brightness_pct and color_temp_kelvin of the button setup?

I tried adding respective entries as follows in the data part. After refreshing the according automation I didn’t receive any error. Yet, using the button the newly added settings are being ignored.

Here’s the snippet of the changed first-button-section:

  - conditions:
    - '{{ command == ''recall'' }}'
    - '{{ scene == 1 }}'
    sequence:
    - service: homeassistant.toggle
      target: !input first_light
    - choose:
      - conditions: '{{ current_light != none }}'
        sequence:
        - service: input_text.set_value
          target:
            entity_id: !input current_light
          data:
            value: first_light
            transition: 2.0
            brightness_pct: 75
            color_temp_kelvin: 4000

The service being called there is input_text.set_value so that won’t have any effect on the light. You would be looking to replace the service call to homeassistant.toggle with a call to light.turn_on and passing that extra data to that service call.

- conditions:
    - '{{ command == ''recall'' }}'
    - '{{ scene == 1 }}'
    sequence:
    - service: light.turn_on
      target: !input first_light
      data:
          transition: 2.0
          brightness_pct: 75
          color_temp_kelvin: 4000
    - choose:
      - conditions: '{{ current_light != none }}'
        sequence:
        - service: input_text.set_value
          target:
            entity_id: !input current_light
          data:
            value: first_light

Something like that

I edited your example here (without trying it) so some syntax might be a little off.

Hello Jeremy, thanks a bunch - that did the trick for me :partying_face:

As I delve deeper into the functionality of the Philips Hue Tap Dial Switch in ZHA I realised that it is missing a feature that is available in the corresponding Z2M implementation: individual button long presses.

I only manage to get a generic long press that generates the same signal for all four buttons by using this:

    - conditions:
          - "{{ command == 'step_with_on_off' }}"
          - "{{ step_mode == 'StepMode.Down' }}"
          - "{{ step_size == 255 }}"

Did you come across custom_zha_quirks that address this feature or do you know if this product is a tad limited using ZHA?

Thanks for sharing if you know something about it!

1 Like

Sorry to bump this question. Anyone having some idea why ZHA is a bit limited on support of the Philips Hue Tap Dial Switch? I mean double clicking and long pressing buttons is already implemented using Z2M.

What is the issue on that and where can I find some documentation so maybe I can support the quest to unleash all features also in ZHA?

Here’s another bump. Are double clicking and long pressing still not possible with ZHA?

Thank you for this Blueprint @apollo1220

I have noticed that i get a warning almost everytime i use the switch in my logs, are there anyway to use some sort of if statement to verify that the scene_id, step_mode, step_size exists before adding them as variables?

2023-09-17 10:20:39.848 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'scene_id' when rendering '{{ trigger.event.data.params.scene_id }}'

2023-09-17 10:20:39.854 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'step_mode' when rendering '{{ trigger.event.data.params.step_mode }}'

2023-09-17 10:20:39.856 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'step_size' when rendering '{{ trigger.event.data.params.step_size }}'

@apollo1220 I just sent a pull request for fixing this.

Thanks for the PR. It’s been merged in.