ZHA - IKEA Tradfri on/off remote dual function

Inspired by @poolcactus I tweaked his blueprint for the IKEA Tradfri On/Off switch. Because I don’t use the dimmer function I use the move and move_with_on_off events to control a switch.

Blueprint Code

Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)

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

blueprint:
  name: ZHA - IKEA Tradfri on/off remote dual function
  description: |
    "Control your light(s) with IKEA Tradfri on/off remote

    Select the Tradfri remote and your lights / switches.
    You can turn the lights On / Off, or hold the buttons to turn on/off a switch"
  domain: automation
  input:
    remote:
      name: Remote
      description: The remote that will control the lights
      selector:
        device:
          integration: zha
          manufacturer: "IKEA of Sweden"
          model: "TRADFRI on/off switch"
    light:
      name: Light
      description: The lights that will be controlled
      selector:
        target:
          entity:
            domain: light
    switch:
      name: Switch
      description: The switches that will be controlled by holding the on/off switch
      selector:
        target:
          entity:
            domain: switch
mode: restart
trigger:
  - platform: event
    event_type: zha_event
    event_data:
      device_id: !input "remote"
action:
  - variables:
      command: "{{ trigger.event.data.command }}"
      cluster_id: "{{ trigger.event.data.cluster_id }}"
      endpoint_id: "{{ trigger.event.data.endpoint_id }}"
  - choose:
      - conditions:
          - "{{ command == 'on' }}"
          - "{{ cluster_id == 6 }}"
          - "{{ endpoint_id == 1 }}"
        sequence:
          - service: light.turn_on
            target: !input "light"
            data:
              transition: 1
      - conditions:
          - "{{ command == 'off' }}"
          - "{{ cluster_id == 6 }}"
          - "{{ endpoint_id == 1 }}"
        sequence:
          - service: light.turn_off
            target: !input "light"
            data:
              transition: 1
      - conditions:
          - "{{ command == 'move_with_on_off' }}"
          - "{{ cluster_id == 8 }}"
          - "{{ endpoint_id == 1 }}"
        sequence:
          - service: switch.turn_on
            target: !input "switch"
      - conditions:
          - "{{ command == 'move' }}"
          - "{{ cluster_id == 8 }}"
          - "{{ endpoint_id == 1 }}"
        sequence:
          - service: switch.turn_off
            target: !input "switch"