I have this working automation however I would like it to work with an offset, so the light needs to turn on 30 minutes before the state is below_horizon.
I tried several options however none of them work. Is there anyone can give me a solution?
- id: '72057594178191520'
alias: Fietsenstallingverlichting aan
initial_state: true
trigger:
- entity_id: sensor.aeotec_zw100_multisensor_6_burglar_2
from: '0'
platform: state
to: '8'
condition:
- condition: state
entity_id: sun.sun
state: below_horizon
action:
- entity_id: switch.fibaro_system_fgs223_double_relay_switch_3
service: switch.turn_on
- id: '72057594178191520'
alias: Fietsenstallingverlichting aan
initial_state: true
trigger:
- entity_id: sensor.aeotec_zw100_multisensor_6_burglar_2
from: '0'
platform: state
to: '8'
condition:
- condition: sun
after: sunset
# -30 minutes relative to sunset, or after. (I.E. will evaluate true if the time is after 30 minutes before sunset)
after_offset: "-00:30:00"
action:
- entity_id: switch.fibaro_system_fgs223_double_relay_switch_3
service: switch.turn_on
Thanks for your reaction, for some reason the sunset option didn’t work. That’s why I use the state with below_horizon option. However I programmed it and will check it tommorow.
You won’t be able to use the below_horizon as a state because it’s not possible to know a state prior to it occuring. Unfortunately you are forced to use the sunset time for that reason (It can be calculated). You may be able to template it if the above condition does not work. I can help with that, just let me know if it doesn’t end up working.
Could it be that after midnight it stops working until the next sunset? This morning it stopped working while yesterday evening it worked. So until now I could’t check if your addition worked.
Yes, this condition will only work until midnight. If you want until sunrise:
- id: '72057594178191520'
alias: Fietsenstallingverlichting aan
initial_state: true
trigger:
- entity_id: sensor.aeotec_zw100_multisensor_6_burglar_2
from: '0'
platform: state
to: '8'
condition:
- condition: or
conditions:
- condition: sun
after: sunset
# -30 minutes relative to sunset, or after. (I.E. will evaluate true if the time is after 30 minutes before sunset)
after_offset: "-00:30:00"
- condition: sun
before: sunrise
action:
- entity_id: switch.fibaro_system_fgs223_double_relay_switch_3
service: switch.turn_on