Here’s what I am trying to do and how I’m trying to do it.
Alternate suggestions about how to achieve this same result are totally welcome.
I have an RGB strip next to my bed. (WS2812B controlled by WLED)
I have used this python code to create the ability to fade it up or down: Light Fader by Transition Time
I have set up an automation at 6:30am on weekdays to turn it on, blue, 1% and then fade up to 60% over 30 minutes. This works beautifully.
The other side is I want to make it fade out over 30 minutes at night when I go to bed which is a variable time so I can’t schedule it.
I use both homekit and alexa integrations so I can use voice commands with either siri or alexa.
I have written a script that sets the lights red, 45% brightness, and then fades the lights down to 0 (turns off) over 30 minutes. This works.
I would like to be able to trigger this script by Alexa, but Alexa can not have scripts or automations as entities, only scenes.
So what I need is a way to be able to activate a scene that then triggers my script and this is what I am stuck on.
Another approach might be a template switch. I don’t use either Homekit or Alexa integrations, but it looks like the Alexa integration allows you to work with a switch entity, so you could probably use the turn_on: series of actions in the template switch to run your script. So the voice command would be “turn on your_switch_name”.
If you look at it’s state in Developer Tools > States you’ll see it is scening (whatever that means). It doesn’t change when the scene is activated (i.e. “turned on”).
That’s why I suggested you use an Event Trigger (not a State Trigger).
If I activate the scene the “event” of that scene activating triggers the automation which calls the script.
It’s a few steps but it works nicely and I am very happy with the result.
Thank you everyone for the assist, seriously, thank you!
Here is the code for the automation that worked for me:
@mrsnyds - I didn’t go down the path of a template switch to solve this one but I can see how it would work. You have introduced me to another great feature of this platform I wasn’t aware of, thank you for that. I will be using these in the future.
The example I posted works (and is the one you ultimately used) yet you marked the post with the example that doesn’t work with the Solution tag. Any particular reason for that?
Hi, i tried the code that u wrote. If im pressing the aktivate button on a scene in the scenes tab, my automation gets triggered. If i aktivate the scene with another automation for example than nothing happens.
Does someone has an idea?