core icon indicating copy to clipboard operation
core copied to clipboard

Calendar - get_events action returns all day events that at not in the period specified

Open JonLaliberte opened this issue 1 year ago • 12 comments

The problem

The get_events action returns all day events that are not within the period specified.

For example, if I do:

action: calendar.get_events
target:
  entity_id:
    - calendar.family
data:
  start_date_time: "2024-08-29 00:00:00"
  end_date_time: "2024-08-29 23:59:59"

I get Response:

calendar.family:
  events:
    - start: "2024-08-30"
      end: "2024-08-31"
      summary: No School

My timezone is UTC-4, so I tested subtracting 4 hours from my end_date_time, so I set it to 19:59:59 and this fixes it. If I move forward another hour (20:59:59), the next day's events start showing up again.

My guess would be that all day calendar events(?) get interpreted as UTC or something? If so, then "2024-08-30 00:00:00" would become "2024-08-29 20:00:00" in my timezone. Then the filter is applied and catches it?

What version of Home Assistant Core has the issue?

core-2024.8.2

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

Calendar

Link to integration documentation on our website

https://www.home-assistant.io/integrations/calendar/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

JonLaliberte avatar Aug 29 '24 20:08 JonLaliberte

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (calendar) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of calendar can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign calendar Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


calendar documentation calendar source (message by IssueLinks)

home-assistant[bot] avatar Aug 29 '24 20:08 home-assistant[bot]

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Issue is still there

Yeahoover avatar Nov 27 '24 21:11 Yeahoover

Yes, the problem still exists, confirmed just now on 2024.11.3.

I haven't tested this, but I also wonder if specific implementations of calendars store their time in local time, or if they all store their data in UTC (this would make the most sense to me, but IDK). Anyway, if it helps anyone debug this, I'm using CalDav via iCloud with my calendar integration.

JonLaliberte avatar Nov 27 '24 21:11 JonLaliberte

Can confirm, still exists for me as well.

This is my automation step:

action: calendar.get_events
metadata: {}
data:
  duration:
    hours: 0
    minutes: 1439
    seconds: 0
  start_date_time: '{{ today_at().strftime(''%Y-%m-%d %H:%M'') }}'
target:
  entity_id: calendar.south_lake_tahoe
response_variable: calendar_events

This is the step details:

Executed: December 11, 2024 at 6:58:34 PM
Result:

params:
  domain: calendar
  service: get_events
  service_data:
    duration:
      hours: 0
      minutes: 1439
      seconds: 0
    start_date_time: 2024-12-11 00:00
    entity_id:
      - calendar.south_lake_tahoe
  target:
    entity_id:
      - calendar.south_lake_tahoe
running_script: false

This returns events with a start date of tomorrow in changed variables:

calendar_events:
  calendar.south_lake_tahoe:
    events:
      - start: '2024-12-11T13:00:00-08:00'
        end: '2024-12-11T16:00:00-08:00'
        summary: Ceramics Class
      - start: '2024-12-12'
        end: '2024-12-13'
        summary: 'Trash Day: Recycling'

kneath avatar Dec 12 '24 03:12 kneath

This still happens with 2025.2.5 and is quite annoying.

It only happens to full-day events.

toabi avatar Feb 24 '25 07:02 toabi

Can you try adding a "Z" at the end of the start and end dates, to see if the issue persists? For example "2024-08-29 00:00:00Z"

abmantis avatar Feb 25 '25 19:02 abmantis

Can you confirm what is your timezone in Settings > System > General please? Also, please share which calendar integration you are using.

abmantis avatar Feb 25 '25 19:02 abmantis

@abmantis GMT-5 Eastern Time Calendar Integration: CalDav

Adding the Z to the end changed the data that is returned, and it's better, but with one oddity - it returns the previous day's all day events now.

So as a reminder, without Z:

  start_date_time: "2024-08-29 00:00:00"
  end_date_time: "2024-08-29 23:59:59"

I get:

calendar.family:
  events:
    - start: "2024-08-30"
      end: "2024-08-31"
      summary: No School

With Z:

  start_date_time: "2024-08-29 00:00:00Z"
  end_date_time: "2024-08-29 23:59:59Z"

I get:

calendar.family:
  events:
    - start: "2024-08-28"
      end: "2024-08-29"
      summary: Whatever

If I change it to: start_date_time: "2024-08-29 00:00:01Z" (note the 01 for seconds), it does what I expect and only returns events on that day, and does not include all day events from the day before or after.

JonLaliberte avatar Feb 25 '25 19:02 JonLaliberte

Adding caldav since at least two reports are on that integration.

abmantis avatar Feb 27 '25 11:02 abmantis

In beta v2025.5 still present. Integrated my Apple calendars via CalDav integration, tested both YAML and UI configuration. My timezone is +00:02:00. Using start_date_time: "{{ today_at() }}" fetches all-day events from the day before, whereas using start_date_time: "{{ today_at() + timedelta(minutes=121) }}" only fetches present day's events.

pedolsky avatar May 05 '25 05:05 pedolsky

The calendar component itself converts any ambiguous timezones to the local time so this appears to be a caldav specific bug.

allenporter avatar Jun 01 '25 02:06 allenporter

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

The issue persists.

pedolsky avatar Aug 30 '25 08:08 pedolsky

This – among other issues already marked as stale – persists.

Commenting here to keep this one from turning stale in the hope someone will eventually look into CalDav and its all-day event related issues.

Dondo11 avatar Oct 08 '25 08:10 Dondo11