I’m trying to create an automation that turns on a lamp as soon as another is turned on by a motion sensor. However, the lamp should take over the attribute values of the previously turned on lamp, such as “brighness” and “color_temp” - and that’s the point where I get stuck.
Why do you need to do this? How do you turn on the lights “badzimmer_wc”, “badzimmer_dusche_1” and “badzimmer_dusche2”? With a switch connected to home assistant or with an automation?
Imagine a bathroom divided into 3 small rooms (look at my masterpiece below).
If you enter ROOM 1 a motion sensor (Philips Hue) turns on the light in ROOM 1 (“light.badezimmer_waschbecken”) for a duration of 2 minutes.
If you enter ROOM 3, another motion sensor turns on the lights in ROOM 3 (“light.badezimmer_dusche_1” and “light.badezimmer_dusche_2”) for a duration of 3 minutes and disables the motion sensor in ROOM 1 to prevent the by Philips Hue automated switch off of the light in ROOM 1 (“light.badezimmer_waschbecken”).
Now, if you still are in ROOM 3 and you do not move long enough so the motion sensor “thinks” there is no presence - the lights in ROOM 3 and ROOM 1 will be turned off. After the lights turned off you maybe want to turn it on again with a movement. So if you do that, the light in ROOM 1 should be switched on and take over the brightness and color temperature of the lights in ROOM 3.
The brighness and temperature of the lights are depending on the daytime.
It’s a little bit complex for a little room like that…
Oh, I somehow assumed that you do all these automations within home assistant not with the Hue Bridge.
The code you posted should work. What is the problem, does it turn the light on, but not with the desired brightness or does it not turn the light on at all?
I haven’t gone thru the whole thing yet but I see a few things that you could do to simplify things:
I see that you are going “from off to on for 1 second”. Why? since the motion sensor likely can only be in two states (either on or off) and no other state then you don’t really need the “from” part.
And I think the “for 1 second” is superfluous unless it’s there for some specific quirk in the functionality of your sensor that I’m not aware of. So you can probably remove that too.
And you don’t need to use the ["…"] notation for the attributes. just use a . notation and it will work fine (again unless I’m missing some quirk in how your lights report their attributes).
and try removing the quotation marks from around the brackets in template between the “if-else” statements. by putting quotes around those you are telling the system to use the literal string ‘{{ states.light.badezimmer_dusche_1.attributes[“color_temp”] }}’. And that won’t work.
Wed Oct 09 2019 23:28:14 GMT+0200 (Mitteleuropäische Sommerzeit)
Error while executing automation automation.badezimmer_beleuchtung_waschbecken_on. Invalid data for call_service at pos 1: expected int for dictionary value @ data['color_temp']
Verbindung getrennt. Verbinde erneut...
Thank you very much for your detailed instructions!
After removing the quotation marks it works fine!
I think I will now optimize my automations a bit along to your description.
But the 1 second of each trigger has a sense, cause my lights are fading on with a transition time of a few milliseconds. If I remove the 1 second the automation would probalby trigger immediately with wrong values for brightness and color temperature.