Automations and Google calendar

I have roller blinds in the bedroom with an automation that closes them every evening at sunset.

The Google calendar is integrated in the home assistant, one of the calendars is a ‘work’ calendar

I want to create an automation, opening the roller blinds at a certain time, except on those days where I have to work till 6 of 7 in the morning, after my night shifts. Then they have to open at another time, in the afternoon

How could I achieve this

Can you provide more details about times/schedules?
Is either “open blinds” time within the time block of your night shift?
Is there any case where you would have a night shift followed by a day shift?

The state of a calendar entity is based on the current or next calendar event which makes it somewhat limited in terms of functioning for conditional logic. You may want to consider the Hass Calendar Addon which creates a sensor containing a list of events beyond current or next.

Hello Drew,
My shifts are different, i work 3 shifts and then i’m 3 days off,

the 3 working shifts,

  • 1st shift is dayshift
  • 2nd shift is day or nightshift
  • 3rd shift is an nightshift

dayshifts are from 6-18 or 7-19, nightshifts are from 18-6 or 19-7

within my google calendar i have a ‘work’ agenda

my wilfe’s mostly home, so on normal days, i would like to open the roller blinds to open around 8 or 9 in the morning

on days where i have to work till 6 or 7 in the morning, i would like them to open around 14 or 15 in the afternoon

I think the most straight-forward method is going to be to use an input boolean/toggle helper. That way, the end of your work calendar event can set the boolean, and your blinds automation can use it as a condition.

trigger:
  - platform: calendar
    event: end
    entity_id: calendar.work
    offset: "-01:00:00"
condition: []
action:
  - choose:
      - conditions:
          - condition: time
            after: "04:00:00"
            before: "07:00:00"
        sequence:
          - service: input_boolean.turn_on
            target:
              entity_id:  input_boolean.worked_night_shift
    default: 
      - service: input_boolean.turn_off
        target:
          entity_id: input_boolean.worked_night_shift
trigger:
  - platform: time
    at: "08:00:00"
    id: early
  - platform: time
    at: "14:00:00"
    id: late
condition:
  - or:
      - and:
          - condition: trigger
            id: early
          - condition: state
            entity_id: input_boolean.worked_night_shift
            state: 'off'
      - and:
          - condition: trigger
            id: late
          - condition: state
            entity_id: input_boolean.worked_night_shift
            state: 'on'
action:
  - service: cover.open_cover
    target:
      entity_id: cover.roller_blinds

Thx Digidrew,

I’m going to try it out one of the next days.