Repository: mampfes/hacs_waste_collection_schedule

Issue:
[Bug]: date time issue
### I Have A Problem With:

The integration in general

### What's Your Problem

Used to work. No change in cfg.
At some point, after an upgrade…
Integration fails while starting. See log.

### Source (if relevant)

_No response_

### Logs

```Shell
Denne feilen stammer fra en tilpasset integrasjon.

Logger: waste_collection_schedule.source_shell
Source: custom_components/waste_collection_schedule/waste_collection_schedule/source_shell.py:136
Integration: waste_collection_schedule (documentation)
First occurred: 19:02:11 (1 occurrences)
Last logged: 19:02:11

fetch failed for source Stavanger Kommune: 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/stavanger_no.py", line 63, in fetch date = datetime.strptime(date[0] + "." + year, "%d.%m.%Y").date() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/_strptime.py", line 568, in _strptime_datetime tt, fraction, gmtoff_fraction = _strptime(data_string, format) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/_strptime.py", line 534, in _strptime julian = datetime_date(year, month, day).toordinal() - \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ValueError: day is out of range for month
```


### Relevant Configuration

```YAML
name: stavanger_no

municipality: Stavanger
```


### 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)
- [X] Checked that the website of your service provider is still working
- [X] Tested my attributes on the service provider website (if possible)
- [X] 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

- [X] I have searched past (closed AND opened) issues to see if this bug has already been reported, and it hasn't been.
- [X] 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.


Discussion:

Resolving patch:
diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py
--- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/stavanger_no.py
@@ -51,14 +51,12 @@ def fetch(self):
         soup = BeautifulSoup(r.text, "html.parser")
 
         tag = soup.find_all("option")
-        year = tag[0].get("value").split("-")
-        year = year[1]
-
         entries = []
         for tag in soup.find_all("tr", {"class": "waste-calendar__item"}):
             if tag.text.strip() == "Dato og dag\nAvfallstype":
                 continue
 
+            year = tag.parent.attrs["data-month"].split("-")[1]
             date = tag.text.strip().split(" - ")
             date = datetime.strptime(date[0] + "." + year, "%d.%m.%Y").date()
 


Test patch: