yes, thats possible, you can also set a profile, but thats isnt reflected either in the states. Not sure if one can template these settings out. The ones in the dev-state definitely can be used
looks like your getting a tuple back, not a list. you could convert the rgb_colors to strings and compare the results.
try this in the template editor:
{{ state_attr('light.ur','rgb_color') == '[10,0,255]' }}
or this
{{ state_attr('light.ur','rgb_color') == '(10,0,255)' }}
or this
{% set r, g, b = states.light.ur.attributes.rgb_color.split(',') %}
{{ [ r | int , g | int, b | int ] == [10,0,255] }}
I suggest you pick up some jinja experience because this is trial and error. You should be able to try a bunch of things in the template editor until you figure out how to verify they are equal. You have the information, you just need to convert one of the 2 sides of the equation so that they both are the same type.
what happens when you set the brightness through the Hue app? Is that at all possible?
No problem. It shows the new brightness level from the Hue app immidiately in HA
ok so weâre sure the light has the possibility to have its brightness setâŚ
can you see the light interface in HA? and does the slider work?:
using {{ state_attr(âlight.urâ,ârgb_colorâ) == â(10,0,255)â }} and removing the qoutes did it. {{ state_attr(âlight.urâ,ârgb_colorâ) == (10,0,255) }} Now it returns with âtrueâ and it Works in my automation too.
Thanks very much for helping.
It Works now. See my answer to Petro.
Thanks for helping
cool.
care to share your final and working automations ?
Of course, here they are.
- alias: Wallclock on with random color when someone home and sunset
trigger:
- platform: sun
event: sunset
condition:
- condition: state
entity_id: group.device_trackers
state: home
action:
- service: light.turn_on
entity_id: light.ur
data_template:
color_name: >
{{ [
"blue",
"red",
"green",
"orange",
"cyan",
"magenta"
] |random }}
- alias: increase brightness when blue
trigger:
- platform: state
entity_id: light.ur
to: 'on'
action:
- service: light.turn_on
data_template:
entity_id: light.ur
brightness: "{{ 50 if is_state_attr('light.ur','rgb_color',(10,0,255)) else 20 }}"
- delay: 0:00:01
- service: light.turn_on
data_template:
entity_id: light.ur
brightness: "{{ 51 if is_state_attr('light.ur','rgb_color',(10,0,255)) else 21 }}"
I now want to replace these odd color names with RGB colors instead but got a bit of the same problem I guess.
I have tried both (and more) but they return those erros.
data_template:
rgb_color: >
{{ (
[0,0,255],
[255,0,0]
) |random }}
[homeassistant.core] Invalid service data for light.turn_on: None for dictionary value @ data[ârgb_colorâ]. Got â[0, 0, 255]â
data_template:
rgb_color: >
{{ [
(0,0,255),
(255,0,0)
] |random }}
[homeassistant.core] Invalid service data for light.turn_on: None for dictionary value @ data[ârgb_colorâ]. Got â(0, 0, 255)â
maybe this helps, checking the correct format:
action:
service: light.turn_on
data:
entity_id: light.master_bedroom
transition: 5
brightness: 150
data_template:
rgb_color: ['{{ "{0:d}".format(range(0, 255)|random) }}',
'{{ "{0:d}".format(range(0, 255)|random) }}',
'{{ "{0:d}".format(range(0, 255)|random) }}']
and to be sure, this is without template:
action:
service: light.turn_on
entity_id: light.master_bedroom
data:
transition: 5
rgb_color: [255, 251, 245]
brightness: 150
or a full randomized party_modeâŚ:
data_template:
entity_id: light.{{['dining_corner','cabinet','kist','home_theater']|random}}
rgb_color: ['{{ (range(0, 255)|random) }}',
'{{ (range(0, 255)|random) }}',
'{{ (range(0, 255)|random) }}']
brightness: '{{ (range(50, 250)|random) }}'
transition: '{{ (range(1, 3)|random) }}'
be sure to use the correct quotes. the single quotes copied from the community forum sometimes are curly, and the parser errors out on these.
this might work:
data_template:
rgb_color: >
{{ [[0,255,0],[255,0,0]]
|random }}
though I admit it seems a bit odd, it renders the correct output in the dev-template
I don´t want a comletely random color just a random color of the one I have listed.
The last suggestion returns this error
[homeassistant.core] Invalid service data for light.turn_on: None for dictionary value @ data[ârgb_colorâ]. Got â[255, 0, 255]â
well, i told you it looked odd⌠but thereâs progress, because the are there.
i tried this
{{ ['[0,255,0]','[255,0,0]']
|random }}
which randomizes correctly in the dev-template too, maybe give that a try?
if not call @pnbruckner and @petro âŚ
same result. Thanks for trying though
last effort:
{%set color = [ '[0,255,0]','[255,0,0]' ] %}
{{ color
|random }}
which is the same, but makes the excercise a bit easier to read
@jeppper nothing will work like that. Just use the color name. Jinja doesnât return anything but strings so the parser will never work when it needs to be a tuple/list. So no matter how hard you try it wonât work.
Okay no problem. I will just keep using the color names Thanks