ical-sensor-homeassistant icon indicating copy to clipboard operation
ical-sensor-homeassistant copied to clipboard

Duplicate entries?

Open slurpey opened this issue 3 years ago • 8 comments

Hi, I'm having lots of duplicate entries - while in the calendar, they are not.
image image

Any suggestions? Thanks

slurpey avatar Feb 24 '22 10:02 slurpey

I often have your problem, duplicates.

immagine

pex81 avatar Mar 22 '22 11:03 pex81

Please enable debug of the ical-component and add some (anonymized) logs here,

Olen avatar Mar 22 '22 13:03 Olen

Now I have updated an event on my calendar, pushing it from one day to another.

this is my log.

2022-03-24 14:32:51 DEBUG (MainThread) [custom_components.ical.sensor] Running ICalSensor async update for Is********628
2022-03-24 14:32:51 DEBUG (MainThread) [custom_components.ical.sensor] Adding event Is********628 - Start 2022-03-24 00:00:00+01:00 - End 2022-03-25 00:00:00+01:00 - as event 0 to calendar Is********628
2022-03-24 14:32:51 DEBUG (MainThread) [custom_components.ical.sensor] Running ICalSensor async update for Co********891
2022-03-24 14:32:51 DEBUG (MainThread) [custom_components.ical.sensor] Adding event Co********891 - Start 2022-03-28 00:00:00+02:00 - End 2022-03-29 00:00:00+02:00 - as event 1 to calendar Co********891
2022-03-24 14:32:51 DEBUG (MainThread) [custom_components.ical.sensor] Running ICalSensor async update for Mac********415
2022-03-24 14:32:51 DEBUG (MainThread) [custom_components.ical.sensor] Adding event Mac********415 - Start 2022-03-29 00:00:00+02:00 - End 2022-03-30 00:00:00+02:00 - as event 2 to calendar Mac********415
2022-03-24 14:32:51 DEBUG (MainThread) [custom_components.ical.sensor] Running ICalSensor async update for Ag********532
2022-03-24 14:32:51 DEBUG (MainThread) [custom_components.ical.sensor] Adding event Ag********532 - Start 2022-03-31 00:00:00+02:00 - End 2022-04-01 00:00:00+02:00 - as event 3 to calendar Ag********532
2022-03-24 14:32:51 DEBUG (MainThread) [custom_components.ical.sensor] Running ICalSensor async update for Co********891
2022-03-24 14:33:21 DEBUG (MainThread) [custom_components.ical.sensor] Running ICalSensor async update for Is********628
2022-03-24 14:33:21 DEBUG (MainThread) [custom_components.ical.sensor] Adding event Is********628 - Start 2022-03-24 00:00:00+01:00 - End 2022-03-25 00:00:00+01:00 - as event 0 to calendar Is********628
2022-03-24 14:33:21 DEBUG (MainThread) [custom_components.ical.sensor] Running ICalSensor async update for Co********891
2022-03-24 14:33:21 DEBUG (MainThread) [custom_components.ical.sensor] Adding event Co********891 - Start 2022-03-28 00:00:00+02:00 - End 2022-03-29 00:00:00+02:00 - as event 1 to calendar Co********891
2022-03-24 14:33:21 DEBUG (MainThread) [custom_components.ical.sensor] Running ICalSensor async update for Mac********415
2022-03-24 14:33:21 DEBUG (MainThread) [custom_components.ical.sensor] Adding event Mac********415 - Start 2022-03-29 00:00:00+02:00 - End 2022-03-30 00:00:00+02:00 - as event 2 to calendar Mac********415
2022-03-24 14:33:21 DEBUG (MainThread) [custom_components.ical.sensor] Running ICalSensor async update for Ag********532
2022-03-24 14:33:21 DEBUG (MainThread) [custom_components.ical.sensor] Adding event Ag********532 - Start 2022-03-31 00:00:00+02:00 - End 2022-04-01 00:00:00+02:00 - as event 3 to calendar Ag********532
2022-03-24 14:33:21 DEBUG (MainThread) [custom_components.ical.sensor] Running ICalSensor async update for Co********891

Right now in my case the duplicates are

  • sensor.ical_halley_event_2 And
  • sensor.ical_halley_event_4

image

pex81 avatar Mar 24 '22 13:03 pex81

In your screenshot, event 2 and event 4 have different dates.

An issue here is that the events SHOULD have been ordered by their start, so event 4 should actually have been event 1. But that is not the same as a duplicate.

What MIGHT have happened is that event 4 has been changed with a new start date, and then event 2 has been created, while event 4 is just lingering and should have been removed altogether.

Olen avatar Mar 24 '22 14:03 Olen

Just to be sure... Do you have calendars with less than 5 entries in them?

I have never had that, so this might be the reason I have never seen the issue. But I do have a hunch that it might be part of the problem.

I pushed a fix that I THINK should have fixed this problem about a month ago https://github.com/tybritten/ical-sensor-homeassistant/commit/c95fb135c9e0035c583b2e6acbd080b236f8b8f1

But there has not been a new release, so it might not have been installed in your systems.

Olen avatar Mar 24 '22 14:03 Olen

Just to be sure... Do you have calendars with less than 5 entries in them?

I have never had that, so this might be the reason I have never seen the issue. But I do have a hunch that it might be part of the problem.

I pushed a fix that I THINK should have fixed this problem about a month ago c95fb13

But there has not been a new release, so it might not have been installed in your systems.

I have a single calendar with max 5 events. The default configuration used when installing the custom component This is my version.

image

pex81 avatar Mar 24 '22 14:03 pex81

Today I have the same duplicate event, but if I restart the home assistant it works fine again.

Unfortunately I have disabled the logs.

image

pex81 avatar Apr 01 '22 11:04 pex81

As I have tried to explain earlier, I am pretty sure this is due to the calendar having less than 5 events in the near future. The problem is that at first run, it creates (up to) 5 sensors of the first (up to) 5 events in the calendar. When event 0 passes, sensor_1 is moved to 0, sensor_2 is moved to 1, sensor_3 is moved to 2 and so on. But if there is no event 3, sensor_2 does not get replaced by anything, and it is also not removed (or replaced with "nothing") as it should be. And so sensor_2 keeps hanging around until there is a at least 3 events in the calendar, so sensor_2 can be overwritten with a new event again.

As stated above, this should be fixed in https://github.com/tybritten/ical-sensor-homeassistant/commit/c95fb135c9e0035c583b2e6acbd080b236f8b8f1 which will be part of a new release, whenever that happens.

Olen avatar Apr 04 '22 06:04 Olen