Google Calendar offset with 3+ digits

I managed to get HA to notify me of Google Calendar events before they start, following guidance from: Help me wrap my head around Google Calendar

However, the offset variable seems to only take 2 digits. For example, naming an event “Blah blah !!-30” works fine and I get notified 30 mins before the event. If you switch that to “blah blah !!-360” then it fails. If I looks in the state of the event, it parses the name as “blah blah 0”, so it seems to set the offset at -36.

I would really like some notifications a few hours before the event as I have some all day events that I’d like to be notified of at 6pm the previous day.

What can I do about this?

Edit: it seems the “!!-360” is interpreted as 36 minute offset as I just received a notification, 36 minutes before the event.

do you have example yaml? for me to help

The only bit of relevant yaml is probably the google_calendar.yaml entry:

- cal_id: [email protected]
  entities:
  - device_id: house
    name: House
    track: true
    offset: "!!"

Having a Google Calendar event named “My Event !!-100” then feeds into HA with the message “My Event 0”, which appears to have parsed the “!!-10” and then left a 0 behind. This will then set the offset to 10 minutes rather than 100 minutes.

I’ve looked through the docs and all i’m seeing is to create a sensor with your event start time:

  - platform: template
    sensors:
      cal_start_time:
        value_template: '{{ states.calendar.house.attributes.start_time }}'
        friendly_name: 'Start Time'

Then using that sensor, build automatons off that. You can use JSON/JINJA to create offsets by subtracting any amount you want inside a value_template.

I’ve never used this add on, so take my suggestions with a grain of salt.

I actually managed to hunt down and adapt a solution posted elsewhere. The first time I read it I couldn’t understand, so I’ve posted my version in case any one else is struggling: Google Calendar event offset

Unfortunately, the solution seems to rely on the entity_id option within the sensor template, so that the maths gets updated every minute. This is being deprecated and I’m not sure what to do after.

I think your solution would also need to be run more often? If it only runs when the start_time changes then the sensor won’t change from off to on. Any ideas about that?

You can build automations off state changes. I do not know how this google calendar integrates into hass. The example I read through led me to believe that the start time was reported in advance. Otherwise, i would have no idea how it works. I haven’t thought about integrating google calendar into hass yet. This may give me an excuse to try though! Sorry if I added to your confusion but I don’t think I’m gonna be any help.

Don’t worry, it’s good to discuss everything!

The start time is given I’m advance. HA gets the details of the next event in each calendar (every 15 mins). This means the value of start_time will change once a old event is finished and the next one is loaded and ready. Start_time won’t change again until the event is finished and the next event is loaded. I think this means that the state of the template sensor (getting its value from the start_time) won’t update very often either.

So if we’re building a comparison that needs to run X minutes before start_time, then it needs to check this every minute, not just when the state changes.

The entity_id solution works for now, but will stop working in a few updates I guess :frowning:

Not necessarily. Do you expect your start times to change alot? If they don’t change much, home assistant will create an event that will fire at a specific time and it wont need to see the start time again… unless the start time changes.

The start time won’t change at all for me, which is a problem for the solution I currently have. I don’t understand how “home assistant will create an event that will fire at a specific time”, how can I achieve that?

The way I have it relies on some maths happening every minute to check if we meet the offset yet.

good question. I was thinking about the time platform. I’ll have to think about this.

The solution linked below has sorted everything for me. It doesn’t use the offset parameter of the calendar, rather a sensor that updates each minute.