Color temperature change action

Thanks for this, I;ve used this script to program my STYRBAR left / right to change color temp using the ZHA - IKEA four button remote (Styrbar) for lights (E2001, E2002) blueprint.

In this scenario I’ve had the issue that when the lamp has been off the color_temp value is None so parsing it to an int causes an error. I’ve solved it by adding the following filter:

{{ state_attr('light. livingroom_lights', 'color_temp') | default(0,True) | int + 50 }}

The default(0,True) sets the value to zero, True is required to make it work.

Entire Yaml script for the left button:

service: light.turn_on
target:
  entity_id: light.livingroom_lights
data:
  color_temp: >
    {{ state_attr( 'light.livingroom_lights', 'color_temp' ) | default( 0, True
    ) | int + 50 }}

Right button uses the same script, but with - 50.

I hope this helps someone.

1 Like