internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: mampfes/hacs_waste_collection_schedule

Issue:
[Request] Add WAS Vorsfelde
Hey,
could you add WAS Vorsflede?

Both "Rest, Bio, Papier" via Street name: https://was-wolfsburg.de/was/biorestpapierics2021.php
And Gelber Sack via street name where you just get the dates: https://was-wolfsburg.de/was/gelber_sack.php

greetz


Discussion:
The ICS file download for "Restmüll, Bio, Papier" works with the following config:

```
waste_collection_schedule:
  sources:
    - name: ics
      args:
        url: "https://was-wolfsburg.de/subabfuhrtermine/ics_abfuhrtermine3.php"
        method: POST
        params:
          ortabf: Denkmalplatz
```

"Gelber Sack" requires to implement an own source.
Thank you for the example. 
Are you able to add an own source for "Gelber Sack"?
Yes, but this may take a while. :-)

Resolving patch:
diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/was_wolfsburg_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/was_wolfsburg_de.py
new file mode 100644
--- /dev/null
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/was_wolfsburg_de.py
@@ -0,0 +1,44 @@
+import datetime
+import re
+
+import requests
+from waste_collection_schedule import Collection  # type: ignore[attr-defined]
+from waste_collection_schedule.service.ICS import ICS
+
+TITLE = "Wolfsburger Abfallwirtschaft und Straßenreinigung"
+DESCRIPTION = "Source for waste collections for WAS-Wolfsburg, Germany."
+URL = "https://was-wolfsburg.de"
+TEST_CASES = {"WAS": {"city": "Barnstorf", "street": "Bahnhofspassage"}}
+
+
+class Source:
+    def __init__(self, city, street):
+        self._city = city
+        self._street = street
+        self._ics = ICS()
+
+    def fetch(self):
+        # fetch "Gelber Sack"
+        args = {"g": self._city}
+        r = requests.get(
+            "https://was-wolfsburg.de/subgelberweihgarten/php/abfuhrgelber.php",
+            params=args,
+        )
+
+        entries = []
+        match = re.findall(r"(\d{2})\.(\d{2})\.(\d{4})", r.text)
+        for m in match:
+            date = datetime.date(day=int(m[0]), month=int(m[1]), year=int(m[2]))
+            entries.append(Collection(date, "Gelber Sack"))
+
+        # fetch remaining collections
+        args = {"ortabf": self._street}
+        r = requests.post(
+            "https://was-wolfsburg.de/subabfuhrtermine/ics_abfuhrtermine3.php",
+            data=args,
+        )
+        dates = self._ics.convert(r.text)
+        for d in dates:
+            entries.append(Collection(d[0], d[1]))
+
+        return entries


Test patch:
Repository: mampfes/hacs_waste_collection_schedule

Issue:
ICS Scraper error
My Home-Assistant has the following error:

`2021-12-02 06:53:42 ERROR (SyncWorker_19) [waste_collection_schedule.scraper] fetch failed for source <waste_collection_schedule.source.ics.Source object at 0x7f3785601ca0>: 'NoneType' object does not support item assignment`

I have events for this year, but not for the next. I know, that the ICS scraper is trying to get events for the next year, when it's december. I don't know if this years events are cached or not. But I assume that the issue is because of the next year scraping. With this in mind I searched the source code.
My Python is quite bad, but I assume, that the problem is in line [162](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py#L162). I think this line should look like the block [151-155](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py#L151-L155).


Discussion:

Resolving patch:
diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py
--- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py
@@ -159,7 +159,8 @@ def fetch(self):
                 if now.month == 12:
                     # also get data for next year if we are already in december
                     url = self._url.replace("{%Y}", str(now.year + 1))
-                    self._params[self._year_field] = str(now.year + 1)
+                    if self._year_field is not None:
+                        self._params[self._year_field] = str(now.year + 1)
 
                     try:
                         entries.extend(self.fetch_url(url), self._params)


Test patch:
Repository: mampfes/hacs_waste_collection_schedule

Issue:
recycleapp_be not working for some addresses
when I enter my address into the configuration.yaml I receive this error on restart:
```
fetch failed for source Recycle!: Traceback (most recent call last): File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/scraper.py", 
line 116, in fetch entries = self._source.fetch() File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/source/recycleapp_be.py", 
line 79, in fetch entries.append(Collection(date, item["fraction"]["name"]["en"])) KeyError: 'name'
```
when I use the example address or some other addresses everything works fine. Is it a problem with my city? Because other addresses of this city also don't work, even though those addresses work on [Recycle!](https://recycleapp.be/home).
this is what I have in configuration.yaml
```
waste_collection_schedule:
  sources:
    - name: recycleapp_be
      args:
        postcode: 3001
        street: Waversebaan
        house_number: 276
```


Discussion:

Resolving patch:
diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/recycleapp_be.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/recycleapp_be.py
--- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/recycleapp_be.py
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/recycleapp_be.py
@@ -12,17 +12,29 @@
         "postcode": 1140,
         "street": "Bazellaan",
         "house_number": 1,
-    }
+    },
+    "3001, Waversebaan 276 with events": {
+        "postcode": 3001,
+        "street": "Waversebaan",
+        "house_number": 276,
+    },
+    "3001, Waversebaan 276 without events": {
+        "postcode": 3001,
+        "street": "Waversebaan",
+        "house_number": 276,
+        "add_events": False,
+    },
 }
 
 _LOGGER = logging.getLogger(__name__)
 
 
 class Source:
-    def __init__(self, postcode, street, house_number):
+    def __init__(self, postcode, street, house_number, add_events=True):
         self._postcode = postcode
         self._street = street
         self._house_number = house_number
+        self._add_events = add_events
 
     def fetch(self):
         url = "https://recycleapp.be/api/app/v1"
@@ -76,5 +88,9 @@ def fetch(self):
                 continue
 
             date = datetime.strptime(item["timestamp"], "%Y-%m-%dT%H:%M:%S.000Z").date()
-            entries.append(Collection(date, item["fraction"]["name"]["en"]))
+            if item["type"] == "collection":
+                entries.append(Collection(date, item["fraction"]["name"]["en"]))
+            elif item["type"] == "event" and self._add_events:
+                entries.append(Collection(date, item["event"]["title"]["en"]))
+
         return entries


Test patch:
Repository: mampfes/hacs_waste_collection_schedule

Issue:
Ad New Waste Collection
Pleas ad
https://www.bmv.at/home.html


Discussion:

Resolving patch:
diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/bmv_at.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/bmv_at.py
new file mode 100644
--- /dev/null
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/bmv_at.py
@@ -0,0 +1,86 @@
+import logging
+from html.parser import HTMLParser
+
+import requests
+from waste_collection_schedule import Collection  # type: ignore[attr-defined]
+from waste_collection_schedule.service.ICS import ICS
+
+TITLE = "BMV.at"
+DESCRIPTION = "Source for BMV, Austria"
+URL = "https://www.bmv.at"
+TEST_CASES = {
+    "Allersdorf": {"ort": "ALLERSDORF", "strasse": "HAUSNUMMER", "hausnummer": 9},
+    "Bad Sauerbrunn": {
+        "ort": "BAD SAUERBRUNN",
+        "strasse": "BUCHINGERWEG",
+        "hausnummer": 16,
+    },
+}
+
+_LOGGER = logging.getLogger(__name__)
+
+
+# Parser for HTML input (hidden) text
+class HiddenInputParser(HTMLParser):
+    def __init__(self):
+        super().__init__()
+        self._args = {}
+
+    @property
+    def args(self):
+        return self._args
+
+    def handle_starttag(self, tag, attrs):
+        if tag == "input":
+            d = dict(attrs)
+            if d["type"] == "HIDDEN":
+                self._args[d["name"]] = d.get("value")
+
+
+class Source:
+    def __init__(self, ort, strasse, hausnummer):
+        self._ort = ort
+        self._strasse = strasse
+        self._hausnummer = hausnummer
+        self._ics = ICS()
+
+    def fetch(self):
+        session = requests.session()
+
+        r = session.get(
+            "https://webudb.udb.at/WasteManagementUDB/WasteManagementServlet?SubmitAction=wasteDisposalServices&InFrameMode=TRUE"
+        )
+
+        # add all hidden input fields to form data
+        p = HiddenInputParser()
+        p.feed(r.text)
+        args = p.args
+
+        args["Focus"] = "Hausnummer"
+        args["SubmitAction"] = "forward"
+        args["Ort"] = self._ort
+        args["Strasse"] = self._strasse
+        args["Hausnummer"] = self._hausnummer
+        r = session.post(
+            "https://webudb.udb.at/WasteManagementUDB/WasteManagementServlet", data=args
+        )
+
+        args["ApplicationName"] = "com.athos.kd.udb.AbfuhrTerminModel"
+        args["Focus"] = None
+        args["IsLastPage"] = "true"
+        args["Method"] = "POST"
+        args["PageName"] = "Terminliste"
+        args["SubmitAction"] = "filedownload_ICAL"
+        del args["Ort"]
+        del args["Strasse"]
+        del args["Hausnummer"]
+        r = session.post(
+            "https://webudb.udb.at/WasteManagementUDB/WasteManagementServlet", data=args
+        )
+
+        dates = self._ics.convert(r.text)
+
+        entries = []
+        for d in dates:
+            entries.append(Collection(d[0], d[1]))
+        return entries


Test patch:
Repository: mampfes/hacs_waste_collection_schedule

Issue:
ZAS Abfallwirtschaft
I'm trying to integrate the ZAS Abfallwirtschaft ICS. But i can't seem to get it to work.
Is there anything i need to configure specifically?

The Website is
https://www.za-sws.de/abfallkalender.cfm

And the generated ICS is
https://online-portal.za-sws.de/WasteManagementSuedwestsachsen/WasteManagementServiceServlet?ApplicationName=Calendar&SubmitAction=sync&StandortID=52554001&AboID=33626&Fra=R;P;B;W;L;C;S
_(The adress used is a random one, not mine of course)_

My configuration looks like this:

```
waste_collection_schedule:
  sources:
    - name: ics
      args:
        url: https://online-portal.za-sws.de/WasteManagementSuedwestsachsen/WasteManagementServiceServlet?ApplicationName=Calendar&SubmitAction=sync&StandortID=52554001&AboID=33626&Fra=R;P;B;W;L;C;S
        customize:
        - type: Restmuelltonne 02-woechentl.
          alias: Restmüll
          icon: mdi:trash-can
        - type: Biotonnenwaesche
          alias: Biotonnenwäsche
          show: false
          icon: mdi:flower-outline
        - type: Papiertonne 04-woechentl.
          alias: Papiertonne
          icon: mdi:trash-can-outline
        - type: LVP
          alias: Gelbe Tonne
          icon: mdi:recycle
```

Thanks in advance.


Discussion:

Resolving patch:
diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py
--- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/ics.py
@@ -132,6 +132,7 @@ def __init__(
         method="GET",
         split_at=None,
         version=2,
+        verify_ssl=True,
     ):
         self._url = url
         self._file = file
@@ -144,6 +145,7 @@ def __init__(
         self._params = params
         self._year_field = year_field  # replace this field in params with current year
         self._method = method  # The method to send the params
+        self._verify_ssl = verify_ssl
 
     def fetch(self):
         if self._url is not None:
@@ -182,9 +184,13 @@ def fetch(self):
     def fetch_url(self, url, params=None):
         # get ics file
         if self._method == "GET":
-            r = requests.get(url, params=params, headers=HEADERS)
+            r = requests.get(
+                url, params=params, headers=HEADERS, verify=self._verify_ssl
+            )
         elif self._method == "POST":
-            r = requests.post(url, data=params, headers=HEADERS)
+            r = requests.post(
+                url, data=params, headers=HEADERS, verify=self._verify_ssl
+            )
         else:
             raise RuntimeError(
                 "Error: unknown method to fetch URL, use GET or POST; got {self._method}"


Test patch:
Repository: mampfes/hacs_waste_collection_schedule

Issue:
CalendarEventDevice is deprecated
Hi there,

Latest HA beta `core-2022.5.0` shows this within the logs:
```
CalendarEventDevice is deprecated, modify WasteCollectionCalendar to extend CalendarEntity
```

Just wanted to let you know 🙂

More information can be found here:
https://github.com/home-assistant/core/pull/68843

And here:
https://developers.home-assistant.io/docs/core/entity/calendar/


Discussion:

Resolving patch:
diff --git a/custom_components/waste_collection_schedule/calendar.py b/custom_components/waste_collection_schedule/calendar.py
--- a/custom_components/waste_collection_schedule/calendar.py
+++ b/custom_components/waste_collection_schedule/calendar.py
@@ -3,7 +3,7 @@
 import logging
 from datetime import timedelta
 
-from homeassistant.components.calendar import CalendarEventDevice
+from homeassistant.components.calendar import CalendarEntity, CalendarEvent
 
 _LOGGER = logging.getLogger(__name__)
 
@@ -24,7 +24,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
     async_add_entities(entities)
 
 
-class WasteCollectionCalendar(CalendarEventDevice):
+class WasteCollectionCalendar(CalendarEntity):
     """Calendar entity class."""
 
     def __init__(self, api, scraper):
@@ -56,10 +56,8 @@ async def async_get_events(self, hass, start_date, end_date):
 
     def _convert(self, collection):
         """Convert an collection into a Home Assistant calendar event."""
-        return {
-            "uid": f"{self._scraper.calendar_title}-{collection.date.isoformat()}-{collection.type}",
-            "summary": collection.type,
-            "start": {"date": collection.date.isoformat()},
-            "end": {"date": (collection.date + timedelta(days=1)).isoformat()},
-            "allDay": True,
-        }
+        return CalendarEvent(
+            summary=collection.type,
+            start=collection.date,
+            end=collection.date + timedelta(days=1),
+        )


Test patch:
Repository: mampfes/hacs_waste_collection_schedule

Issue:
Abfallkalender Bremen
Hello,

unfortunately for my Home Town it dosn´t work. It seens Bremen has a own format:

https://web.c-trace.de/bremenabfallkalender/(S(dytpzs5sl1ivu44sptolg2t4))/abfallkalender/cal?Gemeinde=Bremen&Strasse=Oslebshauser%20Heerstra%C3%9Fe&Hausnr=44

https://www.die-bremer-stadtreinigung.de/abfallwirtschaft/entsorgung/bremer-abfallkalender-23080

It´s possible to fix it?
Cheers

Boris


Discussion:

Resolving patch:
diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/c_trace_de.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/c_trace_de.py
new file mode 100644
--- /dev/null
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/c_trace_de.py
@@ -0,0 +1,52 @@
+import requests
+from waste_collection_schedule import Collection  # type: ignore[attr-defined]
+from waste_collection_schedule.service.ICS import ICS
+
+TITLE = "C-Trace.de"
+DESCRIPTION = "Source for C-Trace.de."
+URL = "https://c-trace.de/"
+TEST_CASES = {"Bremen": {"ort": "Bremen", "strasse": "Abbentorstraße", "hausnummer": 5}}
+
+
+BASE_URL = "https://web.c-trace.de"
+SERVICE_MAP = {"Bremen": "bremenabfallkalender"}
+
+
+class Source:
+    def __init__(self, ort, strasse, hausnummer):
+        self._ort = ort
+        self._strasse = strasse
+        self._hausnummer = hausnummer
+        self._ics = ICS(regex=r"Abfuhr: (.*)")
+
+    def fetch(self):
+        service = SERVICE_MAP.get(self._ort)
+        if service is None:
+            raise Exception(f"no service for {self._ort}")
+
+        session = requests.session()
+
+        # get session url
+        r = session.get(f"{BASE_URL}/{service}/Abfallkalender", allow_redirects=False,)
+        session_id = r.headers["location"].split("/")[
+            2
+        ]  # session_id like "(S(r3bme50igdgsp2lstgxxhvs2))"
+
+        args = {
+            "Gemeinde": self._ort,
+            "Strasse": self._strasse,
+            "Hausnr": self._hausnummer,
+        }
+        r = session.get(
+            f"{BASE_URL}/{service}/{session_id}/abfallkalender/cal", params=args
+        )
+        r.raise_for_status()
+
+        # parse ics file
+        r.encoding = "utf-8"
+        dates = self._ics.convert(r.text)
+
+        entries = []
+        for d in dates:
+            entries.append(Collection(d[0], d[1]))
+        return entries


Test patch:
Repository: mampfes/hacs_waste_collection_schedule

Issue:
[Request] Support for Abfallkalender Landkreis Göttingen (Niedersachsen)
Is it possible to add support for the Abfallkalender Landkreis Göttingen (Niedersachsen)?

https://www.abfallplus.de/fuer-buerger/ states "Kreis Göttingen wird unterstützt". 

I tried to find out the parameters with the help of the proxy app "postman" and the recommended Android App from https://www.abfallplus.de/, but failed so far.



Discussion:
The method of how to extract seem to be outdated or not available (the website of Landkreis Göttingen has no interface). If I get any hint how to extract the needed parameters I (software engineer and Linux user) am more than willing to work on this. So far I could not get them from the traffic generated by the Android app though.

Resolving patch:
diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/wizard/abfall_io.py b/custom_components/waste_collection_schedule/waste_collection_schedule/wizard/abfall_io.py
--- a/custom_components/waste_collection_schedule/waste_collection_schedule/wizard/abfall_io.py
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/wizard/abfall_io.py
@@ -29,6 +29,7 @@
     ("eBe Essen", "9b5390f095c779b9128a51db35092c9c"),
     ("Freudenstadt", "595f903540a36fe8610ec39aa3a06f6a"),
     ("Göppingen", "365d791b58c7e39b20bb8f167bd33981"),
+    ("Göttingen", "7dd0d724cbbd008f597d18fcb1f474cb"),
     ("Heilbronn (Landkreis)", "1a1e7b200165683738adddc4bd0199a2"),
     ("Kitzingen", "594f805eb33677ad5bc645aeeeaf2623"),
     ("Landsberg am Lech", "7df877d4f0e63decfb4d11686c54c5d6"),


Test patch:
Repository: mampfes/hacs_waste_collection_schedule

Issue:
No Import BMV
Hi !
Thanks for the plugin, but unfortunately I can't get any data in. I checked, it may be that the street and the street are different. Thank you


Discussion:
Please provide more info. Which source are you using? Which information is missing or errorneous?

Resolving patch:
diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/bmv_at.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/bmv_at.py
--- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/bmv_at.py
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/bmv_at.py
@@ -15,6 +15,11 @@
         "strasse": "BUCHINGERWEG",
         "hausnummer": 16,
     },
+    "Rattersdorf": {
+        "ort": "RATTERSDORF",
+        "strasse": "SIEBENBRÜNDLGASSE",
+        "hausnummer": 30,
+    },
 }
 
 _LOGGER = logging.getLogger(__name__)
@@ -56,6 +61,24 @@ def fetch(self):
         p.feed(r.text)
         args = p.args
 
+        args["Focus"] = "Ort"
+        args["SubmitAction"] = "changedEvent"
+        args["Ort"] = self._ort
+        args["Strasse"] = "HAUSNUMMER"
+        args["Hausnummer"] = 0
+        r = session.post(
+            "https://webudb.udb.at/WasteManagementUDB/WasteManagementServlet", data=args
+        )
+
+        args["Focus"] = "Strasse"
+        args["SubmitAction"] = "changedEvent"
+        args["Ort"] = self._ort
+        args["Strasse"] = self._strasse
+        args["Hausnummer"] = 0
+        r = session.post(
+            "https://webudb.udb.at/WasteManagementUDB/WasteManagementServlet", data=args
+        )
+
         args["Focus"] = "Hausnummer"
         args["SubmitAction"] = "forward"
         args["Ort"] = self._ort


Test patch:
Repository: mampfes/hacs_waste_collection_schedule

Issue:
[bug] [recycleapp_be] UnboundLocalError: local variable 'streetId' referenced before assignment
Hello, 

I have a problem with the recycleapp_be source.

I have the error into the log : 

```
Logger: waste_collection_schedule.scraper
Source: custom_components/waste_collection_schedule/waste_collection_schedule/scraper.py:143
Integration: waste_collection_schedule ([documentation](https://github.com/mampfes/hacs_waste_collection_schedule#readme))
First occurred: 15:24:43 (1 occurrences)
Last logged: 15:24:43

fetch failed for source Recycle!: Traceback (most recent call last): File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/scraper.py", line 141, in fetch entries = self._source.fetch() File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/source/recycleapp_be.py", line 66, in fetch if streetId is None: UnboundLocalError: local variable 'streetId' referenced before assignment
` ``



Discussion:

Resolving patch:
diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/recycleapp_be.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/recycleapp_be.py
--- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/recycleapp_be.py
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/recycleapp_be.py
@@ -24,6 +24,12 @@
         "house_number": 276,
         "add_events": False,
     },
+    "1400, Rue de namur 1 with events": {
+        "postcode": 1400,
+        "street": "Rue de namur",
+        "house_number": 1,
+        "add_events": True,
+    },
 }
 
 _LOGGER = logging.getLogger(__name__)
@@ -60,6 +66,7 @@ def fetch(self):
             _LOGGER.error("Get street id failed")
             return []
 
+        streetId = None
         for item in r.json()["items"]:
             if item["name"] == self._street:
                 streetId = item["id"]


Test patch: