IKEA Somrig shortcut 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.
How it works.
It uses the 6 actions of the somrig button:
- Dots 1 single press
- Dots 2 single press
- Dots 1 hold
- Dots 2 hold
- Dots 1 double press
- Dots 2 double press
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.