hello,
i’m stuck on a scene that should be simple, but i always get lost along the way
I would like, when my gate opens (I have a sensor), to turn on a projector but only when it’s dark, like 1 hour after sunset
so trigger gate open and if it’s night projector on
I get lost in the boxes and don’t know how to do it.
This will only launch the scene once, not every time the portal opens. I don’t think this is possible in Gladys today. There’s a missing condition for whether the sun has set or not.
It is indeed not possible today directly in a single scene. But even if there was a condition on whether the sun is set or not, it would not quite meet your need since you want it to be night, so a little after sunset…
For your need, with what Gladys already allows, I think you should do this:
in the ‹ Virtual Mqtt Devices › integration, create a device of type ‹ switch › that you call for example « projector to turn on »
in a scene with a trigger « at each sunset » with the option « X minutes after » (you choose the X that pleases you), you use the action Control a device to change the value of « projector to turn on » to ‹ on ›
in a scene with a trigger « at each sunrise » with the option « X minutes before » (you choose the X that pleases you), you use the action Control a device to change the value of « projector to turn on » to ‹ off ›
in the scene you have already written, you indeed use the trigger « state change: the gate opens », you make an action Get the state of « projector to turn on », you add a Condition action on variable that checks if « projector to turn on » is ‹ on ›, and then you finish with the action to turn on the projector.
The trigger instead of the sun is the gate sensor..
Then either put a light sensor or test the sun with 2 other scenes next to it.
So a sunrise scene that sets an MQTT virtual sensor to 1.
Another sunset scene that sets this sensor to 0.
You can put a time condition in these scenes if needed.
And in the scene of the detected gate, the state of this virtual sensor.
When the gate opens, if the virtual sensor is at 0, it means it’s after sunset, so we turn on the light.
Personally, the virtual sensor triggered at sunrise and sunset is what I did in my install and I use it often