franc6 / ics_calendar

Provides an ICS (icalendar) platform for the Home Assistant calendar
Apache License 2.0
146 stars 22 forks source link

Sensor doesn’t record time until next event #103

Closed manuscho closed 10 months ago

manuscho commented 11 months ago

After updating to the latest version, the created calendar.name sensor does not include an attribute on the time until the next calendar event anymore.

My calendar now only has the attributes „friendly_name“ and „offset_reached“, even though the next event is correctly displayed in the calendar tab.

Any advice on what might cause that? Thanks!

franc6 commented 11 months ago

I'm pretty sure that's the way the calendars work in HA. If there's no event that's already started, the attributes for the event aren't there. If you've seen different behavior in the past, then I'm confused. :(

manuscho commented 11 months ago

Thanks for the swift reply, maybe it was the update of HA and not the addon.

I'm am using the same formular as in this post: Template Guide: Days away from calendar event. It worked perfectly until a few days ago.

franc6 commented 11 months ago

I really don't see how that would work with anything but an explicit date. As far as I know, HA behavior hasn't changed in years with regards to calendars. I have several calendars that don't use this component, and they're all the same. Unless the event is going on right now, the only attributes are offset_reached and friendly_name. There's nothing this component can do, AFAIK, to elicit any other type of behavior in HA. Note that I don't use google calendars (I personally think it's insane to give something like HA access to a google account, or vice-versa), but I've looked at the code that HA has for google calendars, and haven't seen anything different. I'll take another look, in case there's something new there, as it's been several months since I last checked it...

franc6 commented 11 months ago

I think I see what's going on. Looking at the new local calendar code helps. So, the current event is returned in a property whose comment has been """Return the next upcoming event.""" for quite some time. However, in caldav, it returns only a current event (it's pretty explicit in the code that's what it's doing). When I looked in the past, that seems to be what the google code was doing, too. The google code has changed a lot, and I think it's now doing what the comment says, returning the next upcoming event. I wonder if it's returning a current event if one is current, or always an upcoming event. The local calendar code is a little simpler to read, so I'll have to determine which it is doing.

This is now officially a bug. I'll have to modify my code to return data for event based on what local calendar is doing. :)

manuscho commented 11 months ago

Awesome, thank you! This has been a really helpful feature, glad it might come back :)

franc6 commented 11 months ago

OK, I've forgotten all about different features added. Try setting "days=X" in the configuration where X > 1. I'd suggest maybe setting "days=7". If that doesn't work, and you have an event < 7 days away, let me know, please.

manuscho commented 11 months ago

Thanks, adding the days in the config actually did the trick - Now it all seems to work again!