Skip to content

[Bug]: Leap Year Issue #1844

Closed
Closed
@armin-gh

Description

@armin-gh

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions