Hello!
I have a problem with sun as condition. I just want to make a automation where a light will be turned on 1 hour before sunrise and one hour after sunset. For example if sunrise is on 7:00 and sunset is on 15:00 i Would like to turn on light between 6:00 and 16:00. Could you post me a solution?
I would like to have it as condition, not as trigger, i just want to use it in existing automation Can u make it as condition? I have sth like this actually, First automation: if 2 movement sensor are on-> turn light on, and second automation: If for 1 minutes there is not a movement on 2 movement sensor turn off the lights. And now i want First automation like this: if 2 movement sensor are on and it is 1h before sunset and 1h after sunrise (i mean it is dark outside) turn light on. Dont change second automation.
Off topic (TS wanted a condition, not a automation):
As an automation your solution is not sufficient! Always use two seperate automations. If, for some reason, your lights are off before sunrise, this automation will turn them on when the sun rises. @forsquirel’s solution is the way to do this right.
OT - it was a basic example for the OP to work from as he didn’t provide any code himself. That code would work fine in isolation and caters for exactly what the OP asked for…
Saying “always use two separate automations” is utter garbage. One automation with a templated action is the way to do this correctly with ‘error handling’.
But before the OP gets that far, he needs to understand what he’s doing, hence the basic-ness of my original reply. An easy way to tell if my replies are ‘this is as basic as it gets’ is when I just dump some code in with no explanations.
I did not put any code because I could not do it a few hours ago - i was outside my home
Truth is i write a wrong info on topic so i need to correct that. I want to turn on light when its dark outside (that mean its 30 min before sunset to 30min after sunrise) but only when 2 motion sensor will be turned on. In my config i have condition that wont turn up if other light switch is on. Im uploading code of my automations.yaml beacuse it is not formatting well here. There is no any errors so trully i dont know how to make it right.
Secondly I dont care about a sunset/sunrise in switching off the light, I just wanna make it go off when movement is detected for 1min atleast. But it is not working too. Edit: Ok i fixed this
So thank you for all your help I am testing this solution with “OR” instead “AND” in condition and its working well but i need more time to be 100% sure its all ok