Repository: mampfes/hacs_waste_collection_schedule

Issue:
[Bug]: Bad sepan_remondis_pl API link
### I Have A Problem With:

A specific source

### What's Your Problem

After 2023, sepan_remondis_pl changed the website address by adding 2024
2023: https://sepan.remondis.pl/harmonogram
2024: https://sepan.remondis.pl/harmonogram2024
integration doesn't get the correct terms

just update api url from  API_URL = "https://sepan.remondis.pl/harmonogram" to API_URL = "https://sepan.remondis.pl/harmonogram2024"

### Source (if relevant)

sepan_remondis_pl

### Logs

_No response_

### Relevant Configuration

```YAML
API_URL = "https://sepan.remondis.pl/harmonogram2024"
```


### Checklist Source Error

- [X] 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

- [X] 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/sepan_remondis_pl.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/sepan_remondis_pl.py
--- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/sepan_remondis_pl.py
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/sepan_remondis_pl.py
@@ -4,7 +4,7 @@
 import xml.etree.ElementTree
 
 import requests
-from waste_collection_schedule import Collection
+from waste_collection_schedule import Collection  # type: ignore[attr-defined]
 
 TITLE = "Poznań/Koziegłowy/Objezierze/Oborniki"
 DESCRIPTION = "Source for Poznań/Koziegłowy/Objezierze/Oborniki city garbage collection"
@@ -20,7 +20,7 @@
 _LOGGER = logging.getLogger(__name__)
 
 
-API_URL = "https://sepan.remondis.pl/harmonogram"
+API_URL = "https://sepan.remondis.pl/harmonogram{}"
 
 NAME_MAP = {
     1: "Zmieszane odpady komunalne",
@@ -50,7 +50,16 @@ def __init__(self, city, street_name, street_number):
         self._street_number = street_number.upper()
 
     def fetch(self):
-        r = requests.get(f"{API_URL}/addresses/cities")
+        try:
+            return self.get_data(API_URL.format(datetime.datetime.now().year))
+        except Exception:
+            _LOGGER.debug(
+                f"fetch failed for source {TITLE}: trying different API_URL ..."
+            )
+            return self.get_data(API_URL.format(""))
+
+    def get_data(self, api_url):
+        r = requests.get(f"{api_url}/addresses/cities")
         r.raise_for_status()
         city_id = 0
         cities = json.loads(r.text)
@@ -60,7 +69,7 @@ def fetch(self):
         if city_id == 0:
             raise Exception("city not found")
 
-        r = requests.get(f"{API_URL}/addresses/streets/{city_id}")
+        r = requests.get(f"{api_url}/addresses/streets/{city_id}")
         r.raise_for_status()
         street_id = 0
         streets = json.loads(r.text)
@@ -70,7 +79,7 @@ def fetch(self):
         if street_id == 0:
             raise Exception("street not found")
 
-        r = requests.get(f"{API_URL}/addresses/numbers/{city_id}/{street_id}")
+        r = requests.get(f"{api_url}/addresses/numbers/{city_id}/{street_id}")
         r.raise_for_status()
         number_id = 0
         numbers = json.loads(r.text)
@@ -80,7 +89,7 @@ def fetch(self):
         if number_id == 0:
             raise Exception("number not found")
 
-        r = requests.get(f"{API_URL}/reports?type=html&id={number_id}")
+        r = requests.get(f"{api_url}/reports?type=html&id={number_id}")
         r.raise_for_status()
         report = json.loads(r.text)
         if report["status"] != "success":


Test patch: