Philips Hue Tap Dial Switch - ZHA

Great help. Thank you so much.

So did anyone get the text helper working in ZHA? Mine does not change when pressing a button. If i manually change the value i can use the dial to dim the “selected” light.

Nope. No help to find here.

I tried everything that came to my mind to try and access the brightness level of the current_light but to no avail:

        sequence:
          - choose:
              - conditions: 
                    - "{{ current_light != none }}"
                    - "**{{lights[states.light.current_light.attributes.brightness] | int + (-step_size * dim_scale) >= min_brightness}}**"
                sequence:
                  - service: light.turn_on
                    target: "{{ lights[states(current_light)] }}"
                    data:
                      brightness_step_pct: "{{ -step_size * dim_scale }}"
                      transition: 1

Hardcoding it works, but makes no sense:

"{{state_attr('light.tischlicht_zha_group_0x0002','brightness') | int + (-step_size * dim_scale) >= min_brightness}}"

Do you happen to know what syntax we need to use? This would enable the possiblity to set a min brightness value in the blueprint.

Yes, it works well.

Settings → Devices/Services → Helpers (upper right hand corner) → Create Helper → Text → name it whatever you’d like, and then import your newly created text helper into the automation, which is at the bottom of the blueprint labeled: (OPTIONAL) Current Light.

I named mine “Master Bedroom Last Selected Light Helper.”

I have the same issue. I get the log message:

2024-02-14 20:45:11.139 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'dict object' has no attribute 'entity_id' when rendering '{{ states(first_light.entity_id) == 'off' }}'
2024-02-14 20:45:11.139 WARNING (MainThread) [homeassistant.helpers.script] Error in 'choose[0]' evaluation: In 'template' condition: UndefinedError: 'dict object' has no attribute 'entity_id'

Thanks for this great blueprint. My tap dial is connected to 2 plugs and 1 light bulb, and the fourth button toggles all 3 devices.

Since the only dimmable device is the bulb, how can I set the dial to only work with the dimmable device (rather than the ‘current’ device)? I’m completely new to Home Assistant, so would greatly appreciate any guidance. Thank you!

@victorhooi, @_Xander, @timothi, @helge137, @AnderssonPeter: What solution have you settled on for using the Tap Dial with Z2M? Have you all moved to HACS Switch Manager or does someone have a blueprint that’s currently working fine? I’m trying to figure out if I shall buy the Tap Dial or some other remote for controlling a Hue light (brightness, on/off, color, scenes) in a kids room (without having a Hue Bridge). Thanks!

I’m using this excellent blueprint on which this ZHA one is based with instant results.

Full disclosure - I hacked the blueprint a bit to support double click events instead of release since I had no use for release. It’s working solidly for whatever I’ve thrown at it so far, with one minor exception. Sending multiple rotate events in a row seems to be swamping out zigbee messages, leading to a little latency.

Other than that, both the tap dial device as well as the blueprint have been rock solid.

1 Like

Did anyone manage to successfully modify the blueprint so that the lowest brightness is 1% (rather than off or 0%)? That would be awesome.

I’m always accidentally turning the light off whenever I try to reduce the brightness level with the dial.

1 Like

If the tap dial supports it in ZHA, it should only be a matter of replacing command == 'step_with_on_off' with command == 'step' in the blueprint.

Both are valid zigbee commands, but it would depend on the device cluster and whether it was implemented with the quirks.

1 Like

Sorry for the late reply, I’m using the following:

So far it works great, it can control 4 different lightgroups and also dim them separately!!

Thank you for your template, I mixed your and @timothi’s and created one that uses all 4 buttons and mqtt-action sensor (not listening to mqtt topic)

For anyone that stubles upon this: Create a new folder/file in your blueprints-folder and add this, reload and its ready to go :slight_smile:

blueprint:
  name: Zigbee2MQTT - Hue Tap Dail 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.
    example value zigbee2mqtt/0x001788010d7d3cac/action
    source https://community.home-assistant.io/t/philips-hue-tap-dial-switch-zha/446636/114

    '
  domain: automation
  input:
    button_sensor:
      name: Philips Hue Tap dial switch sensor entity
      description: Sensor for Philips Hue Tap dial switch to use (Use sensor with
        entity_id ends with _action)
      selector:
        entity:
          domain:
          - sensor
          multiple: false
    remote_button_1_single_press:
      name: Button 1 Single Press
      description: The light(s) to control with first button
      selector:
        target:
          entity:
          - domain:
            - light
    remote_button_2_single_press:
      name: Button 2 Single Press
      description: The light(s) to control with second button
      selector:
        target:
          entity:
          - domain:
            - light
    remote_button_3_single_press:
      name: Button 3 Single Press
      description: The light(s) to control with third button
      selector:
        target:
          entity:
          - domain:
            - light
    remote_button_4_single_press:
      name: Button 4 Single Press
      description: The light(s) to control with fourth button
      selector:
        target:
          entity:
          - domain:
            - light
    current_button:
      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
          multiple: false
    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: 3.0
      selector:
        number:
          min: 0.0
          max: 5.0
          step: 0.01
          mode: slider
    dim_time:
      name: Diming time
      description: How long it takes to dim one step
      default: 0.5
      selector:
        number:
          min: 0.1
          max: 1.0
          step: 0.01
          mode: slider
  source_url: https://github.com/AnderssonPeter/HomeAssistantBlueprints/blob/65f08a396a2d6e259b6b5f3a40e9b51a48ca0b8c/HueTapDailSwitch.yaml
mode: restart
max_exceeded: silent
variables:
  remote_button_1_single_press: !input remote_button_1_single_press
  remote_button_2_single_press: !input remote_button_2_single_press
  remote_button_3_single_press: !input remote_button_3_single_press
  remote_button_4_single_press: !input remote_button_4_single_press
  current_button: !input current_button
  dim_scale: !input dim_scale
  lights:
    remote_button_1_single_press: !input remote_button_1_single_press
    remote_button_2_single_press: !input remote_button_2_single_press
    remote_button_3_single_press: !input remote_button_3_single_press
    remote_button_4_single_press: !input remote_button_4_single_press
trigger:
- platform: state
  entity_id: !input button_sensor
  to: button_1_press
- platform: state
  entity_id: !input button_sensor
  to: button_2_press
- platform: state
  entity_id: !input button_sensor
  to: button_3_press
- platform: state
  entity_id: !input button_sensor
  to: button_4_press
- platform: state
  entity_id: !input button_sensor
  to: dial_rotate_left_step
- platform: state
  entity_id: !input button_sensor
  to: dial_rotate_left_slow
- platform: state
  entity_id: !input button_sensor
  to: dial_rotate_left_fast
- platform: state
  entity_id: !input button_sensor
  to: dial_rotate_right_step
- platform: state
  entity_id: !input button_sensor
  to: dial_rotate_right_slow
- platform: state
  entity_id: !input button_sensor
  to: dial_rotate_right_fast
action:
- variables:
    action: '{{ trigger.to_state.state }}'
- choose:
  - conditions: '{{ action == ''button_1_press'' }}'
    sequence:
    - service: light.toggle
      target: !input remote_button_1_single_press

    - choose:
      - conditions: '{{ current_button != none }}'
        sequence:
        - service: input_text.set_value
          target:
            entity_id: !input current_button
          data:
            value: remote_button_1_single_press
  - conditions: '{{ action == ''button_2_press'' }}'
    sequence:
    - service: light.toggle
      target: !input remote_button_2_single_press
    - choose:
      - conditions: '{{ current_button != none }}'
        sequence:
        - service: input_text.set_value
          target:
            entity_id: !input current_button
          data:
            value: remote_button_2_single_press
  - conditions: '{{ action == ''button_3_press'' }}'
    sequence:
    - service: light.toggle
      target: !input remote_button_3_single_press
    - choose:
      - conditions: '{{ current_button != none }}'
        sequence:
        - service: input_text.set_value
          target:
            entity_id: !input current_button
          data:
            value: remote_button_3_single_press
  - conditions: '{{ action == ''button_4_press'' }}'
    sequence:
    - service: light.toggle
      target: !input remote_button_4_single_press
    - choose:
      - conditions: '{{ current_button != none }}'
        sequence:
        - service: input_text.set_value
          target:
            entity_id: !input current_button
          data:
            value: remote_button_4_single_press
  - conditions:
    - '{{ action == ''dial_rotate_left_step'' }}'
    sequence:
    - choose:
      - conditions: '{{ current_button != none }}'
        sequence:
        - service: light.turn_on
          target: '{{ lights[states(current_button)] }}'
          data:
            brightness_step_pct: '{{ -dim_scale }}'
            transition: !input dim_time
      default:
      - service: light.turn_on
        target: !input remote_button_1_single_press
        data:
          brightness_step_pct: '{{ -dim_scale }}'
          transition: !input dim_time
  - conditions:
    - '{{ action == ''dial_rotate_right_step'' }}'
    sequence:
    - choose:
      - conditions: '{{ current_button != none }}'
        sequence:
        - service: light.turn_on
          target: '{{ lights[states(current_button)] }}'
          data:
            brightness_step_pct: '{{ dim_scale }}'
            transition: !input dim_time
      default:
      - service: light.turn_on
        target: !input remote_button_1_single_press
        data:
          brightness_step_pct: '{{ dim_scale }}'
          transition: !input dim_time
  - conditions:
    - '{{ action == ''dial_rotate_left_slow'' }}'
    sequence:
    - choose:
      - conditions: '{{ current_button != none }}'
        sequence:
        - service: light.turn_on
          target: '{{ lights[states(current_button)] }}'
          data:
            brightness_step_pct: '{{ -dim_scale * 2 }}'
            transition: !input dim_time
      default:
      - service: light.turn_on
        target: !input remote_button_1_single_press
        data:
          brightness_step_pct: '{{ -dim_scale * 2 }}'
          transition: !input dim_time
  - conditions:
    - '{{ action == ''dial_rotate_right_slow'' }}'
    sequence:
    - choose:
      - conditions: '{{ current_button != none }}'
        sequence:
        - service: light.turn_on
          target: '{{ lights[states(current_button)] }}'
          data:
            brightness_step_pct: '{{ dim_scale * 2 }}'
            transition: !input dim_time
      default:
      - service: light.turn_on
        target: !input remote_button_1_single_press
        data:
          brightness_step_pct: '{{ dim_scale * 2 }}'
          transition: !input dim_time
  - conditions:
    - '{{ action == ''dial_rotate_left_fast'' }}'
    sequence:
    - choose:
      - conditions: '{{ current_button != none }}'
        sequence:
        - service: light.turn_on
          target: '{{ lights[states(current_button)] }}'
          data:
            brightness_step_pct: '{{ -dim_scale * 5 }}'
            transition: !input dim_time
      default:
      - service: light.turn_on
        target: !input remote_button_1_single_press
        data:
          brightness_step_pct: '{{ -dim_scale * 5 }}'
          transition: !input dim_time
  - conditions:
    - '{{ action == ''dial_rotate_right_fast'' }}'
    sequence:
    - choose:
      - conditions: '{{ current_button != none }}'
        sequence:
        - service: light.turn_on
          target: '{{ lights[states(current_button)] }}'
          data:
            brightness_step_pct: '{{ dim_scale * 5 }}'
            transition: !input dim_time
      default:
      - service: light.turn_on
        target: !input remote_button_1_single_press
        data:
          brightness_step_pct: '{{ dim_scale * 5 }}'
          transition: !input dim_time

1 Like

Thank you for your work.
Could you please give me a hint how to set up the Text Helper correctly?

  • If not set up a Text Helper, the dial only works for the lamp on the 1st button (generally all 4 lamps are dimmable).
  • If set up, nothing happens when turning the dial.

What I did:
1st I set up a Text Helper (as there wasn’t any information here, I took a template from another website):

Then I just choosed it in your blueprint by the dropdown menu:

So what to do to set it up correctly please?

The regex that you setup would be preventing it from storing the value it needs to store. Remove that and it should work fine.

Thank you for trying to help!
But no joy, I’m sorry. Emptied the “Regex pattern” field, saved, started HA new, but no change.
What I wonder about: How does the helper know the last input from the Hue Tap? Where is the input? Maybe I missed an important requirement?

Edit:
Found a “traces” button and got this:

But where does it miss the id?

Any idea somebody? Any help appreciated

Is there any way to replicate the original behavior of the dial?
Let’s say I assign a scene to a button that turn on 2 out of 3 lights, the dial only affects the lights that are already on and have no impact on the lights that are off.

I’ve never put anything in here but it only ever adjusts the brightness of the light on button 1, even if it’s off it’ll dial up the brightness and turn it on. Any hints on how to set this up please? Pretend I don’t know yaml or regex!

Not exactly original. But I currently combined this script with the other script for the hue dial tab.

It’s still work in progress but as workaround you could try to set the lights (for dimming) and then define a custom action that start the scene.

For some reason the dimming is not working in HA for scenes although scenes have all the lights enteties as attribut. One could surely do it in the blueprint but I could not find a quick solution yet and that.