core: Calendar trigger not working for all-day events

The problem

I am using the Caldav integration to access a Nextcloud calendar.

When using automations, the Calendar trigger event does not fire for all-day events. It works fine for events that are not added as all-day events.

A service call to calendar.get_events returns the following:

calendar.homeoffice: events: - start: “2023-12-13T10:35:00+01:00” end: “2023-12-13T10:40:00+01:00” summary: Homeofficetest - start: “2023-12-13” end: “2023-12-14” summary: Alldaytest

The first entry with start: “2023-12-13T10:35:00+01:00” works fine, however the second entry with start: "2023-12-13 did not cause the calendar trigger event to fire.

Am I missing something or is this a bug?

Thanks Jan

What version of Home Assistant Core has the issue?

core-2023.12.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

caldav

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

alias: "CAL: HeuteHomeoffice"
description: ""
trigger:
  - platform: calendar
    event: start
    offset: "0:0:0"
    entity_id: calendar.homeoffice
    id: Anfang
  - platform: calendar
    event: end
    offset: "-0:0:0"
    entity_id: calendar.homeoffice
    id: Ende
condition: []
action:
  - if:
      - condition: trigger
        id:
          - Anfang
    then:
      - service: input_boolean.turn_on
        data: {}
        target:
          entity_id: input_boolean.heutehomeoffice
  - if:
      - condition: trigger
        id:
          - Ende
    then:
      - service: input_boolean.turn_off
        target:
          device_id: []
          area_id: []
          entity_id: input_boolean.heutehomeoffice
        data: {}
mode: parallel
max: 10

Anything in the logs that might be useful for us?

No response

Additional information

No response

About this issue

  • Original URL
  • State: open
  • Created 7 months ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

I can confirm this behavior with an iCloud calendar. All day the events do not trigger.

I was looking at the problem in a way I could easily debug. I have no idea, how home assistant handles triggers or state changes. I started with the debug output I mentioned, looked at the code in the caldav component and the went “all the way to the end”, checking until the nextcloud server. My main findings are based on a short script that uses python-caldav to determine why an all-day event and a normal event are not consistently found as active. These findings led to my conclusion, that the underlying problem at the moment is nextcloud, but that homeassistant can also do better.

In my testing, the time zones were consistent as far as I could configure them, every step of the way. Every server and application has its timezone configured to Europe/Berlin. I did not think about time zone mismatches, but that would obviously also result in the same errors. But this leads more into undefined territory, especially for all day events.

Since the original poster also has a nextcloud server, I guessed, that they have the same problem as me. I have not heard anything in the nextcloud issue.

Regarding the entity state, I have not looked deeper in the caldav component code, but it seems to me, that instead of using the local state of the calendar (if it even exists), it fires a request to the caldav server. Presumably to get the most current events. This is then repeated every so often, when the trigger is evaluated. And since the problem lies in the caldav report request, the trigger is not correctly set, even if the event is correctly shown in the calendar view

According to my tests this is not nextcloud specific. Tested it with another Caldav provider and the problem persisted.