I have made an automation that turns on some light in a clock and chooses a random color each time. Because the blue light is much less intense that the other colors I would like to increase brightness when color is blue.
I have added the condition: template in my action but nothing happens. I don´t get any error in the log file.
Someone has an idea what is wrong?
I have tried your first suggestion but it seems that the light keeps turning on also after turning it off. Could that be because the action triggers after each state change, including “off”?
I have also noticed that the LED driver for this wall clock somehow needs a change in brightness after it has been set the first time to react. Brightness -->20 nothing happens, then brightness -->21 then brightness is set to 20 in reality. Odd behaviour but that is strangely how this zigbee RGBW driver Works through Philips Hue Bridge with HA.
I have also tried to insert a 10 sec delay in my own automation before the condition: template but it still does not increase the brightness when blue is active.
I’m not sure how scripts work when trying to access changes in states that occur throughout the script. That is why I tried to steer you towards the other solution, which uses a state object that drives the randomness. That way you know that ‘blue’ will be chosen prior to choosing it. It allows you to account for the color blue all throughout your script.
I have now tried this for brightness but it stays at 20, also when blue.
I have added the delay and the extra data template for getting the brightness change as described before.
- alias: change brightness based on color
trigger:
- platform: state
entity_id: light.wallclock
to: 'on'
action:
- service: light.turn_on
data_template:
entity_id: light.wallclock
brightness: "{{ 50 if is_state_attr('light.wallclock','color_name','blue') else 20 }}"
- delay: 0:00:01
- service: light.turn_on
data_template:
entity_id: light.wallclock
brightness: "{{ 51 if is_state_attr('light.wallclock','color_name','blue') else 21 }}"
actually I don´t see “color_name” under attributes, but since it reacts in my automations I guess it has to be okay.
I also tried replacing color_name with rgb_color but still the same
(value_template: ‘{{ states.light.ur.attributes.rgb_color == [10,0,255] }}’
Yes these are the attributes.
Sorry about “ur” It is just the Danish Word for clock (wallclock). I translated it so it would make a little sense, but forgot the translation here
I am not quite sure how to check the template inside the editor. I have inserted the template in the editor and see some result in the upper right side. This does not change when I change color to blue.
Hmm the response is: (10, 0, 255) as it should be. It seems that it is correct but when I try color_name there is no result. So I guess color_name can be used for setting the color but is not used for “feedback”
I should be possible to get anything/atribute that is shown in the dev-state on that entity_id into a message template for feedback or use it in a value_template somehow.
What does that page show on the light.ur?
you could also check if settings are applied correctly by customizing the light in the front-end to display those attributes: