RESOLVED - Google Calendar based lights

I have worked on this some more to clean it up and improve the functionality, I no longer need separate calendars. I can search within one calendar now. I still can’t get the offset to work though, so I have moved my timers in the calendar to 8:30PM.

configuration.yaml

# Track calendar false is needed to prevent Hass from overwriting the google_calendar.yaml file.
google:
  client_id: id.apps.googleusercontent.com
  client_secret: password
  track_new_calendar: false

input_boolean:        
  early_shift:
  late_shift:

google_calendars.yaml

- cal_id: [email protected]
  entities:
  - device_id: early_shift
    name: Early Shift
    track: true
    search: "#early_shift"
  - device_id: late_shift
    name: Late Shift
    track: true
    search: "#late_shift"

automations.yaml

# Clear previous days booleans
- alias: Reset Daily Booleans
  trigger:
    - platform: time
      at: '20:00:00'
  action:
    - service: homeassistant.turn_off
      entity_id:
        - input_boolean.early_shift
        - input_boolean.late_shift

# Set Booleans from calendar
- alias: Early Shift
  trigger:
    - platform: state
      entity_id: calendar.early_shift
      to: 'on'
  action:
    - service: input_boolean.turn_on
      entity_id: input_boolean.early_shift

- alias: Late Shift
  trigger:
    - platform: state
      entity_id: calendar.late_shift
      to: 'on'
  action:
    - service: input_boolean.turn_on
      entity_id: input_boolean.late_shift
 
# Automation for when to turn lights off after going bed.
# Time for bed...
- alias: "LightsOutBedEarly"
  trigger:
    platform: time
    at: '22:15:00'
  condition:
    condition: state
    entity_id: input_boolean.early_shift
    state: 'on'
  action:
    service: homeassistant.turn_off
    entity_id: group.AllLights

- alias: "LightsOutBedLate"
  trigger:
    platform: time
    at: '01:00:00'
  condition:
    condition: state
    entity_id: input_boolean.late_shift
    state: 'on'
  action:
    service: homeassistant.turn_off
    entity_id: group.AllLights

# Automation for when to turn lights off when going to work.
# Time for work...
- alias: "LightsOutWorkEarly"
  trigger:
    platform: time
    at: '05:20:00'
  condition:
    condition: state
    entity_id: input_boolean.early_shift
    state: 'on'
  action:
    service: homeassistant.turn_off
    entity_id: group.AllLights

- alias: "LightsOutWorkLate"
  trigger:
    platform: time
    at: '12:40:00'
  condition:
    condition: state
    entity_id: input_boolean.late_shift
    state: 'on'
  action:
    service: homeassistant.turn_off
    entity_id: group.AllLights

# Automation for when to turn lights on in the mornings.
# Time to get up earlies...
# Condition ideally needs to check light lux for summer months, no need for kitchen
# lights then.
- alias: "LightsOnMorningEarly"
  trigger:
    platform: time
    at: '04:45:00'
  condition:
    condition: state
    entity_id: input_boolean.early_shift
    state: 'on'
  action:
    - service: homeassistant.turn_on
      entity_id: group.HallLights
    - delay: 00:00:10
    - service: homeassistant.turn_on
      entity_id: group.LivingRoomLights
    - delay: 00:00:10
    - service: homeassistant.turn_on
      entity_id: light.KitchenCeiling

Hopefully this will help someone out who is trying to get lights etc working from a calendar. I needed my lights to be different each week as I work shifts. My calendar triggers at 8:30PM the day before. So when I work Mon - Fri my calendar is Sun - Thurs, unless I work overtime on Sat, then I put an overtime trigger into the calendar on Fri. I did it this was so I could trigger lights before going bed and when I get up.

3 Likes