Skip to content

Instantly share code, notes, and snippets.

@prashnts
Last active July 31, 2022 08:11
Show Gist options
  • Save prashnts/befbb2cb5ddfa341de4f256827fc53d0 to your computer and use it in GitHub Desktop.
Save prashnts/befbb2cb5ddfa341de4f256827fc53d0 to your computer and use it in GitHub Desktop.
blueprint:
name: Ikea Styrbar Remote over Z2M
description: Control your lights with the IKEA STYRBAR remote. You can also set actions for the left and right button.
domain: automation
input:
transition_time:
name: Transition time
description: Transition time for the target lights in seconds
selector:
number:
min: 1.0
max: 60.0
mode: slider
step: 0.1
unit_of_measurement: 'sec'
remote:
name: Remote
description: The action entity of your Styrbar remote
selector:
entity:
domain: sensor
target_light:
name: Lights
description: The lights you want to control with the remote
selector:
target:
entity:
domain: light
button_left:
name: Left button
description: Action to run on left button press
default: []
selector:
action: {}
button_right:
name: right button
description: Action to run on right button press
default: []
selector:
action: {}
brightness:
name: Brightness
description: The brightness you want your lights to be when turning them on
default: 100
selector:
number:
min: 0.0
max: 100.0
mode: slider
step: 1.0
unit_of_measurement: '%'
force_brightness:
name: Force Brightness
description: Force the above set brightness when turning on the lamps?
default: false
selector:
boolean: {}
trigger:
- platform: state
entity_id: !input 'remote'
attribute: action
condition: []
action:
- variables:
command: '{{ trigger.to_state.state }}'
- choose:
- conditions:
- condition: template
value_template: '{{ command == ''toggle'' }}'
sequence:
- choose:
- conditions: '{{ force_brightness }}'
sequence:
- service: light.toggle
target: !input 'target_light'
data:
transition: !input transition_time
brightness_pct: !input 'brightness'
default:
- service: light.toggle
target: !input 'target_light'
data:
transition: !input transition_time
- conditions:
- condition: template
value_template: '{{ command == ''brightness_up_click'' }}'
sequence:
- repeat:
until:
- condition: state
entity_id: !input 'remote'
state: brightness_stop
attribute: action
sequence:
- service: light.turn_on
data:
brightness_step_pct: -10
transition: !input transition_time
target: !input 'target_light'
- delay: '1'
- conditions:
- condition: template
value_template: '{{ command == ''brightness_down_click'' }}'
sequence:
- repeat:
until:
- condition: state
entity_id: !input 'remote'
state: brightness_stop
attribute: action
sequence:
- service: light.turn_on
data:
brightness_step_pct: +10
transition: !input transition_time
target: !input 'target_light'
- delay: '1'
- conditions:
- '{{ command == ''arrow_left_click'' }}'
sequence: !input 'button_left'
- conditions:
- '{{ command == ''arrow_right_click'' }}'
sequence: !input 'button_right'
mode: restart
max_exceeded: silent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment