Hi folks. My lady and I have just hammered out how we’d like the lights for my daughter’s room to work - but I’m having real trouble wrapping my head around how to code it. Any advice would be greatly appreciated!
The brief:
- One single button will control the light. (I’m already successfully catching the event this fires and running a test automation).
- The “correct” (or default, rather) colour and brightness of the light is defined by time of day, e.g. 255,255,255 and 100% from 0700 to 1900. I have these defined as Scenes. There are currently three Scenes/times of day, but this might well expand to four/five.
- If the light is off, or not the “correct” colour/brightness by time of day, pressing the button should turn it on and set it to the correct Scene.
- If the light is on, AND already the correct colour+brightness/scene, turn it off.
My problem really is I’m not sure how to catch all these different scenarios without just writing a ton of different automations, which would be ugly, but worse, Wrong
I started trying to handle the different times/scenes in a template condition, but then I thought I probably can’t use properties of the light (e.g. rgb_color, brightness_pct), when the trigger itself is nothing to do with the light? (It’s platform: event)
Could I code a template sensor “Daughters light is correct colour” = true/false, and use the output of that in my conditions?
Am I way overcomplicating this, and it’s actually easy to do in a single automation if, well, you’re better at it than me?
Basically, how would you approach this problem?