Philips Hue Remote Buttons - Using ZHA Integration

Hue Remote Mapper

What does this automation do…

This is mapper automation, that allows you to attach actions to the hue remote. All four buttons (On, Dim Up, Dim Down, Off), and all six states (single/double/triple/quadrupal/quintuple/long press). You can attach any event you want, not just lights. I’ve friends that use these remotes for launching Netflix/Disney+ on their tv, etc.

Why did I make this…

I realised that there is no easy way in hassio to map button presses on zigbee remotes to actions. It originally started, as you’d expect, mapping button pushes to lights coming on to specific light levels. As my knowledge of blueprints improved, I realised that I could just add actions, any make it just a single universal blueprint.

I’ve made a number of automations, but this is the first that I’ve published here. So please be kind. I’m aware it’s not the most efficient, so if you can recommend any optimisations, that would be fantastic, thank you.

Get started

Click the badge to import this Blueprint:
Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

Or import this Blueprint by using the forum topic URL:

blueprint:
  name: Hue Remote Mapper (ZHA Integration)
  description: |
    A remote control mapper for the Philips Hue Remotes (RWL020, RWL021, and RWL022).
  domain: automation
  source_url: https://gist.github.com/manix84/7c9cccac1f498b6b0fa134054f86ecab
  author: Manix84
  input:
    dimmer_device_id:
      name: Dimmer Remote Device
      description: "Your Hue dimmer remote (e.g. RWL020, RWL021, RWL022); check Hue integration and/or Hue app if you don't know the name"
      selector:
        device:
          filter:
            - integration: zha
              manufacturer: "Philips"
              model: RWL020
            - integration: zha
              manufacturer: "Philips"
              model: RWL021
            - integration: zha
              manufacturer: "Philips"
              model: RWL022

    button1_actions:
      name: On Button
      icon: mdi:numeric-1-box-outline
      collapsed: true
      input:
        btn_on_single_press_action:
          name: Single Press Actions
          description: <ha-icon icon="mdi:numeric-1-box"></ha-icon> Actions to run, when button is pressed quickly.
          default: []
          selector:
            action: {}
        btn_on_double_press_action:
          name: Double (2) Press Actions
          description: <ha-icon icon="mdi:numeric-2-box-multiple"></ha-icon> Actions to run, when button is pressed quickly twice.
          default: []
          selector:
            action: {}
        btn_on_triple_press_action:
          name: Triple (3) Press Actions
          description: <ha-icon icon="mdi:numeric-3-box-multiple"></ha-icon> Actions to run, when button is pressed quickly three times.
          default: []
          selector:
            action: {}
        btn_on_quadruple_press_action:
          name: Quadruple (4) Press Actions
          description: <ha-icon icon="mdi:numeric-4-box-multiple"></ha-icon> Actions to run, when button is pressed quickly four times.
          default: []
          selector:
            action: {}
        btn_on_quintuple_press_action:
          name: Quintuple (5) Press Actions
          description: <ha-icon icon="mdi:numeric-5-box-multiple"></ha-icon> Actions to run, when button is pressed quickly five times.
          default: []
          selector:
            action: {}
        btn_on_long_press_action:
          name: Long Press Actions
          description: <ha-icon icon="mdi:checkbox-multiple-blank"></ha-icon> Actions to run, when button is pressed and released after over a second.
          default: []
          selector:
            action: {}

    button2_actions:
      name: Dim Up Button
      icon: mdi:chevron-up-box-outline
      collapsed: true
      input:
        btn_up_single_press_action:
          name: Single Press Actions
          description: <ha-icon icon="mdi:numeric-1-box"></ha-icon> Actions to run, when button is pressed quickly.
          default: []
          selector:
            action: {}
        btn_up_double_press_action:
          name: Double (2) Press Actions
          description: <ha-icon icon="mdi:numeric-2-box-multiple"></ha-icon> Actions to run, when button is pressed quickly twice.
          default: []
          selector:
            action: {}
        btn_up_triple_press_action:
          name: Triple (3) Press Actions
          description: <ha-icon icon="mdi:numeric-3-box-multiple"></ha-icon> Actions to run, when button is pressed quickly three times.
          default: []
          selector:
            action: {}
        btn_up_quadruple_press_action:
          name: Quadruple (4) Press Actions
          description: <ha-icon icon="mdi:numeric-4-box-multiple"></ha-icon> Actions to run, when button is pressed quickly four times.
          default: []
          selector:
            action: {}
        btn_up_quintuple_press_action:
          name: Quintuple (5) Press Actions
          description: <ha-icon icon="mdi:numeric-5-box-multiple"></ha-icon> Actions to run, when button is pressed quickly five times.
          default: []
          selector:
            action: {}
        btn_up_long_press_action:
          name: Long Press Actions
          description: <ha-icon icon="mdi:checkbox-multiple-blank"></ha-icon> Actions to run, when button is pressed and released after over a second.
          default: []
          selector:
            action: {}

    button3_actions:
      name: Dim Down Button
      icon: mdi:chevron-down-box-outline
      collapsed: true
      input:
        btn_down_single_press_action:
          name: Single Press Actions
          description: <ha-icon icon="mdi:numeric-1-box"></ha-icon> Actions to run, when button is pressed quickly.
          default: []
          selector:
            action: {}
        btn_down_double_press_action:
          name: Double (2) Press Actions
          description: <ha-icon icon="mdi:numeric-2-box-multiple"></ha-icon> Actions to run, when button is pressed quickly twice.
          default: []
          selector:
            action: {}
        btn_down_triple_press_action:
          name: Triple (3) Press Actions
          description: <ha-icon icon="mdi:numeric-3-box-multiple"></ha-icon> Actions to run, when button is pressed quickly three times.
          default: []
          selector:
            action: {}
        btn_down_quadruple_press_action:
          name: Quadruple (4) Press Actions
          description: <ha-icon icon="mdi:numeric-4-box-multiple"></ha-icon> Actions to run, when button is pressed quickly four times.
          default: []
          selector:
            action: {}
        btn_down_quintuple_press_action:
          name: Quintuple (5) Press Actions
          description: <ha-icon icon="mdi:numeric-5-box-multiple"></ha-icon> Actions to run, when button is pressed quickly five times.
          default: []
          selector:
            action: {}
        btn_down_long_press_action:
          name: Long Press Actions
          description: <ha-icon icon="mdi:checkbox-multiple-blank"></ha-icon> Actions to run, when button is pressed and released after over a second.
          default: []
          selector:
            action: {}

    button4_actions:
      name: Off Button
      icon: mdi:numeric-0-box-outline
      collapsed: true
      input:
        btn_off_single_press_action:
          name: Single Press Actions
          description: <ha-icon icon="mdi:numeric-1-box"></ha-icon> Actions to run, when button is pressed quickly.
          default: []
          selector:
            action: {}
        btn_off_double_press_action:
          name: Double (2) Press Actions
          description: <ha-icon icon="mdi:numeric-2-box-multiple"></ha-icon> Actions to run, when button is pressed quickly twice.
          default: []
          selector:
            action: {}
        btn_off_triple_press_action:
          name: Triple (3) Press Actions
          description: <ha-icon icon="mdi:numeric-3-box-multiple"></ha-icon> Actions to run, when button is pressed quickly three times.
          default: []
          selector:
            action: {}
        btn_off_quadruple_press_action:
          name: Quadruple (4) Press Actions
          description: <ha-icon icon="mdi:numeric-4-box-multiple"></ha-icon> Actions to run, when button is pressed quickly four times.
          default: []
          selector:
            action: {}
        btn_off_quintuple_press_action:
          name: Quintuple (5) Press Actions
          description: <ha-icon icon="mdi:numeric-5-box-multiple"></ha-icon> Actions to run, when button is pressed quickly five times.
          default: []
          selector:
            action: {}
        btn_off_long_press_action:
          name: Long Press Actions
          description: <ha-icon icon="mdi:checkbox-multiple-blank"></ha-icon> Actions to run, when button is pressed and released after over a second.
          default: []
          selector:
            action: {}

description: ""
trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: on_press
    id: btn_on_single_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: on_double_press
    id: btn_on_double_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: on_triple_press
    id: btn_on_triple_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: on_quadruple_press
    id: btn_on_quadruple_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: on_quintuple_press
    id: btn_on_quintuple_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: on_long_release
    id: btn_on_long_press

  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: up_press
    id: btn_up_single_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: up_double_press
    id: btn_up_double_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: up_triple_press
    id: btn_up_triple_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: up_quadruple_press
    id: btn_up_quadruple_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: up_quintuple_press
    id: btn_up_quintuple_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: up_long_release
    id: btn_up_long_press

  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: down_press
    id: btn_down_single_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: down_double_press
    id: btn_down_double_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: down_triple_press
    id: btn_down_triple_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: down_quadruple_press
    id: btn_down_quadruple_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: down_quintuple_press
    id: btn_down_quintuple_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: down_long_release
    id: btn_down_long_press

  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: off_press
    id: btn_off_single_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: off_double_press
    id: btn_off_double_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: off_triple_press
    id: btn_off_triple_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: off_quadruple_press
    id: btn_off_quadruple_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: off_quintuple_press
    id: btn_off_quintuple_press
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input dimmer_device_id
      command: off_long_release
    id: btn_off_long_press

condition: []
action:
  - choose:
      - alias: On Button - Single Press
        conditions:
          - condition: trigger
            id: btn_on_single_press
        sequence: !input btn_on_single_press_action
      - alias: On Button - Double Press
        conditions:
          - condition: trigger
            id: btn_on_double_press
        sequence: !input btn_on_double_press_action
      - alias: On Button - Triple Press
        conditions:
          - condition: trigger
            id: btn_on_triple_press
        sequence: !input btn_on_triple_press_action
      - alias: On Button - Quadruple Press
        conditions:
          - condition: trigger
            id: btn_on_quadruple_press
        sequence: !input btn_on_quadruple_press_action
      - alias: On Button - Quintuple Press
        conditions:
          - condition: trigger
            id: btn_on_quintuple_press
        sequence: !input btn_on_quintuple_press_action
      - alias: On Button - Long Press
        conditions:
          - condition: trigger
            id: btn_on_long_press
        sequence: !input btn_on_long_press_action

      - alias: Dim Up Button - Single Press
        conditions:
          - condition: trigger
            id: btn_up_single_press
        sequence: !input btn_up_single_press_action
      - alias: Dim Up Button - Double Press
        conditions:
          - condition: trigger
            id: btn_up_double_press
        sequence: !input btn_up_double_press_action
      - alias: Dim Up Button - Triple Press
        conditions:
          - condition: trigger
            id: btn_up_triple_press
        sequence: !input btn_up_triple_press_action
      - alias: Dim Up Button - Quadruple Press
        conditions:
          - condition: trigger
            id: btn_up_quadruple_press
        sequence: !input btn_up_quadruple_press_action
      - alias: Dim Up Button - Quintuple Press
        conditions:
          - condition: trigger
            id: btn_up_quintuple_press
        sequence: !input btn_up_quintuple_press_action
      - alias: Dim Up Button - Long Press
        conditions:
          - condition: trigger
            id: btn_up_long_press
        sequence: !input btn_up_long_press_action

      - alias: Dim Down Button - Single Press
        conditions:
          - condition: trigger
            id: btn_down_single_press
        sequence: !input btn_down_single_press_action
      - alias: Dim Down Button - Double Press
        conditions:
          - condition: trigger
            id: btn_down_double_press
        sequence: !input btn_down_double_press_action
      - alias: Dim Down Button - Triple Press
        conditions:
          - condition: trigger
            id: btn_down_triple_press
        sequence: !input btn_down_triple_press_action
      - alias: Dim Down Button - Quadruple Press
        conditions:
          - condition: trigger
            id: btn_down_quadruple_press
        sequence: !input btn_down_quadruple_press_action
      - alias: Dim Down Button - Quintuple Press
        conditions:
          - condition: trigger
            id: btn_down_quintuple_press
        sequence: !input btn_down_quintuple_press_action
      - alias: Dim Down Button - Long Press
        conditions:
          - condition: trigger
            id: btn_down_long_press
        sequence: !input btn_down_long_press_action

      - alias: Off Button - Single Press
        conditions:
          - condition: trigger
            id: btn_off_single_press
        sequence: !input btn_off_single_press_action
      - alias: Off Button - Double Press
        conditions:
          - condition: trigger
            id: btn_off_double_press
        sequence: !input btn_off_double_press_action
      - alias: Off Button - Triple Press
        conditions:
          - condition: trigger
            id: btn_off_triple_press
        sequence: !input btn_off_triple_press_action
      - alias: Off Button - Quadruple Press
        conditions:
          - condition: trigger
            id: btn_off_quadruple_press
        sequence: !input btn_off_quadruple_press_action
      - alias: Off Button - Quintuple Press
        conditions:
          - condition: trigger
            id: btn_off_quintuple_press
        sequence: !input btn_off_quintuple_press_action
      - alias: Off Button - Long Press
        conditions:
          - condition: trigger
            id: btn_off_long_press
        sequence: !input btn_off_long_press_action
    default:
      - service: persistent_notification.create
        data:
          message: >-
            Hue dimmer ran default event from "choose" action on button press!
            Please check any automations which may not be handling this event: {{ trigger.id }}
          notification_id: hue-remote-lights
          title: >-
            Uncaught Dimmer Command ({{ trigger.id }})
mode: single
1 Like

I’d love some feedback. Is this a bad blueprint? Is it just tough to understand what it does? Should I give up making blueprints all-together? Any feedback would be helpful.

I mean for the HUE Remotes there a lots of blueprints around for remap the Buttons To-Do different actions.
In the past i used this one:

But i will give your blueprint a try in the next Day.