Hi, I would like to create an automation to close my windows at sunset, but based on the weather.
If there is rain it must close 30 minutes before sunset, if cloudy at the exact sunset, if clear 15 minutes after sunset.
I have already done this with 3 automations, but I wanted to put it in only one, also because I would like to send a voice alert 2 minutes before closing.
I created this code but it doesn’t work
I’d use a template trigger and the sun elevation. Then you can close at (say) 1 degree when it’s sunny, 1.5 degrees when party cloudy, etc.
That’s also much more consistent in terms of light level. Half an hour before sunset is a very different level of light outside on the longest day than the shortest day.
and used this sensor to trigger the automation.
Now I’d like to put an entity that shows me the time left to close.
I know that the altitude is not linear, but I want to create a sensor that when there are 3 or 4 hours to sunset, I calculate the time left.
The multiplying factor for my zone is 0.166 every minute, which means the elevation decreases by about 1.66 every ten minutes.
So if the sunset today is at 20:00 and at 17:00 the elevation calculated by my sensor is 30.36 multiplying 30.36 x 0.166 I get 182.8 minutes which is 3:02 hours at closing.
What code can I use to create such a sensor?
I did, I created a sensor that gives me the sunset time until a few hours before sunset, then gives me the missing time, until the shutters close and then returns to give me the sunset.