Hi, I have an automation that has been working for me for a long time, but has suddenly stopped working.
The automation is simple. I want to open my roller shutters at sunrise, but not before 7:30. The automation code is:
- id: '1578575595853'
trigger:
- platform: sun
event: sunrise
- platform: time
at: "07:30:00"
condition:
- condition: time
after: '07:29:59'
- condition: state
entity_id: sun.sun
state: 'above_horizon'
action:
- service: script.subir_persianas_automatico
- data:
message: 🔼 Subiendo persianas automáticamente
service: notify.telegram_casa
Currently the sunrise time is over 7:40. The last time it worked was the day with sunrise at 7:46. Before that day it always worked fine. But now it not working.
I suppose it is not working between 7:30 and 7:45, but why? I don’t undestand which the problem is.
I suppose the sun is above_horizon when sunrise trigger the automation because, if not so, the automation would never have worked. Three days ago, and all the previous days, the automation have worked perfectly
and have you tried using this sunrise condition instead of state condition?
I think that’s your issue - you’re trying to combine event: sunrise with sun.sun: above_horizon, but it might be not the same and your condition blocks action…
- id: '1578575595853'
alias: Subir persianas automáticamente
description: Sube las persianas cuando sale el sol
trigger:
- platform: sun
event: sunrise
- platform: time
at: "07:30:00"
condition:
- condition: sun
after: sunrise
- condition: time
after: '07:29:59'
action:
- service: script.subir_persianas_automatico
if it doesn’t work, you might need to do with condition: sun something similar to what you’ve done with condition: time - as per example there, `after_offset: “-00:01:00”
Technically, sunrise and sunset occur when the sun’s elevation is - 0.83 degrees below the horizon. This is so the tip of the sun is just about level with the horizon.
The 0.83 is made up of two components 1. The angular radius of the sun 2. The lens effect of the Earth’s atmosphere which tends to make it look higher than it actually is (at low elevations)
This is used by Phil in his enhanced sun component (and in sun.sun too)
You could write ‘07:30:00’ here as ‘after’ actually means >= not just > so it keeps the code easier on the eye (funnily enough Phil corrected me on that quite recently too )
You are right. I had 7:30 but i changed it testing if this could be the problem (no sense, but you know, testing all possibilities when something doesn’t work )