Skip to content

Instantly share code, notes, and snippets.

@trilorian
Created May 7, 2024 11:42
Show Gist options
  • Save trilorian/31d61da50a2a3bdd7737d26c29055ad4 to your computer and use it in GitHub Desktop.
Save trilorian/31d61da50a2a3bdd7737d26c29055ad4 to your computer and use it in GitHub Desktop.
blueprint:
name: IKEA Rodret Dimmer
description: "## IKEA RODRET Dimmer remote (v1.88)
Only for use with [ZHA](https://www.home-assistant.io/integrations/zha/)
Available controls:
- Click the **on** or **off** buttons
- Click and hold the **on**/**off** buttons
- Double click the **on** or **off** buttons
- Triple click the **on** or **off** buttons
All actions are optional.
"
source_url: https://github.com/trilorian/zha/blob/main/ikea/rodret/ikea-rodret_E2201_ZHA.yaml
domain: automation
input:
remote_device:
name: Remote
description: IKEA Rodret dimmer remote to use.
default: ""
selector:
device:
filter:
integration: zha
manufacturer: IKEA of Sweden
model: RODRET Dimmer
multiple: false
on_click_action:
name: On - Single click action
description: Choose action(s) to run when **on** button is clicked.
default: []
selector:
action: {}
off_click_action:
name: Off - Single click action
description: Choose action(s) to run when **off** button is **clicked**.
default: []
selector:
action: {}
dimming_lights:
name: Dimming lights
description:
Choose lights to dim (if any)
default: []
selector:
entity:
domain: light
multiple: true
minimum_light_level:
name: Minimum light level when decreasing brightness
default: 20
selector:
number:
min: 1.0
max: 99.0
step: 1.0
mode: slider
brightness_step_pct:
name: Brightness step
description:
Choose a step to increase/decrease brightness, default is 10%.
default: 10
selector:
number:
min: 1.0
max: 50.0
step: 1.0
mode: slider
on_double_click_action:
name: On - Double click action
description:
Choose action(s) to run when clicking the **on** button twice.
default: []
selector:
action: {}
on_triple_click_action:
name: On - Triple click action
description:
Choose action(s) to run when clicking the **on** button three times.
default: []
selector:
action: {}
off_double_click_action:
name: Off - Double click action
description:
Choose action(s) to run when clicking the **off** button twice.
default: []
selector:
action: {}
off_triple_click_action:
name: Off - Triple click action
description:
Choose action(s) to run when clicking the **off** button three times.
default: []
selector:
action: {}
helper_multi_click_delay:
name: Helper - Multi click delay
description:
Max delay between the button clicks for the **Multi click events**. Change this value if you notice that the multi click action is not triggered properly.
default: 250
selector:
number:
unit_of_measurement: milliseconds
min: 100.0
max: 5000.0
step: 10.0
mode: slider
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:
zha_remote: !input remote_device
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: "{{ zha_remote }}"
command: "on"
cluster_id: 6
endpoint_id: 1
id: click-on-zha
- platform: event
event_type: zha_event
event_data:
device_id: "{{ zha_remote }}"
command: "off"
cluster_id: 6
endpoint_id: 1
id: click-off-zha
- platform: event
event_type: zha_event
event_data:
device_id: "{{ zha_remote }}"
command: "move_with_on_off"
cluster_id: 8
endpoint_id: 1
args: [0, 83]
id: hold-on-zha
- platform: event
event_type: zha_event
event_data:
device_id: "{{ zha_remote }}"
command: "move"
cluster_id: 8
endpoint_id: 1
args: [1, 83, 0, 0]
id: hold-off-zha
- platform: event
event_type: zha_event
event_data:
device_id: "{{ zha_remote }}"
command: "stop_with_on_off"
cluster_id: 8
endpoint_id: 1
id: release-zha
action:
- variables:
brightness_step_pct: !input brightness_step_pct
minimum_light_level: !input minimum_light_level
light: !input light_entity
- choose:
- conditions:
- condition: trigger
id:
- click-on-zha
sequence:
- wait_for_trigger:
- platform: event
event_type: zha_event
event_data:
device_id: "{{ zha_remote }}"
command: "on"
cluster_id: 6
endpoint_id: 1
timeout:
milliseconds: !input helper_multi_click_delay
continue_on_timeout: true
- choose:
- conditions:
- condition: template
value_template: '{{ wait.trigger == none }}'
sequence: !input on_click_action
default:
- wait_for_trigger:
- platform: event
event_type: zha_event
event_data:
device_id: "{{ zha_remote }}"
command: "on"
cluster_id: 6
endpoint_id: 1
timeout:
milliseconds: !input helper_multi_click_delay
continue_on_timeout: true
- choose:
- conditions:
- condition: template
value_template: '{{ wait.trigger == none }}'
sequence:
- choose:
- conditions:
# Double click, check if on_double_click_action is defined
- condition: template
value_template: "{{ on_double_click_action != none }}"
sequence: !input on_double_click_action
default: !input on_click_action
default:
- choose:
- conditions:
# Triple click, check if on_triple_click_action is defined
- condition: template
value_template: "{{ on_triple_click_action != none }}"
sequence: !input on_triple_click_action
default: !input on_click_action
- choose:
- conditions:
- condition: trigger
id:
- click-off-zha
sequence:
- wait_for_trigger:
- platform: event
event_type: zha_event
event_data:
device_id: "{{ zha_remote }}"
command: "off"
cluster_id: 6
endpoint_id: 1
timeout:
milliseconds: !input helper_multi_click_delay
continue_on_timeout: true
- choose:
- conditions:
- condition: template
value_template: '{{ wait.trigger == none }}'
sequence: !input off_click_action
default:
- wait_for_trigger:
- platform: event
event_type: zha_event
event_data:
device_id: "{{ zha_remote }}"
command: "off"
cluster_id: 6
endpoint_id: 1
timeout:
milliseconds: !input helper_multi_click_delay
continue_on_timeout: true
- choose:
- conditions:
- condition: template
value_template: '{{ wait.trigger == none }}'
sequence:
- choose:
- conditions:
# Double click, check if off_double_click_action is defined
- condition: template
value_template: "{{ off_double_click_action != none }}"
sequence: !input off_double_click_action
default: !input off_click_action
default:
- choose:
- conditions:
# Triple click, check if off_triple_click_action is defined
- condition: template
value_template: "{{ off_triple_click_action != none }}"
sequence: !input off_triple_click_action
default: !input off_click_action
- conditions:
- condition: trigger
id:
- hold-on-zha
sequence:
- repeat:
count: !input helper_max_loops
sequence:
- parallel:
- sequence: !input on_hold_action
- sequence:
- choose:
- conditions:
- condition: trigger
id:
- hold-on-zha
sequence:
- wait_for_trigger:
- platform: event
event_type: zha_event
event_data:
device_id: "{{ zha_remote }}"
command: "stop_with_on_off"
cluster_id: 8
endpoint_id: 1
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-off-zha
action:
service: light.turn_on
entities: dimming_lights
data_template:
brightness: '{{states.dimming_lights.attributes.brightness - 10}}'
# sequence:
# - repeat:
# count: !input helper_max_loops
# sequence:
# repeat:
# while:
# - condition: numeric_state
# entity_id: !input dimming_lights
# attribute: brightness
# above: "{{ float(float('brightness_step_pct' + float('brightness_step_pct')) }}"
## - condition: template
## value_template: "{{ state_attr(entity, 'speed') > 0 }}"
## value_template: "{{ state_attr('!input light_entity', 'brightness')|float(none) > brightness_step_pct|float + minimum_light_level|float }}"
# sequence:
# - service: light.turn_on
# target: !input light_target
# data:
# transition: 1
# brightness_step_pct: "-{{ brightness_step_pct }}"
# - delay: 1
# sequence:
# - parallel:
## - sequence: !input off_hold_action
# - sequence:
# repeat:
# while:
# - condition: template
# value_template: "{{ repeat.index < 10 }}"
# sequence:
# - service: light.turn_on
# target: !input light_target
# data:
# transition: 1
# brightness_step_pct: -10
# - delay: 1
# - sequence:
# - choose:
# - conditions:
# - condition: trigger
# id:
# - hold-off-zha
# sequence:
# - wait_for_trigger:
# - platform: event
# event_type: zha_event
# event_data:
# device_id: "{{ zha_remote }}"
# command: "stop_with_on_off"
# cluster_id: 8
# endpoint_id: 1
# 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-off-zha
# sequence:
# - parallel:
# - sequence:
# - repeat:
# count: !input helper_max_loops
# sequence:
# repeat:
# until:
# condition: trigger
# id: release-down-zha
# while:
# - condition: template
# value_template: "{{ trigger.id == 'release-down-zha' }}"
# - condition: numeric_state
# entity_id: !input light_entity
# attribute: brightness
# above: 3
# sequence:
# - service: light.turn_on
# target: !input light_target
# data:
# transition: 1
# brightness_step_pct: -!input brightness_step_pct
# - delay: 1
# - sequence:
# - choose:
# - conditions:
# - condition: trigger
# id:
# - hold-on-zha
# sequence:
# - wait_for_trigger:
# - platform: event
# event_type: zha_event
# event_data:
# device_id: "{{ zha_remote }}"
# command: "stop_with_on_off"
# cluster_id: 8
# endpoint_id: 1
# 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