I’m trying to set an automation that will trigger two lights ONLY between Sunset and Sunrise.
I’m attempting to use a condition setting the parameters to Before Sunrise and After Sunset… (Automation below is HA generated not by my hand)
My motion sensor is firing ( I can see the light flash) but my two lights do not turn on.
Now… If I set the condition to a time condition 18:00 to 06:00 it works… and if I just set the condition to just “After Sunset” it works as well…
I’m at a loss… again!
id: '1564252116802'
alias: 'Auto East Patio Lights On '
trigger:
- entity_id: binary_sensor.ecolink_motion_detector_sensor_2
platform: state
to: 'on'
condition:
- after: sunset
before: sunrise
condition: sun
action:
- data:
entity_id: switch.honeywell1
service: switch.turn_on
- data:
entity_id: switch.honeywell3
service: switch.turn_on
- id: '1564254684625'
alias: Auto East Patio Lights Off
trigger:
- entity_id: binary_sensor.ecolink_motion_detector_sensor_2
platform: state
to: 'off'
condition: []
action:
- data:
entity_id: switch.honeywell3
service: switch.turn_off
- data:
entity_id: switch.honeywell1
service: switch.turn_off
I was using it like a Between…
If(sun >= sunset && sun <= sunrise)
{
// then do something
}
It works fine when I use just After: Sunset… which is the same as below_horizion I guess…
condition:
condition: or # 'when dark' condition: either after sunset or before sunrise - equivalent to a state condition on `sun.sun` of `below_horizon`
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
No it wasnt lol… I’m a coder by profession… but ymal and its dependency on spaces is maddening… the statement below is a VERY klutzy or statement… logical when you look at it but just doesn’t roll off the fingers…
I’ll try the other method just for completeness in the experiment that is HA!
Thanks for the support and advice folks… the struggle is real … lol
condition:
condition: or # 'when dark' condition: either after sunset or before sunrise - equivalent to a state condition on `sun.sun` of `below_horizon`
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise