ZHA - IKEA Somrig remote for lights with double press

A blueprint for the IKEA Somrig remote, model E2213, to be used with ZHA as a light control (with dimming, etc) and a double press configuration. This expands usual basic Somrig blueprint with more Styrbar like functionality.

Enjoy : )

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

blueprint:
  name: ZHA - IKEA Somrig remote for lights
  description: Dimmable light control
  domain: automation
  input:
    remote:
      name: Remote
      description: IKEA Somrig remote to use
      selector:
        device:
          integration: zha
          manufacturer: IKEA of Sweden
          model: SOMRIG shortcut button
          multiple: false
    light:
      name: Light(s)
      description: The light(s) to control
      selector:
        target:
          entity:
            domain: light
    force_brightness:
      name: Force turn on brightness
      description:
        Force the brightness to the set level below, when the "on" button
        on the remote is pushed and lights turn on.
      default: false
      selector:
        boolean: null
    brightness:
      name: Brightness
      description: Brightness of the light(s) when turning on
      default: 50
      selector:
        number:
          min: 0.0
          max: 100.0
          mode: slider
          step: 1.0
          unit_of_measurement: "%"
    hold_time:
      name: Hold Time
      description: Time between the execution of the brighter/darker actions when holding the brighter/darker button.
      default: 0.5
      selector:
        number:
          min: 0.1
          max: 2
          step: 0.1
          unit_of_measurement: seconds
    single_dot_double_press:
      name: Single dot (Double press)
      description: Action to run on single dot double press
      default: []
      selector:
        action: {}
    double_dot_double_press:
      name: Double dot (Double press)
      description: Action to run on double dot double press
      default: []
      selector:
        action: {}
mode: restart
max_exceeded: silent
variables:
  force_brightness: !input "force_brightness"
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 }}"
      args: "{{ trigger.event.data.args }}"
  - choose:
      - conditions:
          - "{{ command == 'short_release' }}"
          - "{{ endpoint_id == 1 }}"
        sequence:
          - choose:
              - conditions: "{{ force_brightness }}"
                sequence:
                  - service: light.turn_on
                    target: !input "light"
                    data:
                      transition: 1
                      brightness_pct: !input "brightness"
            default:
              - service: light.turn_on
                target: !input "light"
                data:
                  transition: 1
      - conditions:
          - "{{ command == 'short_release' }}"
          - "{{ endpoint_id == 2 }}"
        sequence:
          - service: light.turn_off
            target: !input "light"
            data:
              transition: 1
      - conditions:
          - "{{ command == 'long_press' }}"
          - "{{ endpoint_id == 1 }}"
        sequence:
          - repeat:
              count: 10
              sequence:
                - service: light.turn_on
                  target: !input "light"
                  data:
                    brightness_step_pct: 10
                    transition: !input "hold_time"
                - delay: !input "hold_time"
      - conditions:
          - "{{ command == 'long_press' }}"
          - "{{ endpoint_id == 2 }}"
        sequence:
          - repeat:
              count: 10
              sequence:
                - service: light.turn_on
                  target: !input "light"
                  data:
                    brightness_step_pct: -10
                    transition: !input "hold_time"
                - delay: !input "hold_time"
      - conditions:
         - '{{ command == ''multi_press_complete'' }}'
         - '{{ endpoint_id == 1 }}'
        sequence: !input single_dot_double_press
      - conditions:
         - '{{ command == ''multi_press_complete'' }}'
         - '{{ endpoint_id == 2 }}'
        sequence: !input double_dot_double_press
2 Likes

I needed to add a parameter for the initial color temperature. I created an automation based on your blueprint. Would you find the time to add options for Force turn on temperature and Color of the light(s) when turning on? Here is the my fully working automation code:

alias: Kitchen table
description: ""
triggers:
  - event_type: zha_event
    event_data:
      device_id: 80630a2a1f3a8aceb61caadc3c8042ca
    trigger: event
actions:
  - variables:
      command: "{{ trigger.event.data.command }}"
      endpoint_id: "{{ trigger.event.data.endpoint_id }}"
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ command == 'short_release' and endpoint_id == 1 }}"
        sequence:
          - target:
              entity_id: light.ikea_tradfri_bulb_gu10_ws_345lm_light
            data:
              transition: 0
              brightness_pct: "{{ initial_brightness }}"
              kelvin: "{{ initial_color_temp }}"
            action: light.turn_on
      - conditions:
          - condition: template
            value_template: "{{ command == 'short_release' and endpoint_id == 2 }}"
        sequence:
          - target:
              entity_id: light.ikea_tradfri_bulb_gu10_ws_345lm_light
            data: {}
            action: light.turn_off
      - conditions:
          - condition: template
            value_template: "{{ command == 'long_press' and endpoint_id == 1 }}"
        sequence:
          - repeat:
              count: 10
              sequence:
                - target:
                    entity_id: light.ikea_tradfri_bulb_gu10_ws_345lm_light
                  data:
                    brightness_step_pct: 10
                    transition: 0.5
                  action: light.turn_on
                - delay: 0.5
      - conditions:
          - condition: template
            value_template: "{{ command == 'long_press' and endpoint_id == 2 }}"
        sequence:
          - repeat:
              count: 10
              sequence:
                - target:
                    entity_id: light.ikea_tradfri_bulb_gu10_ws_345lm_light
                  data:
                    brightness_step_pct: -10
                    transition: 0.5
                  action: light.turn_on
                - delay: 0.5
      - conditions:
          - condition: template
            value_template: "{{ command == 'multi_press_complete' and endpoint_id == 1 }}"
        sequence:
          - target:
              entity_id: light.ikea_tradfri_bulb_gu10_ws_345lm_light
            data:
              kelvin: 2700
            action: light.turn_on
      - conditions:
          - condition: template
            value_template: "{{ command == 'multi_press_complete' and endpoint_id == 2 }}"
        sequence:
          - target:
              entity_id: light.ikea_tradfri_bulb_gu10_ws_345lm_light
            data:
              kelvin: 2350
            action: light.turn_on
mode: restart
max_exceeded: silent
variables:
  initial_brightness: 90
  initial_color_temp: 4000

The biggest challenge was to ensure that pressing the single dot always turns on the light with the defined initial parameters. I finally succeeded.
Iā€™m asking about the modification of the blueprint because the initial temperature might be useful for someone else as well. My attempts to create a blueprint always ended in syntax errors. In the end, I gave up.
Cheers :raising_hand_man: