Automation giving false alerts when reading Google Calendar

Hello folks,

strange one here, I have a google calendar that I use to record my work shifts. I have an automation that runs to check if I am on an Early shift and will then turn on some lights.

After reading some stuff on the forum, I changed the way I checked the camera to make it simpler.

What I have noticed that the last few days it has been telling me I am on an early shift. I have no entries in my calendar as I am on my rest days, and my next shift is an early one and is in 2 days time. So it appears that it is reading my calendar until it finds an entry and then does the comparison.

Is this normal behaviour? Am I doing something wrong?

thanks

Calendars by default show you the next calendar event

You removed the start_time condition which tells you when the event is starting. So removing that condition was unwise as it verified that the start of the event is occurring “today”

oh ok, so I add a start time then it will just look at that day?

When you removed the conditon you basically removed a filter that said: Is the event today? Now your automation doesn’t have that.

I have the trigger which is time and set for 04:45 so do I need a condition for the same time as well?

no, you just need a condition that verifies that the event is occurring today.

Sorry, I’m probably being stupid here :upside_down_face:. I understand what you mean about a condition that verifies the event is occurring today, but not sure how that is put into the automation.

This is what I have

- id: '1633198910437'
  alias: Test - Calendar Event Check
  description: ''
  trigger:
  - platform: time
    at: 06:00
  condition:
  - condition: state
    entity_id: calendar.myshifts
    state: Earlies
    attribute: message
  action:
  - service: script.broadcast_onlyme
    data:
      title: Test Notification
      message: Testing new calendar event check - {{now().strftime('%H:%M')}}

Just use the condition you had before, unless it wasn’t working.

I.e. You didn’t make it simpler, you broke it. Just revert this change.

oh ok. Yes that is working. But that method means creating a sensor for that particular event in my calendar, which isn’t a problem. However I read up that a simpler way of doing this was to use the method I changed to because then I search for anything and use it for other purposes with my calendar.

I don’t follow you, your condition checks the attribute from the calendar, no extra sensor needed.

So when I originally set this up which was a good year or so ago, the instructions I followed required me to create a google_calenders.yaml.

- cal_id: [email protected]
  entities:
  - device_id: mycal_catchall
    ignore_availability: true
    name: Everything
    track: true

  - device_id: test_earlies
    ignore_availability: true
    name: Earlies
    track: true
    search: Earlies

  - device_id: test_days
    ignore_availability: true
    name: Days
    track: true
    search: Days
    
  - device_id: test_lates
    ignore_availability: true
    name: lates
    track: true
    search: Lates
    
  - device_id: test_nights
    ignore_availability: true
    name: Nights
    track: true
    search: Nights

That is why the original code searches a particular attribute

- condition: template
    value_template: '{{ ((as_timestamp(states.calendar.test_earlies.attributes.start_time)
      - as_timestamp(now())) < 0)}}' 

Which is why i was trying to move to the new method. Sorry Its hard to describe something a little complex :slight_smile:

Yes, but I still don’t see what you’re talking about with the attributes. You just linked the google calendar integration yaml configuration.

can you clarify what you mean by ‘attributes’

Clarify this I mean

hi petro,
So as above, in the google_calendars.yaml I had to add the entries listed in order to search to. It might be that I am using the wrong terminology.
In order to search for my early shift, I use the value_template mentioned above.

That is why I was trying to use the state condition as it appears you don’t need to add any additional yaml.

Ok, it is your terminology. You do need that extra condition.

ok, I will revert back to the original working version.
thank you for your time Petro.