Hi. Tell me how to turn off the light an hour after sunrise and turn it on an hour before sunset? sun Text Sensor has the number I need but how to make minus one hour.
In the sun of automation there is only elevation. And it’s not clear how I can use it.
I do not understand.
You need to set two automations, one as above to turn off the light after sunset and another one with -01:00:00 sunrise offset, to do the actions you want before sunrise.
I’m just dealing with this myself. I didn’t play with delays yet, but if i understand correct then it goes like this: for, say, one hour BEFORE sunset you have to enter positive elevation, while for delay one hour AFTER sunset you have to enter negative elevation.
I didn’ find any information how to user hours or minutes, though. But you can observe current elevation in degrees and define elevation to use from this (there’s an example for showing current elevation on esphome sun page). But i’m not sure if this elevation angle stays the same the whole year -i think it changes with summer/winter time…
You want to try the ESPHome discord, they are very helpfull and this sounds like something they would know. There is a time component in there (text_sensor) that gives the sunset and sunrise exact time to HA. If you could acces that info it would be simple to subtract or add a hour to that in an if statement.
That’s true, but the fact is that sun is higher on the sky in the summer than in the winter, so i think elevation is different, because it’s calculated regarding to your location. THIS calculator shows quite differnt maximum daily elevation now and in the April or May.
Currently in my location appr. 0.7 degrees means around 5 minutes.
You will find that no matter what location you choose outside the Arctic circles the elevation an hour after sunset only varies by about 2 degrees, in the case of the default suncalc position of Madrid, it varies between about 10 and 12 degrees. So if you set the lights to go on when the sun is at elevation of 11 degrees, you will be very close. It won’t be seconds (or even minutes) accurate, but it will be close.
You’re probably right. I did some test calculation on that page i noticed that now (autmn) highest sun is appr. 40deg, while in high summer it will be at good 60 deg. But, as you said, at morning and evening there shouldn’t be much difference. I really don’t care much if lights start to turn on somewhat early and stop a bit later when it’s already day, so elevation is more than enough accurate.
@lordzid: that is an option, sure, but not if you want to make HA indepentent automation. I tried with HA automations first and it works perfectly, but at the end i rather decided to control light from esphome module only. Just in case if server goes down….etc… lights will still turn on at movement. Although in appr. one year of running HA i didn’t experience problem yet. Knocking on wood….