I would like to trigger my front outside lights to turn on when I have guests coming over and it’s going to be dark either when they arrive or when they leave.
I was hoping to use the integration to Google Calendar and basically toggle this off the location of an event on the calendar. If the location is set to my home address, then let HA assume that means guests are coming over to my place.
I know how to write an automation to turn lights on based on sunset and I know how to write on based on turning lights on when a calendar even starts.
What I can’t figure out is the overlap between the two and permutations involved. E.g., if they arrive while the sun is up but leave when it is dark. Or if it is dark for an hour before they arrive, how do I turn the lights on 15 minutes before they get here?
I guess what I can’t figure out is how to have HA check if there’s an event at my home sometime this evening at sunset, or to check if the sun will set during an event at my home.
This is as far as I got:
trigger:
- platform: calendar
event: start
offset: '-0:15:0'
entity_id: calendar.our_family_block_both
condition:
- condition: and
conditions:
- condition: state
entity_id: climate.main_floor_thermostat
attribute: preset_mode
state:
- Home
- Sleep
- condition: template
value_template: '{{ ''123 Somewhere St'' in trigger.calendar_event.location }}'
action:
- choose:
- conditions:
- condition: sun
after: sunset
- condition: state
entity_id: calendar.our_family_block_both
attribute: location
state: 123 Somewhere St
sequence:
- service: scene.turn_on
target:
entity_id: scene.outside_lights_normal_on
metadata: {}
mode: single