Philips Hue Tap Dial Switch - ZHA

Requires the Philips Hue Tap Dial Switch and at least one light to be controlled.

Turn on/off light(s) using the dial switch. Each of the four buttons can control a different light(s). If you setup the optional current input_text, it will dim the most recent light with the dial.

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

Edit (15/09/2022): Added dimming scaling

blueprint:
  name: Philips Tap Dial Switch
  description: 'Control lights with a Philips Hue Tap Switch.
    Use the four buttons to control up to four light(s) with an on/off toggle. The dial can be used to dim the most recently used light.
    '
  domain: automation
  input:
    remote:
      name: Philips Hue Tap Switch
      selector:
        device:
          integration: zha
          manufacturer: Signify Netherlands B.V.
          model: RDM002
    first_light:
      name: First Light
      description: The light(s) to control with first button
      selector:
        target:
          entity: {}
    second_light:
      name: (OPTIONAL) Second Light
      description: The light(s) to control with second button
      default: {}
      selector:
        target:
          entity: {}
    third_light:
      name: (OPTIONAL) Third Light
      description: The light(s) to control with third button
      default: {}
      selector:
        target:
          entity: {}
    forth_light:
      name: (OPTIONAL) Forth Light
      description: The light(s) to control with forth button
      default: {}
      selector:
        target:
          entity: {}
    current_light:
      name: (OPTIONAL) Current Light
      description:
        'Text helper to track the current light to dim. Set for the dimmer controls to change which light they are controlling according to the last one turned on.'
      default:
      selector:
        entity:
          domain: input_text
    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
  source_url: https://github.com/apollo1220/blueprints/blob/main/philips_zigbee_dial.yaml
mode: restart
max_exceeded: silent
variables:
  first_light: !input "first_light"
  second_light: !input "second_light"
  third_light: !input "third_light"
  forth_light: !input "forth_light"
  current_light: !input "current_light"
  dim_scale: !input "dim_scale"
  lights:
    first_light: !input "first_light"
    second_light: !input "second_light"
    third_light: !input "third_light"
    forth_light: !input "forth_light"
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:
          - 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
      - conditions:
          - "{{ command == 'recall' }}"
          - "{{ second_light != none }}"
          - "{{ scene == 0 }}"
        sequence:
          - service: homeassistant.toggle
            target: !input "second_light"
          - choose:
              - conditions: "{{ current_light != none }}"
                sequence:
                  - service: input_text.set_value
                    target:
                      entity_id: !input "current_light"
                    data:
                      value: second_light
      - conditions:
          - "{{ command == 'recall' }}"
          - "{{ third_light != none }}"
          - "{{ scene == 5 }}"
        sequence:
          - service: homeassistant.toggle
            target: !input "third_light"
          - choose:
              - conditions: "{{ current_light != none }}"
                sequence:
                  - service: input_text.set_value
                    target:
                      entity_id: !input "current_light"
                    data:
                      value: third_light
      - conditions:
          - "{{ command == 'recall' }}"
          - "{{ forth_light != none }}"
          - "{{ scene == 4 }}"
        sequence:
          - service: homeassistant.toggle
            target: !input "forth_light"
          - choose:
              - conditions: "{{ current_light != none }}"
                sequence:
                  - service: input_text.set_value
                    target:
                      entity_id: !input "current_light"
                    data:
                      value: forth_light
      - conditions:
          - "{{ command == 'step_with_on_off' }}"
          - "{{ step_mode == 'StepMode.Up' }}"
        sequence:
          - choose:
              - conditions: "{{ current_light != none }}"
                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
      - conditions:
          - "{{ command == 'step_with_on_off' }}"
          - "{{ step_mode == 'StepMode.Down' }}"
        sequence:
          - choose:
              - conditions: "{{ current_light != none }}"
                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
3 Likes

I’ve been trying this blueprint with a tap dial and keep getting this error? I’ve even tried setting it up with only one light but still get the same error?
Executed: August 12, 2022 at 10:54:53 PM

Error: UndefinedError: ‘dict object’ has no attribute ‘event’
What am I doing wrong?

Are you trying to test it by using the ‘Run Actions’ in the UI? In that case the trigger object wouldn’t have an event which would result in this error. That is the only place an ‘event’ attribute is being referenced. If you trigger it using the buttons on the device, then it should have an event and work. This is the part the error would be coming from:

  - 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 }}"

That was exactly what I was doing. It works perfectly. Thanks for the help and for writing the blueprint!

Really like this. I can’t figure out exactly what to put in the optional field to have the dimmer dial control the current or last button/ light pushed. It always defaults to the first light. I’ve tried Current Light and current_light. If i’m setting the automation up through the ui what should i fill in?

Settings > Devices & Service > Helpers. Create a Text helper which will be used for saving the state. Go back to the blueprint and select that new helper.

2 Likes

Got it working. Thaks so much

Got the buttons working with MQTT, but the dial doesnt work. How to got the dial working witg Zigbee2MQTT?

Got it working with an own automation and used Repeat with count 1. But needs improvement in smoothness and speed :slight_smile:

Used the ‘rotate_fast’ trigger and that is pretty good :slight_smile:

I grabbed the blueprint, but when I attempt to create an automation the Device pull-down menu for the Philips Hue Tap Switch field is empty.

When I go to the Hue integration, I have a device named Hue tap dial switch 1.

Anyone have any tips for how I should proceed?

This blueprint is for use through ZHA. So it won’t work for any of the other ways the device can be added to Home Assistant.

2 Likes

Ah. That explains it. Thanks!

This is great! Have you figured out how to do long presses?

No. Last time I checked it was sending a regular click event for long press. But hopefully in the next HA release they will have better support for this device.

2 Likes

Thanks very much for this blueprint. The switches are very cool for me. Is it possible to turn on scenes with the buttons? I can choose a scene in “entity” but it didn’t work right now.

This blueprint leverages the homeassistant.toggle action, which I don’t think scenes respond to. But there has been a variation of this blueprint made by @vnkr which lets you do any action you want. I would suggest giving that a try. It is here

Thanks very much, that’s exactly what I’m searching for!

Thank you! What a beautiful blueprint this is. I landed here, because I have 4 Ikea Fyrtur motorized covers and wanted to use the hue tap dial to control all 4. So I took your blueprint and modified it, mainly by renaming light(s) to cover(s) and using a different service to set the cover position:

      - conditions: '{{ current_cover != none }}'
        sequence:
        - service: cover.set_cover_position
          target: '{{ covers[states(current_cover)] }}'
          data:
            position: '{{ step_size }}'

…which works sortoff, blinds going up and down, but in a more or less random fashion - it has a mind of its own on the up/down decision. The position for the cover is normally a value between 0-100 and makes it move to that position. Do you have any idea what I should investigate here?

Thanks anyway - I think I am almost there :wink:

Almost works, the only problem is fetching the actual position of the selected cover. If I fill in the precise entity in the template, it works (for that cover only) so I need an equivalent that retrieves it from the array of devices (variable lights aka covers in this case)

  - conditions:
    - '{{ command == ''step_with_on_off'' }}'
    - '{{ step_mode == ''StepMode.Down'' }}'
    sequence:
    - choose:
      - conditions: '{{ current_cover != none }}'
        sequence:
        - service: cover.set_cover_position
          target: '{{ covers[states(current_cover)] }}'
          data:
           position: "{{ (state_attr('cover.roll_cover', 'current_position') | int)  - (step_size | int ) }}"
#           position: "{{ (state_attr(covers[states(current_cover)], 'current_position') | int)  + (step_size | int ) }}"
      default:
      - service: cover.set_cover_position
        target: !input first_cover
        data:
          position: "{{ (state_attr('cover.roll_cover', 'current_position') | int)  - (step_size | int ) }}"

The ‘#’ line does not work…

Honestly not sure why that wouldn’t be working. Looks like it should work and this post seems to back that up where the same sort of thing is being done with a variable entity passed to state_attr.

Does the HUE tap switch, with the blueprint work with besides zigbee lights, also with zwave dimmer I already have in my system?