Skip to content

Instantly share code, notes, and snippets.

@notjosh
Forked from amorfinvdev/somrig.yaml
Last active January 24, 2024 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save notjosh/28929f26e802d595057ee61bc55ef2db to your computer and use it in GitHub Desktop.
Save notjosh/28929f26e802d595057ee61bc55ef2db to your computer and use it in GitHub Desktop.
Ikea Somrig Remote Blueprint (Z2M) [w/ initial press]
blueprint:
name: IKEA Somrig Controls (Z2M) [w/ initial press]
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:
- Push (before releasing) the **dots 1** or **dots 2** buttons (workaround to ignore latency when device waits for double press)
- Single press (after releasing) 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/notjosh/28929f26e802d595057ee61bc55ef2db
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_initial_press_action:
name: Dots 1 - Initial press action
description: Choose action(s) to run when **dots 1** button is **pressed**.
default: []
selector:
action: {}
dots_2_initial_press_action:
name: Dots 2 - Initial press action
description: Choose action(s) to run when **dots 2** button is **pressed**.
default: []
selector:
action: {}
dots_1_single_press_action:
name: Dots 1 - Single press action
description: Choose action(s) to run when **dots 1** button is **pressed and released** once.
default: []
selector:
action: {}
dots_2_single_press_action:
name: Dots 2 - Single press action
description: Choose action(s) to run when **dots 2** button is **pressed and released** once.
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_initial_press"
id: initial-press-dots-1-z2m
- platform: mqtt
topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}"
payload: "2_initial_press"
id: initial-press-dots-2-z2m
- platform: mqtt
topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}"
payload: "1_short_release"
id: single-press-dots-1-z2m
- platform: mqtt
topic: "{{ z2m_base_topic ~ '/' ~ z2m_controller ~ '/action' }}"
payload: "2_short_release"
id: single-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:
- initial-press-dots-1-z2m
sequence: !input dots_1_initial_press_action
- conditions:
- condition: trigger
id:
- initial-press-dots-2-z2m
sequence: !input dots_2_initial_press_action
- conditions:
- condition: trigger
id:
- single-press-dots-1-z2m
sequence: !input dots_1_single_press_action
- conditions:
- condition: trigger
id:
- single-press-dots-2-z2m
sequence: !input dots_2_single_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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment