Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save caglarsayin/c04f8d4c8afb7f21a2f14d718ff8e039 to your computer and use it in GitHub Desktop.
Save caglarsayin/c04f8d4c8afb7f21a2f14d718ff8e039 to your computer and use it in GitHub Desktop.
blueprint zha_ikea_tradfri_4button_remote_temp
blueprint:
name: ZHA - IKEA TRADFRI - 4 Button Remote - Color Lights
description: This automation simulates the use of the IKEA TRADFRI remote control
connected through ZHA. Button Up and Button Down = Turn On and Turn Off. Holdin Button Up or holding Button Down = Increase or decrease of brightness. Button Right Press changes the color hue, Button Left changes the color saturation.
domain: automation
input:
remote:
name: IKEA TRADFRI remote control 4 buttons
description: Select the remote control you wish to use.
selector:
device:
integration: zha
manufacturer: IKEA of Sweden
model: Remote Control N2
multiple: false
light:
name: Light
description: Select the light entity you wish to control.
selector:
entity:
domain: light
multiple: false
speed:
name: Speed
description: The speed in which to update the light when the button is held.
selector:
number:
min: 0.0
max: 1000.0
step: 50.0
unit_of_measurement: milliseconds
mode: slider
default: 100
color_step_hue:
name: Color Step Hue
description: The color step change for the hue value
selector:
number:
min: 1.0
max: 360.0
step: 1.0
unit_of_measurement: hue
mode: slider
default: 10
color_step_sat:
name: Color Step Saturation
description: The color step change for the saturation value
selector:
number:
min: 1.0
max: 100.0
step: 1.0
unit_of_measurement: saturation
mode: slider
default: 5
source_url: https://gist.github.com/cehberlin/be7b5d34aecb71aea0dd9514651e802d
mode: restart
max_exceeded: silent
variables:
var_light: !input 'light'
var_speed: !input 'speed'
var_color_step_hue: !input 'color_step_hue'
var_color_step_sat: !input 'color_step_sat'
trigger:
- platform: event
event_type: zha_event
event_data:
device_id: !input 'remote'
action:
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "on" }}'
sequence:
- service: light.turn_on
target:
entity_id: !input 'light'
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "off" }}'
sequence:
- service: light.turn_off
target:
entity_id: !input 'light'
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "move_to_level_with_on_off"
}}'
sequence:
- service: light.turn_on
target:
entity_id: !input 'light'
data:
brightness: 254
hs_color:
- 38.222
- 52.941
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "step_with_on_off" }}'
sequence:
- service: light.turn_on
target:
entity_id: !input 'light'
data:
brightness_step_pct: 20
transition: '{{ (var_speed / 1000)|float }}'
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "move_with_on_off" }}'
sequence:
- repeat:
while: []
sequence:
- service: light.turn_on
target:
entity_id: !input 'light'
data:
brightness_step_pct: 10
transition: '{{ (var_speed / 1000)|float }}'
- delay:
milliseconds: !input 'speed'
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "step" }}'
sequence:
- service: light.turn_on
target:
entity_id: !input 'light'
data:
brightness_step_pct: -20
transition: '{{ (var_speed / 1000)|float }}'
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "move" }}'
sequence:
- repeat:
while: []
sequence:
- service: light.turn_on
target:
entity_id: !input 'light'
data:
brightness_step_pct: -10
transition: '{{ (var_speed / 1000)|float }}'
- delay:
milliseconds: !input 'speed'
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "press" }}'
- condition: template
value_template: '{{ trigger.event.data.args[0] == 256 }}'
- condition: template
value_template: '{{ trigger.event.data.args[1] == 13 }}'
- condition: template
value_template: '{{ trigger.event.data.args[2] == 0 }}'
sequence:
- service: light.turn_on
target:
entity_id: !input 'light'
data:
hs_color:
- '{{(state_attr(var_light, "hs_color")[0] + var_color_step_hue) % 360}}'
- '{{ state_attr(var_light, "hs_color")[1] }}'
transition: '{{ (var_speed / 1000)|float }}'
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "hold" }}'
- condition: template
value_template: '{{ trigger.event.data.args[0] == [3328] }}'
- condition: template
value_template: '{{ trigger.event.data.args[1] == [0] }}'
sequence:
- repeat:
while: []
sequence:
- service: light.turn_on
target:
entity_id: !input 'light'
data:
hs_color:
- '{{(state_attr(var_light, "hs_color")[0] + var_color_step_hue) % 360}}'
- '{{ state_attr(var_light, "hs_color")[1] }}'
transition: '{{ (var_speed / 1000)|float }}'
- delay:
milliseconds: !input 'speed'
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "press" }}'
- condition: template
value_template: '{{ trigger.event.data.args[0] == 257 }}'
- condition: template
value_template: '{{ trigger.event.data.args[1] == 13 }}'
- condition: template
value_template: '{{ trigger.event.data.args[2] == 0 }}'
sequence:
- service: light.turn_on
target:
entity_id: !input 'light'
data:
hs_color:
- '{{ state_attr(var_light, "hs_color")[0] }}'
- '{{(state_attr(var_light, "hs_color")[1] + var_color_step_sat) % 100}}'
transition: '{{ (var_speed / 1000)|float }}'
- conditions:
- condition: template
value_template: '{{ trigger.event.data.command == "hold" }}'
- condition: template
value_template: '{{ trigger.event.data.args[0] == [3329] }}'
- condition: template
value_template: '{{ trigger.event.data.args[1] == [0] }}'
sequence:
- repeat:
while: []
sequence:
- service: light.turn_on
target:
entity_id: !input 'light'
data:
hs_color:
- '{{ state_attr(var_light, "hs_color")[0] }}'
- '{{(state_attr(var_light, "hs_color")[1] + var_color_step_sat) % 100}}'
transition: '{{ (var_speed / 1000)|float }}'
- delay:
milliseconds: !input 'speed'
default: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment