CalDav. Can HA tell the future?

I have my work schedule in my Nextcloud calendar, so I was hoping to create an automation that activates my alarm clock automation based on whether or not I have work that day.

Being a USian retail worker, “holidays” and any algorithm you can attach to them are basically meaningless, so the WorkDay sensor component isn’t really going to help me. Aside from that, my schedule changes from week to week based on various situations that arise. I make these changes in my calendar on Nextcloud.

So the problem I’m up against is that the Caldav component creates binary sensors that turn on at the moment that an event starts, and off when the event stops. If I have to be at work at 9am, I would like for Home Assistant to see that, and set my alarm for 7am. (Or just turn the alarm on because I like to wake up around that time regardless of what time I have to go to work.)

In essence, is there a way for HA to tell if a certain event is going to occur on that day, as opposed to whether or not an event is currently happening? I’m really trying to avoid creating multiple events in my calendar.

Hope this makes sense. :sunglasses:

1 Like

I haven’t used it, but I believe the attribute offset_reached is what you need, although I think to use that you have to change the title of your calendar entry.

An alternative is to make your workdays all day events, but that would mean that you lose the time when you have to be at work.

1 Like

Thanks. I submitted a change to that part of the docs because the way it’s worded is very confusing.

TBH I apparently still don’t understand, because the offset_reached setting is still not working for me…

Here’s how I have the event set in my calendar:

Calendar: Work
Event: Work !!-120

In my configuration.yaml:

    - name: 'Work'
      calendar: 'Work'
      search: 'Work'

The sensor reports an offset_reached attribute, but it’s still False up until the time that the event actually starts, regardless of the offset.

bump. I’m still having the same problem. Has anyone resolved this?

This was captured at 19:00 with an event title Test Event !!-60, and it appears to work correctly

message: Test Event 
all_day: false 
offset_reached: true 
start_time: 2018-05-16 19:55:00 
end_time: 2018-05-16 20:55:00 
location: null 
description: null 
friendly_name: Test

Does my config:

- name: 'Work'
  calendar: 'Work'
  search: 'Work'

look right to you?

It is hard to tell out of context. My configuration is

calendar:
  - platform: caldav
    url: !secret owndrive_url
    username: !secret owndrive_username
    password: !secret owndrive_password
    calendars:
      - Waste

Ah. Sorry. Here’s my full caldav config.

 - platform: caldav
   username: !secret nextcloud_un
   password: !secret nextcloud_pw
   url: !secret nextcloud_url
   custom_calendars:
     - name: 'Trash Day'
       calendar: 'Home'
       search: 'Trash Day !!-420'
     - name: 'Change Britta Filter'
       calendar: 'Home'
       search: 'Change Britta Filter'
     - name: 'Change Napoleons Water'
       calendar: 'Home'
       search: 'Change Napoleons Water'
     - name: 'Work'
       calendar: 'Work'
       search: 'Work !!-120'

So I wonder if something messes up when using custom_calendars.

I tried a test setup, and tt seemed to work for me, but I didn’t use the !!-60 in the search

calendar:
  - platform: caldav
    url: !secret owndrive_url
    username: !secret owndrive_username
    password: !secret owndrive_password
#      calendars:
#        - Waste
    custom_calendars:
      - name: 'My Test'
        calendar: Test
        search: 'Test Event'
alendar.test_my_test	off	message: Test Event
all_day: false
offset_reached: true
start_time: 2018-05-17 17:30:00
end_time: 2018-05-17 18:30:00
location: null
description: null
friendly_name: My Test

And the event title is

Test Event !!-60

I really hope the CalDav integration gets a lot of improvements.
I would like a sensor that reports all upcoming birthdays in the next 2 weeks (that would be 20160 minutes), but it does not work.

Is my configuration wrong ?

      - name: birthday_in_next_two_weeks
        calendar: 'Contact birthdays'
        search: '.*-20160'

Does offset_reached work with “.*” ?
Is there a limit for offset_reached ?

I use Nextcloud as the CalDav Server.

Maybe a crazy idea but try removing the ‘ ‘