franc6 / ics_calendar

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

State is not on when event is active #84

Open albinmedoc opened 1 year ago

albinmedoc commented 1 year ago

Hello! Using other calendar integration the state of the entity is 'on' when there is an ongoing event. When using ics_calendar integration the state is only active some minutes, even if the event is multiple hours.

See the attached images. The event is between 11:30 - 14:50 but the state was only 'on' between 11:30:40 - 11:34:41 (4 minutes)

Skärmavbild 2023-01-24 kl  11 37 54 Skärmavbild 2023-01-24 kl  11 37 21
bearpawmaxim commented 1 year ago

Hi @albinmedoc! Looks like the event is on until the calendar updates from the internet?

franc6 commented 1 year ago

@albinmedoc I haven't seen this before. Can you share a sample ICS file (it's OK if the dates/times are in the past)? Just please remove any sensitive information from the file before sharing it. If you don't want to post it to GItHub, you can also send it to me in a private message to franc6 on https://community.home-assistant.io/ That will help me track down what's going wrong, and include a test to ensure it stays fixed.

albinmedoc commented 1 year ago

Down is a small sample ICS file. (I have shortened it and removed sensitive information)

BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
CALSCALE:GREGORIAN
X-WR-CALNAME:TimeCenter Matilda Takkula
PRODID:-//TimeCenter//EN
X-WR-TIMEZONE:Europe/Stockholm
BEGIN:VEVENT
DTSTART:20230108T070000Z
DTEND:20230108T100000Z
SUMMARY:Semester  (Färg & slingor av långt hår med klippning\, 180 min)
UID:24345762
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230108T070000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230109T070000Z
DTEND:20230109T100000Z
SUMMARY:Semester  (Färg & slingor av långt hår med klippning\, 180 min)
UID:24345763
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230109T070000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230111T070000Z
DTEND:20230111T100000Z
SUMMARY:Semester  (Färg & slingor av långt hår med klippning\, 180 min)
UID:24345766
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230111T070000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230112T070000Z
DTEND:20230112T100000Z
SUMMARY:Semester  (Färg & slingor av långt hår med klippning\, 180 min)
UID:24345767
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230112T070000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230113T070000Z
DTEND:20230113T100000Z
SUMMARY:Semester  (Färg & slingor av långt hår med klippning\, 180 min)
UID:24345768
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230113T070000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230114T070000Z
DTEND:20230114T100000Z
SUMMARY:Semester  (Färg & slingor av långt hår med klippning\, 180 min)
UID:24345769
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230114T070000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230115T070000Z
DTEND:20230115T100000Z
SUMMARY:Semester  (Färg & slingor av långt hår med klippning\, 180 min)
UID:24345770
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230115T070000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230116T073000Z
DTEND:20230116T080000Z
SUMMARY:Ulla Nilsson (Klippning\, 30 min)
UID:24809631
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230116T073000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230116T090000Z
DTEND:20230116T093000Z
SUMMARY:(Klippning\, 30 min)
UID:24926965
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230116T090000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230116T100000Z
DTEND:20230116T103000Z
SUMMARY:(Klippning\, 30 min)
UID:24989744
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230116T100000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230116T130000Z
DTEND:20230116T151500Z
SUMMARY:(Helfärg av långt hår med klippning\, 135 min)
UID:24917367
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230116T130000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230116T153000Z
DTEND:20230116T160000Z
SUMMARY:(Klippning\, 30 min)
UID:24891006
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230116T153000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230116T161500Z
DTEND:20230116T181500Z
SUMMARY:(Bottenfärg med klippning\, 120 min)
UID:24723273
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230116T161500Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230116T181500Z
DTEND:20230116T184500Z
SUMMARY:(Klippning 8-15år\, 30 min)
UID:24922623
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230116T181500Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230117T150000Z
DTEND:20230117T170000Z
SUMMARY:(Bottenfärg med klippning\, 120 min)
UID:24762963
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230117T150000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230117T170000Z
DTEND:20230117T173000Z
SUMMARY:(Klippning\, 30 min)
UID:24926322
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230117T170000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230117T174500Z
DTEND:20230117T180000Z
SUMMARY:(Maskin/Putsning\, 15 min)
UID:24961690
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230117T174500Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230117T180000Z
DTEND:20230117T183000Z
SUMMARY:(Klippning 8-15år\, 30 min)
UID:24900931
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230117T180000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230118T073000Z
DTEND:20230118T080000Z
SUMMARY:(Klippning\, 30 min)
UID:24968023
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230118T073000Z
END:VEVENT
BEGIN:VEVENT
DTSTART:20230118T100000Z
DTEND:20230118T110000Z
SUMMARY:Månadsmöte  (Övrigt\, 60 min)
UID:24998096
CLASS:PUBLIC
SEQUENCE:0
DESCRIPTION:
DTSTAMP:20230118T100000Z
END:VEVENT
END:VCALENDAR
albinmedoc commented 1 year ago

This is how i add the calendar in configuration.yaml

platform: ics_calendar
calendars:
  - name: "Matilda jobb"
    url: !secret ics_calendar_matilda_work
    parser: "ics"
    days: 30
    user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
    exclude: "['Semester']"
franc6 commented 1 year ago

Thanks for the info. I hope to be able to look into this next month. I'm sorry for the delay.

LPirro commented 1 year ago

I'm having this issue as well. The calendar is not 'on' even if have some events.

BEBU88 commented 10 months ago

Same issue her. I'm using the Holiday Calendar for Germany from Apple iCloud. It's located here: https://p05-calendars.icloud.com/holiday/DE_de.ics

This is how I integrated it:

ics_calendar:
  calendars:
    - name: "Feiertag"
      url: "https://p05-calendars.icloud.com/holiday/DE_de.ics"
      include_all_day: True
      exclude: "['']"
      include: "['Neujahr', 'Rosenmontag', 'Karfreitag', 'Ostermontag', 'Erster Mai', 'Christi Himmelfahrt', 'Pfingstmontag', 'Fronleichnam', 'Tag der Deutschen Einheit', 'Allerheiligen', 'Heiligabend', '1. Weihnachtsfeiertag', '2. Weihnachtsfeiertag', 'Silvester']"

There are only all-day events in this calendar.

State for Christmas Eve switched to on at 00:00 a.m. and swichted back to off 15 minutes later.

Screenshot 2023-12-24 095015

papperone commented 10 months ago

I've same problem, on the event in the calendar it turns "on" at midnight then back to "off" at 1:00am. If more info or test are needed to troubleshoot let me know... immagine

papperone commented 9 months ago

any plan to fix this problem soon? basically this integration is useless unless you create additional sensors to overcome this bug...

franc6 commented 9 months ago

@albinmedoc The sample file doesn't cover the time in your initial report. @LPirro @bearpawmaxim @papperone I have spent a lot of time on this, and cannot reproduce the problem. "It works for me." :( My own ICS file is relatively static, that is, new stuff will show up, and all the old stuff is always there. You might try downloading your ICS file manually and check to be sure that old items are not dropping off too quickly. E.g. if you have an all day event, on the day of the event, download the ICS file several times throughout the day, and make sure that all day event is always there. If it's not, then that's the problem. If the event is removed from the ICS file, then this component won't keep reporting it, and the state will be 'off', and all the other attributes will be removed, too. No, I don't think this is likely to be your problem, but it's the one thing I can think of that's guaranteed to be an issue. @papperone Please post your config for this calendar, too. Feel free to change the actual URL to something that's obviously wrong.

franc6 commented 9 months ago

@albinmedoc @LPirro @bearpawmaxim @papperone Please also enable debug logs. To do this, you'll need to edit your configuration.yaml. Look for a section named "logger". If you don't have such a section, add it to the bottom of the file, along with a subsection named "logs". Under that subsection, add:

custom_components.ics_calendar: debug

So, your yaml should look something like this:

logger:
  logs:
    custom_components.ics_calendar: debug

Then, next time you notice it, download your home assistant core log file (or go for it directly, if you can), remove all lines that don't contain: "[custom_components.ics_calendar]", and post it here. If you see something that should be kept private, please redact that only by changing the private data with a single letter 'X'. If you remove any lines from the log output, it won't be very useful. I might need to add some more debug logging if that doesn't help track down the problem.

Thanks!

papperone commented 6 months ago

@albinmedoc The sample file doesn't cover the time in your initial report. @LPirro @bearpawmaxim @papperone I have spent a lot of time on this, and cannot reproduce the problem. "It works for me." :( My own ICS file is relatively static, that is, new stuff will show up, and all the old stuff is always there. You might try downloading your ICS file manually and check to be sure that old items are not dropping off too quickly. E.g. if you have an all day event, on the day of the event, download the ICS file several times throughout the day, and make sure that all day event is always there. If it's not, then that's the problem. If the event is removed from the ICS file, then this component won't keep reporting it, and the state will be 'off', and all the other attributes will be removed, too. No, I don't think this is likely to be your problem, but it's the one thing I can think of that's guaranteed to be an issue. @papperone Please post your config for this calendar, too. Feel free to change the actual URL to something that's obviously wrong.

here's my config:

ics_calendar:
  calendars:
    - name: "Festività italiane"
      url: "https://www.webcal.guru/it-IT/scarica_calendario?calendar_instance_id=66"
      include_all_day: true
      download_interval: 1440
      days: 365
      parser: "ics" 

today (and probably tomorrow) I had the issue, despite the entry in the calendar is "all day" the event stay ON only a bit more than 1h (see below) immagine

event for tomorrow seems again correct in the calendar but the behaviour is that the calendar stays on 1h or more and then turn off; I'm expecting to stay ON whole day accordingly to caledar event start/end time: immagine

papperone commented 6 months ago

to link to my previous post, this is how it shows the event of yesterday, today; no clue if it relates but now with daylight saving on the ON state last 1h more... immagine

franc6 commented 6 months ago

Thanks, @papperone! Every data point might be helpful. I did eventually see this once with my own calendar, but only once so far. It’s frustrating since I haven’t been able to reproduce it reliably, or at all under test conditions (unless I’ve got something backwards in the tests). When I get some more time again, I’ll be looking into it more. That will likely be a while. I didn’t even get back to this last month, and the next few don’t look much better for my time. Thanks for your patience.

papperone commented 6 months ago

Thanks, @papperone! Every data point might be helpful. I did eventually see this once with my own calendar, but only once so far. It’s frustrating since I haven’t been able to reproduce it reliably, or at all under test conditions (unless I’ve got something backwards in the tests). When I get some more time again, I’ll be looking into it more. That will likely be a while. I didn’t even get back to this last month, and the next few don’t look much better for my time. Thanks for your patience.

thanks for your work, at the moment I've put a workaround to read the state of the calendar every day at 00:15 and copy it on a boolean that than I use in my automation, but unfortunately if my HA reboots on a Bank Holiday (this is why I use this addon) the boolean is of course restored to "false" and I loos all my automation that are based on the fact that day is/isn't a public holiday :( if you need any test I may help with let me know

papperone commented 5 days ago

any chance to have this fixed? sorry to say but with this bug ongoing since literally months I will probably drop this integration to move to something different (manually done probably) that al least can work properly... still available to run test but if you import the calendar I'm using just for test I'm sure you should be able to replicate the issue