I am new to all of this, so if this should be posted elsewhere, just let me know.
I have an automation setup where if motion is detected a RGB LED is turned on to white, conditions are light level (LDR) and time.
A second automation turns it off after 1 minute if state = standby (no motion) and has the same time condition applied.
It works fine, but i want more…
I would like to “match” the state? of the group of leds that the led in question belongs to, rather than simply turn off after one minute.
By “match” I mean all options i.e. colour, brightness etc, not just on or off.
How do I query the state and those options of the group and get then set the LED to match it?
I’m assuming by “group of leds” you mean a light group (as in a Light Group, as opposed to an organizational group, because the former will show combined values of brightness, etc., whereas the latter will only show on or off.) Without knowing more of your specifics, basically you can do the following as a step in an automation’s action or in a script:
- service: light.turn_on
entity_id: light.whatever
data_template:
brightness: "{{ state_attr('light.led_group', 'brightness') }}"
hs_color: [{{ state_attr('light.led_group', 'hs_color')
.replace('[', '').replace(']', '').split(',')[0] }}, {{
state_attr('light.led_group', 'hs_color')
.replace('[', '').replace(']', '').split(',')[1] }}]
Note that this will generally only work if you’re turning the led on (i.e., the light group is on.) A complete solution would be more involved, doing the right thing if the light group was off. Also, I can’t really test the code above, but I think it should work.
It did not work, even after i created a proper light group.
Configuration check complained about this “[” and seemed to prefer a couple of " framing the hs_color portion.
But still no luck even after a green check result on a configuration test. Which i guess is just checking proper format and not content. Really, your code… i don’t know at all and have much to learn.
Importantly you turned me on to the group as a platform which you were correct to clarify, i did not have it this way and can see new possibilities in other parts of my config, now that i am aware.
Thanks for your help, i will keep plugging away at it.
Ok. Sorry, I don’t have any color lights to experiment with. Good luck!