Counting/Debouncing Philips Hue Dimmer

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

This is a blueprint to support multi-clicks with the Philips Hue Dimmer again, after zigbee2mqtt update this is not support anymore (at least without legacy options)

It subscribes to the 4 different release events and starts a debouncing counter. If another event is fired within the defined threshold the automation restarts and increments a counter. Once the timer expires, another event is fired with payload of the button name and the counter.

The output looks like:

event_type: hue_dimmer_debounced
data:
  count: 1
  trigger: off_press_release

So you can create any type of automation with that event as a trigger.

You just need to specify the dimmer device and your preffered debounce threshold.
I could not find a way to do it without a helper entity, so you need to create/specify a counter as helper.
Maybe you can suggest how to update to get rid of the helper.

blueprint:
  name: Hue Dimmer Counter
  description: Debounces the Hue Dimmer events to enable click counters and fires an event with that counter as payload once the timeout is reached
  domain: automation
  input:
    hue_dimmer_device_id:
      name: Hue Dimmer
      description: This is the Hue Dimmer device
      selector:
        device:
          filter:
            manufacturer: Philips
            model: Hue dimmer switch
    debounce_time:
      name: Debounce time
      description: Maximum time between two triggers before final event is fired
      default: 500
      selector:
        number:
          min: 0
          max: 10000
          unit_of_measurement: "ms"
    helper_counter:
      name: "[Helper] Internal click counter"
      description: used in the automation to count clicks between the triggers
      selector:
        entity:
          filter:
            domain: counter
triggers:
  - domain: mqtt
    device_id: !input hue_dimmer_device_id
    type: action
    subtype: on_press_release
    trigger: device
    id: "1"
    enabled: true
  - domain: mqtt
    device_id: !input hue_dimmer_device_id
    type: action
    subtype: up_press_release
    trigger: device
    id: "1"
  - domain: mqtt
    device_id: !input hue_dimmer_device_id
    type: action
    subtype: down_press_release
    trigger: device
    id: "1"
  - domain: mqtt
    device_id: !input hue_dimmer_device_id
    type: action
    subtype: off_press_release
    trigger: device
    id: "1"
  - trigger: event
    event_type: hue_dimmer_counter_event_internal
    event_data: {}
    id: event
conditions: []
actions:
  - choose:
      - conditions:
          - condition: not
            conditions:
              - condition: trigger
                id:
                  - event
        sequence:
          - action: counter.increment
            metadata: {}
            data: {}
            target:
              entity_id: counter.huedimmerclickcounter
          - delay:
              hours: 0
              minutes: 0
              seconds: 0
              milliseconds: !input debounce_time
          - event: hue_dimmer_counter_event_internal
            event_data:
              payload: "{{trigger.payload}}"
      - conditions:
          - condition: trigger
            id:
              - event
        sequence:
          - data:
              message: Test {{ trigger.event.data.payload }}
            action: notify.mobile_app_a063
            enabled: false
          - event: hue_dimmer_debounced
            event_data:
              count: "{{ states('counter.huedimmerclickcounter') | int }}"
              trigger: "{{ trigger.event.data.payload }}"
          - action: counter.reset
            metadata: {}
            data: {}
            target:
              entity_id: counter.huedimmerclickcounter
mode: restart
1 Like