I’m looking to turn the front porch lights on when I come home using OwnTracks and a Zone. When I enter the home zone after sunset, turn the lights on, wait 4 minutes, then turn them off.
I see the tracker as home, but never turned the lights on. Does this look correct?
- alias: Lights - Front Porch - Come Home After Sunset
trigger:
platform: zone
entity_id: device_tracker.phone_capo
zone: zone.home
event: enter
condition:
condition: sun
after: sunset
action:
- service: light.turn_on
data:
brightness: 255
entity_id:
- light.porch
- delay: '00:04:00'
- service: light.turn_off
data:
entity_id:
- light.porch
trigger:
platform: state
entity_id: device_tracker.XXXX
to: 'home'
condition:
- condition: sun
after: sunset
after_offset: "-00:45:00"
a negative after_offset means up to 45min before sunset is valid too
a positive after_offset means from 45min after sunset is ok
Edit:
Actualy I combine it with “condition: or” so I can have that offset when weather is bad. Bad weather usualy means it’s dark earlier that day. When weather is good I don’t need it.
- condition: or
conditions:
- condition: and
conditions:
- condition: or
conditions:
- condition: sun
after: sunset
after_offset: "-00:45:00"
- condition: sun
before: sunrise
before_offset: "00:45:00"
- condition: numeric_state
entity_id: sensor.yr_symbol
above: '1'
- condition: or
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
Thanks for the feedback. I tried modifying mine to be more simpler. I think there is an issue with MQTT, so I will create a new thread. Thanks for your help everyone.