Problem/Motivation
My city recently started to collect plastic containers, and it looks like they created a new code for it: 56
It's identified as "PACKAGESBAG" in the JSON, and labelled "Verpakkingen (zakken)" on the site.
Expected behavior
twentemilieu handling the new type.
It would also be nice if unknown types were somehow handled rather than erroring out, so it could still show the dates for known types.
Actual behavior
twentemilieu throws ValueError: 56 is not a valid WasteType
Homeassistant error trace
2024-11-28 16:25:54.976 ERROR (MainThread) [homeassistant.components.twentemilieu] Unexpected error fetching twentemilieu data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 382, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 279, in _async_update_data
return await self.update_method()
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/twentemilieu/twentemilieu.py", line 194, in update
waste_type = WasteType(pickup["pickupType"])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/enum.py", line 757, in __call__
return cls.__new__(cls, value)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/enum.py", line 1171, in __new__
raise ve_exc
ValueError: 56 is not a valid WasteType
Steps to reproduce
Request the calendar for 7553MA 1
Proposed changes
Add WasteType PACKAGESBAG = 56
Maybe catch the enum error, and convert it to something like WasteType UNKNOWN?
Additional info
JSON from https://www.twentemilieu.nl/hengelo/afval/afvalkalender
{"userMessage":{"type":null,"messageCode":0,"description":null},"ExtraOption":{"$type":"System.Dynamic.ExpandoObject, System.Core"},"dataList":[{"pickupDates":["2025-01-23T00:00:00","2024-11-28T00:00:00","2024-12-19T00:00:00"],"pickupType":2,"_pickupType":2,"_pickupTypeText":"PAPER","description":null},{"pickupDates":["2025-01-04T00:00:00","2025-01-08T00:00:00","2025-01-15T00:00:00","2025-01-22T00:00:00","2024-11-27T00:00:00","2024-12-21T00:00:00","2024-12-04T00:00:00","2024-12-11T00:00:00","2024-12-18T00:00:00"],"pickupType":56,"_pickupType":56,"_pickupTypeText":"PACKAGESBAG","description":null}],"intDataList":null,"data":null,"status":true,"messageCode":107,"pdfResponse":null,"token":null,"ID":null,"invalidParameters":null,"total":0,"messageToString":null}
Problem/Motivation
My city recently started to collect plastic containers, and it looks like they created a new code for it:
56It's identified as
"PACKAGESBAG"in the JSON, and labelled "Verpakkingen (zakken)" on the site.Expected behavior
twentemilieu handling the new type.
It would also be nice if unknown types were somehow handled rather than erroring out, so it could still show the dates for known types.
Actual behavior
twentemilieu throws
ValueError: 56 is not a valid WasteTypeHomeassistant error trace
2024-11-28 16:25:54.976 ERROR (MainThread) [homeassistant.components.twentemilieu] Unexpected error fetching twentemilieu data Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 382, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 279, in _async_update_data return await self.update_method() ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/twentemilieu/twentemilieu.py", line 194, in update waste_type = WasteType(pickup["pickupType"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/enum.py", line 757, in __call__ return cls.__new__(cls, value) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/enum.py", line 1171, in __new__ raise ve_exc ValueError: 56 is not a valid WasteTypeSteps to reproduce
Request the calendar for
7553MA 1Proposed changes
Add
WasteTypePACKAGESBAG = 56Maybe catch the enum error, and convert it to something like
WasteTypeUNKNOWN?Additional info
JSON from https://www.twentemilieu.nl/hengelo/afval/afvalkalender
{"userMessage":{"type":null,"messageCode":0,"description":null},"ExtraOption":{"$type":"System.Dynamic.ExpandoObject, System.Core"},"dataList":[{"pickupDates":["2025-01-23T00:00:00","2024-11-28T00:00:00","2024-12-19T00:00:00"],"pickupType":2,"_pickupType":2,"_pickupTypeText":"PAPER","description":null},{"pickupDates":["2025-01-04T00:00:00","2025-01-08T00:00:00","2025-01-15T00:00:00","2025-01-22T00:00:00","2024-11-27T00:00:00","2024-12-21T00:00:00","2024-12-04T00:00:00","2024-12-11T00:00:00","2024-12-18T00:00:00"],"pickupType":56,"_pickupType":56,"_pickupTypeText":"PACKAGESBAG","description":null}],"intDataList":null,"data":null,"status":true,"messageCode":107,"pdfResponse":null,"token":null,"ID":null,"invalidParameters":null,"total":0,"messageToString":null}