I want this automation sends me a message i am not home between sunrise and sunset if i leave my home zone. Is this correct? Must i use condition ‘and’ or condition ‘or’ ?
- alias: 'Maurizio lascia casa'
trigger:
platform: zone
event: leave
zone: zone.home
entity_id: device_tracker.life360_maurizio
condition:
condition: or
conditions:
- condition: sun
after: 'sunrise'
- condition: sun
before: 'sunset'
action:
service: notify.telegram
data:
message: 'Nessuno a casa'
as @sholofly said above the “above_horizon” will simplify things but to answer your question…
You need to use “and” since after sunrise will be true between sunrise and the next midnight and before sunset will be true between the previous midnight and sunset. So you need to eliminate the times after sunset till midnight and after midnight till sunrise. To do that you need to have both conditions true - after sunrise “and” before sunset.