Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Leap Year Issue #1844

Closed
3 of 7 tasks
armin-gh opened this issue Feb 29, 2024 · 11 comments
Closed
3 of 7 tasks

[Bug]: Leap Year Issue #1844

armin-gh opened this issue Feb 29, 2024 · 11 comments

Comments

@armin-gh
Copy link

I Have A Problem With:

The integration in general

What's Your Problem

Found an error this morning in the logs when the integration was trying to fetch the schedule from the server

Feb 29 01:21:31 smarthome hass[7852]: ValueError: day is out of range for month

Obvisously "end_date" is set to "same day next year", with doesn't work for February 29th
end_date = start_date.replace(year=start_date.year + 1)

Source (if relevant)

ICS

Logs

Feb 29 01:21:31 smarthome hass[7852]: 2024-02-29 01:21:31.427 ERROR (SyncWorker_9) [waste_collection_schedule.source_shell] fetch failed for source ICS:
Feb 29 01:21:31 smarthome hass[7852]: Traceback (most recent call last):
Feb 29 01:21:31 smarthome hass[7852]:   File "/home/homeassistant/.homeassistant/custom_components/waste_collection_schedule/waste_collection_schedule/source_shell.py", line 134, in fetch
Feb 29 01:21:31 smarthome hass[7852]:     entries = self._source.fetch()
Feb 29 01:21:31 smarthome hass[7852]:               ^^^^^^^^^^^^^^^^^^^^
Feb 29 01:21:31 smarthome hass[7852]:   File "/home/homeassistant/.homeassistant/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py", line 179, in fetch
Feb 29 01:21:31 smarthome hass[7852]:     return self.fetch_url(self._url, self._params)
Feb 29 01:21:31 smarthome hass[7852]:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 29 01:21:31 smarthome hass[7852]:   File "/home/homeassistant/.homeassistant/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py", line 204, in fetch_url
Feb 29 01:21:31 smarthome hass[7852]:     return self._convert(r.text)
Feb 29 01:21:31 smarthome hass[7852]:            ^^^^^^^^^^^^^^^^^^^^^
Feb 29 01:21:31 smarthome hass[7852]:   File "/home/homeassistant/.homeassistant/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py", line 215, in _convert
Feb 29 01:21:31 smarthome hass[7852]:     dates = self._ics.convert(data)
Feb 29 01:21:31 smarthome hass[7852]:             ^^^^^^^^^^^^^^^^^^^^^^^
Feb 29 01:21:31 smarthome hass[7852]:   File "/home/homeassistant/.homeassistant/custom_components/waste_collection_schedule/waste_collection_schedule/service/ICS.py", line 39, in convert
Feb 29 01:21:31 smarthome hass[7852]:     end_date = start_date.replace(year=start_date.year + 1)
Feb 29 01:21:31 smarthome hass[7852]:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Feb 29 01:21:31 smarthome hass[7852]: ValueError: day is out of range for month

Relevant Configuration

waste_collection_schedule:
  sources:
    - name: ics
      args:
        url: "https://kundenportal.avl-lb.de/WasteManagementLudwigsburg/WasteManagementServiceServlet?ApplicationName=Calendar&SubmitAction=sync&StandortID=xxxxxxxxx&AboID=yyyy&Fra=BT;RT;PT;LT;GT"

Checklist Source Error

  • Use the example parameters for your source (often available in the documentation) (don't forget to restart Home Assistant after changing the configuration)
  • Checked that the website of your service provider is still working
  • Tested my attributes on the service provider website (if possible)
  • I have tested with the latest version of the integration (master) (for HACS in the 3 dot menu of the integration click on "Redownload" and choose master as version)

Checklist Sensor Error

  • Checked in the Home Assistant Calendar tab if the event names match the types names (if types argument is used)

Required

  • I have searched past (closed AND opened) issues to see if this bug has already been reported, and it hasn't been.
  • I understand that people give their precious time for free, and thus I've done my very best to make this problem as easy as possible to investigate.
@Mart-Muc
Copy link

same here, using ics calender of (AVM München)

stopped working after update feb 20th with the same error message in log.

@just-grizzle
Copy link

Same here. First time user and thought i misconfigured it.
If it matters, there is no garbage collection planned on 2024-02-29 for my area.

@JonasDoebertin
Copy link

Same here using "Stadtreinigung Hamburg"

fetch failed for source Stadtreinigung Hamburg: Traceback (most recent call last): File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/source_shell.py", line 134, in fetch entries = self._source.fetch() ^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/source/stadtreinigung_hamburg.py", line 27, in fetch dates = self._ics.convert(r.text) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/service/ICS.py", line 39, in convert end_date = start_date.replace(year=start_date.year + 1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: day is out of range for month

@Bill-Dung
Copy link

Same for "KWU Entsorgung Landkreis Oder-Spree"

@Soulfly999
Copy link

Same isue with ics file

@fr3ddy-sudo
Copy link

Same with Mags Mönchengladbach Abfallkalender

@frosso
Copy link

frosso commented Feb 29, 2024

Date exception cases and programmers, name a better duo :) I feel the maintainer :i-know-that-feel-bro:

@MaxCRRR
Copy link

MaxCRRR commented Feb 29, 2024

Same
IMG_0217

„unknown“ & nothing in my calendar

@armin-gh
Copy link
Author

I would guess it fixes itself tomorrow.

@kargpfen
Copy link

Same here

@5ila5
Copy link
Collaborator

5ila5 commented Mar 1, 2024

Leap year error fixed in #1855. But should work normally today.

ICS helper calculated an end date by replacing the year with year +1 in the current date, which throws an error as the 2025-02-29 does not exist.

@5ila5 5ila5 closed this as completed Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.