Example script for changing color temp using the left and right buttons;
Yaml script for the left button:
service: light.turn_on
target:
entity_id: light.hanglamp_keuken
data:
color_temp: >
{{ state_attr( 'light.hanglamp_keuken', 'color_temp' ) | default( 0, True
) | int + 50 }}
Yaml script for the right button:
service: light.turn_on
target:
entity_id: light.hanglamp_keuken
data:
color_temp: >
{{ state_attr( 'light.hanglamp_keuken', 'color_temp' ) | default( 0, True
) | int - 50 }}
The default(0,True)
sets the value to zero, True is required to make it work. This is because sometimes when powering the lamp on for the first time the color_temp
value is None and not an int.
I’m looking for a way to remove the manual entity_id, I tried !input “light” or this.entity_id but that doesn’t seem to work.
I hope this helps someone.