Skip to content

Instantly share code, notes, and snippets.

@amorfinvdev
Last active April 30, 2024 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save amorfinvdev/ece1a0873759f908429a5c01c8426dce to your computer and use it in GitHub Desktop.
Save amorfinvdev/ece1a0873759f908429a5c01c8426dce to your computer and use it in GitHub Desktop.
Ikea Somrig Remote Blueprint (Z2M)
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
@GianlucaUlivi
Copy link

Hi,
Thanks a lot for this amazon template, it works really well!

Do you thing there is any way to "listen" for inputs from two different Somrig that I would like to have them do the same actions?
Of course it would be possible to simply duplicate the resulting automation and attach the second one to a second device but I think it will be very nice if possible to support multiple Somrig.

Thanks

@amorfinvdev
Copy link
Author

Hi, glad you like it.

I think the simplest way to do this would be to put both somrig remotes in one zigbee group and use that for the remote name. Unsure if that would work though but give it a try.

Otherwise you will need to update the blueprint to take multiple input remotes. This should be doable but not something I can work on at the moment. Best of luck!

-Andres

@GianlucaUlivi
Copy link

I will with the group idea as soon as I get a second remote and update the post here.
Unfortunately I'm not and expert on home assistant and especially blueprint and I don't know where to start from but I will give it a try anyway.

Regards!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment