IKEA somrig shortcut (IKEA E2213) Z2M

IKEA Somrig shorcut button blueprint

Hello all,

I created a simple blueprint for the Ikea Somrig shortcut button. It is based on the Rodret blueprint by @damru. Unfortunately, I am unfamiliar with ZHA so this only works with zigbee2mqtt.

image

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

:blue_book: How it works.

It uses the 6 actions of the somrig button:

  1. Dots 1 single press
  2. Dots 2 single press
  3. Dots 1 hold
  4. Dots 2 hold
  5. Dots 1 double press
  6. Dots 2 double press

:page_with_curl: yaml

The code is here.

blueprint:
  name: IKEA Somrig Controls (Z2M)
  description: "## Control anything with IKEA Somrig Dimmer remote (v1.0)


    Only for use with Zigbee2MQTT ([MQTT](https://www.home-assistant.io/integrations/mqtt)
    + [Z2M addon](https://www.zigbee2mqtt.io/guide/installation/03_ha_addon.html)).

    Adapted from https://gist.github.com/damru/b2c1c780ffb0ddc084952eb89db9573a

    Available controls:

    - Press the **dots 1** or **dots 2** buttons

    - Double press the **dots 1** or **dots 2** buttons.

    - Press and hold the **dots 1**/**dots 2** buttons. Actions will be executed every **Helper - Hold delay**, but maximum **Helper - Max number of loops** times.
    "
  source_url: https://gist.github.com/amorfinvdev/ece1a0873759f908429a5c01c8426dce
  domain: automation
  input:
    remote_name:
      name: (Zigbee2MQTT) Remote Name
      description: The name of the controller (e.g. IKEA Somrig).
      default: ""
    base_topic:
      name: (Zigbee2MQTT) Base mqtt topic
      description: The topic configured in [Z2M addon](https://www.zigbee2mqtt.io/guide/usage/mqtt_topics_and_messages.html).
      default: zigbee2mqtt
    dots_1_press_action:
      name: Dots 1 - Single press action
      description: Choose action(s) to run when **dots 1** button is pressed.
      default: []
      selector:
        action: {}
    dots_2_press_action:
      name: Dots 2 - Single press action
      description: Choose action(s) to run when **dots 2** button is **pressed**.
      default: []
      selector:
        action: {}
    dots_1_hold_action:
      name: Dots 1 - Hold action
      description: Choose action(s) to run when **dots 1** button is **pressed and hold**.
      default: []
      selector:
        action: {}
    dots_2_hold_action:
      name: Dots 2 - Hold action
      description: Choose action(s) to run when **dots 2** button is **pressed and hold**.
      default: []
      selector:
        action: {}
    dots_1_double_press_action:
      name: Dots 1 - Double press action
      description:
        Choose action(s) to run when pressing the **dots 1** button twice.
      default: []
      selector:
        action: {}
    dots_2_double_press_action:
      name: Dots 2 - Double press action
      description:
        Choose action(s) to run when pressing the **dots 2** button twice.
      default: []
      selector:
        action: {}
    helper_hold_delay:
      name: Helper - Hold delay
      description: Delay between the execution of the **Hold** action(s).
      default: 250
      selector:
        number:
          unit_of_measurement: milliseconds
          min: 100.0
          max: 5000.0
          step: 10.0
          mode: slider
    helper_max_loops:
      name: Helper - Max number of loops
      description: Maximum number of loops when holding down a button.
      default: 20
      selector:
        number:
          min: 1.0
          max: 1000.0
          step: 1.0
          mode: slider
mode: single
max_exceeded: silent
trigger_variables:
  z2m_base_topic: !input base_topic
  z2m_controller: !input remote_name
trigger:
  - platform: mqtt
    topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}"
    payload: "1_short_release"
    id: press-dots-1-z2m
  - platform: mqtt
    topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}"
    payload: "2_short_release"
    id: press-dots-2-z2m
  - platform: mqtt
    topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}"
    payload: "1_double_press"
    id: double-press-dots-1-z2m
  - platform: mqtt
    topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}"
    payload: "2_double_press"
    id: double-press-dots-2-z2m
  - platform: mqtt
    topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}"
    payload: "1_long_press"
    id: hold-dots-1-z2m
  - platform: mqtt
    topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}"
    payload: "2_long_press"
    id: hold-dots-2-z2m
  - platform: mqtt
    topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}"
    payload: "1_long_release"
    id: release-dots-1-z2m
  - platform: mqtt
    topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}"
    payload: "2_long_release"
    id: release-dots-2-z2m
action:
  - variables:
      z2m_base_topic: !input base_topic
      z2m_controller: !input remote_name
  - choose:
      - conditions:
          - condition: trigger
            id:
              - press-dots-1-z2m
        sequence: !input dots_1_press_action
      - conditions:
          - condition: trigger
            id:
              - press-dots-2-z2m
        sequence: !input dots_2_press_action
      - conditions:
          - condition: trigger
            id:
              - double-press-dots-1-z2m
        sequence: !input dots_1_double_press_action
      - conditions:
          - condition: trigger
            id:
              - double-press-dots-2-z2m
        sequence: !input dots_2_double_press_action
      - conditions:
          - condition: trigger
            id:
              - hold-dots-1-z2m
        sequence:
          - repeat:
              count: !input helper_max_loops
              sequence:
                - parallel:
                    - sequence: !input dots_1_hold_action
                    - sequence:
                        - choose:
                            - conditions:
                                - condition: trigger
                                  id:
                                    - hold-dots-1-z2m
                              sequence:
                                - wait_for_trigger:
                                    - platform: mqtt
                                      topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}"
                                      payload: "1_long_release"
                                  timeout:
                                    milliseconds: !input helper_hold_delay
                                  continue_on_timeout: true
                                - if:
                                    - condition: template
                                      value_template: "{{ wait.trigger.idx is defined }}"
                                  then:
                                    - stop: button released
      - conditions:
          - condition: trigger
            id:
              - hold-dots-2-z2m
        sequence:
          - repeat:
              count: !input helper_max_loops
              sequence:
                - parallel:
                    - sequence: !input dots_2_hold_action
                    - sequence:
                        - choose:
                            - conditions:
                                - condition: trigger
                                  id:
                                    - hold-dots-2-z2m
                              sequence:
                                - wait_for_trigger:
                                    - platform: mqtt
                                      topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}"
                                      payload: "2_long_release"
                                  timeout:
                                    milliseconds: !input helper_hold_delay
                                  continue_on_timeout: true
                                - if:
                                    - condition: template
                                      value_template: "{{ wait.trigger.idx is defined }}"
                                  then:
                                    - stop: button released

Cheers.

Note: I havenā€™t tested the hold action yet.

4 Likes

Hi,

nice idea! But I get this error message when clicking the button to import the blueprint:

"No valid blueprint found in the gist. The blueprint file needs to end with ā€˜.yamlā€™ "

Any idea?

Woops @bjbe70 . I had saved it as txt file. It should be fixed now. Thanks

Thanks @amorfinv !

Just 1 question - why asking for the name of the device instead of its id or the entity id? The name is very likely to change, which would break the automation.

Thanks anyway, it works!
For people stumbling on this: at the time of writing (jan 2024), the SOMRIG remote is only recognized in Z2M, not in ZHA (yet).

Hi @h0rnsUp,

Thanks for trying it out. My initial goal was to use a blueprint selector for the device. However that returns the device id and not the name. If I understand correctly, Zigbee2MQTT is using the device name for the MQTT topic. I tried to use some templating to get the device name from the id. But I could not figure it out because of a ā€œlimited templateā€ when declaring variables in the blueprint.

I saw some other blueprints using the entity instead of the device but I found that a bit clunkier.

If you figure that out, I am happy to update the blueprint.

-Andres

This works for me, but the short presses take about 2-3 seconds to register. This is much longer compared to the TRADFRI remote, but if this canā€™t be fixed then thatā€™s okay

Hello @IceBotYT . I am unsure why that happens to you. Mine are registering pretty much instantaneously in Z2M. Could it be something with your ZigBee network?

I donā€™t knowā€¦ What should I be looking for? I changed my hue ZigBee channel so itā€™s off of thatā€¦ what else do I do?

Not sure. I would first check the Zigbee2Mqtt logs to see if itā€™s a ZigBee issue or a home assistant issue.

If the presses are slow in the Z2M logs then I would troubleshoot it as is stated in docs :

If only this device has issues in your network then perhaps something is up with the device.

I am also experiencing much longer response times then my other Ikea remotes. Have not been able to find a cause as of yet.

Interesting. Have you checked the Z2M logs?

I donā€™t have them yet, but I think the longer response is due to double press. Other Ikea buttons have only long presses or single presses. The device is waiting for the second press, thus the delay.

That does make sense, but it would be nice if we could configure that delay

I cannot confirm if this is delay is actually the problem. My somrig device registers the double click without any noticable delay. Can you share the logs from z2m when performing a single click and a double click?

Here is how my z2m logs looks for a single press:

Info 2024-02-19 12:37:16MQTT publish: topic 'zigbee2mqtt/bathroom_fanremote', payload '{"action":"1_initial_press","battery":88,"linkquality":104,"update":{"installed_version":16777248,"latest_version":16777248,"state":"idle"},"update_available":null,"voltage":1300}'
Info 2024-02-19 12:37:16MQTT publish: topic 'zigbee2mqtt/bathroom_fanremote', payload '{"action":"","battery":88,"linkquality":104,"update":{"installed_version":16777248,"latest_version":16777248,"state":"idle"},"update_available":null,"voltage":1300}'
Info 2024-02-19 12:37:16MQTT publish: topic 'zigbee2mqtt/bathroom_fanremote/action', payload '1_initial_press'
Info 2024-02-19 12:37:16MQTT publish: topic 'zigbee2mqtt/bathroom_fanremote', payload '{"action":"1_short_release","battery":88,"linkquality":108,"update":{"installed_version":16777248,"latest_version":16777248,"state":"idle"},"update_available":null,"voltage":1300}'
Info 2024-02-19 12:37:16MQTT publish: topic 'zigbee2mqtt/bathroom_fanremote', payload '{"action":"","battery":88,"linkquality":108,"update":{"installed_version":16777248,"latest_version":16777248,"state":"idle"},"update_available":null,"voltage":1300}'
Info 2024-02-19 12:37:16MQTT publish: topic 'zigbee2mqtt/bathroom_fanremote/action', payload '1_short_release'

And this is for a double press:

Info 2024-02-19 12:38:54MQTT publish: topic 'zigbee2mqtt/bathroom_fanremote', payload '{"action":"1_initial_press","battery":88,"linkquality":248,"update":{"installed_version":16777248,"latest_version":16777248,"state":"idle"},"update_available":null,"voltage":1300}'
Info 2024-02-19 12:38:54MQTT publish: topic 'zigbee2mqtt/bathroom_fanremote', payload '{"action":"","battery":88,"linkquality":248,"update":{"installed_version":16777248,"latest_version":16777248,"state":"idle"},"update_available":null,"voltage":1300}'
Info 2024-02-19 12:38:54MQTT publish: topic 'zigbee2mqtt/bathroom_fanremote/action', payload '1_initial_press'
Info 2024-02-19 12:38:54MQTT publish: topic 'zigbee2mqtt/bathroom_fanremote', payload '{"action":"1_double_press","battery":88,"linkquality":248,"update":{"installed_version":16777248,"latest_version":16777248,"state":"idle"},"update_available":null,"voltage":1300}'
Info 2024-02-19 12:38:54MQTT publish: topic 'zigbee2mqtt/bathroom_fanremote', payload '{"action":"","battery":88,"linkquality":248,"update":{"installed_version":16777248,"latest_version":16777248,"state":"idle"},"update_available":null,"voltage":1300}'
Info 2024-02-19 12:38:54MQTT publish: topic 'zigbee2mqtt/bathroom_fanremote/action', payload '1_double_press'

You can see that in both cases the message is received in the same second of the initial press.

However, this is very dependent on your zigbee network.

Sure, hereā€™s a revised version with improved grammar:

Hey, I just installed this blueprint but noticed that after mapping a button to a light and leaving it on toggle, the light turns on. Then, after about 5 seconds, it turns off again, and then after another 5 seconds, it turns back on and stays on.

Has anyone else experienced this issue?

Log below:

Info 2024-04-26 19:18:37MQTT publish: topic 'zigbee2mqtt/Kitchen Button', payload '{"action":"1_initial_press","battery":100,"linkquality":255,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2024-04-26 19:18:37MQTT publish: topic 'zigbee2mqtt/Kitchen Button', payload '{"action":"","battery":100,"linkquality":255,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2024-04-26 19:18:37MQTT publish: topic 'zigbee2mqtt/Kitchen Button/action', payload '1_initial_press'
Info 2024-04-26 19:18:38MQTT publish: topic 'zigbee2mqtt/Kitchen Button', payload '{"action":"1_short_release","battery":100,"linkquality":255,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2024-04-26 19:18:38MQTT publish: topic 'zigbee2mqtt/Kitchen Button', payload '{"action":"","battery":100,"linkquality":255,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2024-04-26 19:18:38MQTT publish: topic 'zigbee2mqtt/Kitchen Button/action', payload '1_short_release'
Info 2024-04-26 19:18:38MQTT publish: topic 'zigbee2mqtt/Office Light', payload '{"brightness":254,"color_mode":"color_temp","color_options":{"execute_if_off":false},"color_temp":250,"color_temp_startup":250,"linkquality":255,"power_on_behavior":"previous","state":"OFF","update":{"installed_version":69635,"latest_version":69635,"state":"idle"},"update_available":null}'
Info 2024-04-26 19:18:44MQTT publish: topic 'zigbee2mqtt/Kitchen Button', payload '{"action":"1_initial_press","battery":100,"linkquality":255,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2024-04-26 19:18:44MQTT publish: topic 'zigbee2mqtt/Kitchen Button', payload '{"action":"","battery":100,"linkquality":255,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2024-04-26 19:18:44MQTT publish: topic 'zigbee2mqtt/Kitchen Button/action', payload '1_initial_press'
Info 2024-04-26 19:18:47MQTT publish: topic 'zigbee2mqtt/Bedroom Sensor', payload '{"battery":100,"identify":null,"illuminance":15314,"illuminance_lux":34,"linkquality":255,"occupancy":false,"update":{"installed_version":16777303,"latest_version":16777303,"state":"idle"},"update_available":null}'
Info 2024-04-26 19:18:47MQTT publish: topic 'zigbee2mqtt/Kitchen Button', payload '{"action":"1_initial_press","battery":100,"linkquality":253,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2024-04-26 19:18:47MQTT publish: topic 'zigbee2mqtt/Kitchen Button', payload '{"action":"","battery":100,"linkquality":253,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2024-04-26 19:18:47MQTT publish: topic 'zigbee2mqtt/Kitchen Button/action', payload '1_initial_press'
Info 2024-04-26 19:18:47MQTT publish: topic 'zigbee2mqtt/Kitchen Button', payload '{"action":"1_short_release","battery":100,"linkquality":229,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2024-04-26 19:18:47MQTT publish: topic 'zigbee2mqtt/Kitchen Button', payload '{"action":"","battery":100,"linkquality":229,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2024-04-26 19:18:47MQTT publish: topic 'zigbee2mqtt/Kitchen Button/action', payload '1_short_release'
Info 2024-04-26 19:18:47MQTT publish: topic 'zigbee2mqtt/Office Light', payload '{"brightness":254,"color_mode":"color_temp","color_options":{"execute_if_off":false},"color_temp":250,"color_temp_startup":250,"linkquality":255,"power_on_behavior":"previous","state":"ON","update":{"installed_version":69635,"latest_version":69635,"state":"idle"},"update_available":null}'
Info 2024-04-26 19:18:51MQTT publish: topic 'zigbee2mqtt/Kitchen Button', payload '{"action":"1_short_release","battery":100,"linkquality":255,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2024-04-26 19:18:51MQTT publish: topic 'zigbee2mqtt/Kitchen Button', payload '{"action":"","battery":100,"linkquality":255,"update":{"installed_version":-1,"latest_version":-1,"state":null},"update_available":null}'
Info 2024-04-26 19:18:51MQTT publish: topic 'zigbee2mqtt/Kitchen Button/action', payload '1_short_release'
Info 2024-04-26 19:18:51MQTT publish: topic 'zigbee2mqtt/Office Light', payload '{"brightness":254,"color_mode":"color_temp","color_options":{"execute_if_off":false},"color_temp":250,"color_temp_startup":250,"linkquality":255,"power_on_behavior":"previous","state":"OFF","update":{"installed_version":69635,"latest_version":69635,"state":"idle"},"update_available":null}'

Hey @CurtisB123 . The issue doesnā€™t seem related to Home Assistant. This appears more like an issue with the device or Z2M, due to sending duplicate messages. if you delete the device from home assistant is it still sending many commands after clicking it just once? Might want to try repairing it.