Repository: mampfes/hacs_waste_collection_schedule

Issue:
[Bug]: Source Ronneby Miljöteknik Sophämtning does not seem to work
### I Have A Problem With:

A specific source

### What's Your Problem

I've tried to integrate through HACS according to the documentation, but I do not seem to get any data.
I've tried to increase logging, but no logs are generated related to this component at all.
The sensor state is always set to "unknown" and the calendar remains empty.

### Source (if relevant)

doc/source/miljoteknik_se.md

### Logs

```Shell
No relevant log info found. I tried to change HACS to debug, but it didn't give much.
If there is anyway to force more logs from the component, please let me know how...
```


### Relevant Configuration

```YAML
waste_collection_schedule:
  sources:
    - name: miljoteknik_se
      args:
        street_address: "xxx"
  fetch_time: "10:40"

sensor:
  - platform: waste_collection_schedule
    name: Miljöteknik
    count: 2

logger:
  default: info
  logs:
    custom_components.hacs: debug
    aiogithubapi: debug
```


### 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/miljoteknik_se.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/miljoteknik_se.py
--- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/miljoteknik_se.py
+++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/miljoteknik_se.py
@@ -1,20 +1,21 @@
 import json
 import re
+from datetime import datetime
+
 import requests
 from bs4 import BeautifulSoup as bs
-from datetime import datetime
 from waste_collection_schedule import Collection  # type: ignore[attr-defined]
 
 # Ronneby Miljöteknik, Blekinge Sweden
 #
 # The public URL is http://www.fyrfackronneby.se/hamtningskalender/
-# However, this uses an iframe from http://35.228.122.136 which is the
+# However, this uses an iframe from https://kalender.fyrfackronneby.se which is the
 # actual service providing the bin data.
 #
 # One first has to do a search since they put an ID in the list of
 # search results which is required when sending the request to get the
 # bin data. The data then comes injected into a script tag as it's
-# normally used to build a browseable calendar for easy viewing.
+# normally used to build a browsable calendar for easy viewing.
 #
 # Bins in this municipality have four types of waste each, and each
 # house has 2 bins, example raw data for the two bins:
@@ -36,40 +37,38 @@
 TITLE = "Ronneby Miljöteknik"
 DESCRIPTION = "Source for Ronneby Miljöteknik waste collection."
 URL = "http://www.fyrfackronneby.se"
-TEST_CASES = {
-    "Home": {"street_address": "Hjortsbergavägen 16, Johannishus"}
-}
+TEST_CASES = {"Home": {"street_address": "Hjortsbergavägen 16, Johannishus"}}
 
 API_URL = "http://www.fyrfackronneby.se/hamtningskalender/"
 
 
 class Source:
     def __init__(self, street_address):
-        addr_parts = street_address.split(',')
+        addr_parts = street_address.split(",")
         self._street_address = addr_parts[0]
         self._city = addr_parts[1].lstrip()
 
     def fetch(self):
         data = {"search_address": self._street_address}
         headers = {
-            'Accept-Encoding': 'identity',
-            'Accept': '*/*',
-            'Accept-Language': 'sv-SE,sv;q=0.9',
-            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
+            "Accept-Encoding": "identity",
+            "Accept": "*/*",
+            "Accept-Language": "sv-SE,sv;q=0.9",
+            "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
         }
         response = requests.post(
-            "http://35.228.122.136/search_suggestions.php",
+            "https://kalender.fyrfackronneby.se/search_suggestions.php",
             data=data,
-            headers=headers
+            headers=headers,
         )
 
-        soup = bs(response.text, 'html.parser')
+        soup = bs(response.text, "html.parser")
         pickup_id = False
-        for el_addr in soup.find_all('span', attrs={'class': 'address'}):
+        for el_addr in soup.find_all("span", attrs={"class": "address"}):
             if el_addr.string == self._street_address:
                 for el_addr_sib in el_addr.next_siblings:
-                    if el_addr_sib.name == 'span' and el_addr_sib.string == self._city:
-                        pickup_id = el_addr.parent['id']
+                    if el_addr_sib.name == "span" and el_addr_sib.string == self._city:
+                        pickup_id = el_addr.parent["id"]
                         break
                 if pickup_id:
                     break
@@ -77,21 +76,23 @@ def fetch(self):
             return []
 
         data = {
-            "chosen_address": "{} {}".format(self._street_address, self._city),
-            "chosen_address_pickupid": pickup_id
+            "chosen_address": f"{self._street_address} {self._city}",
+            "chosen_address_pickupid": pickup_id,
         }
         response = requests.post(
-            "http://35.228.122.136/get_data.php",
+            "https://kalender.fyrfackronneby.se/get_data.php",
             data=data,
-            headers=headers
+            headers=headers,
         )
 
         entries = []
-        for entry in re.findall(r'{.title:[^}]+}', response.text):
-            json_entry = json.loads(re.sub(r'(title|start):', r'"\1":', entry.replace("'", '"')))
+        for entry in re.findall(r"{.title:[^}]+}", response.text):
+            json_entry = json.loads(
+                re.sub(r"(title|start):", r'"\1":', entry.replace("'", '"'))
+            )
             # Same icon always, due to two bins both being various recycled things
             icon = "mdi:recycle"
-            waste_type = json_entry['title'].split(':')[1].lstrip()
-            pickup_date = datetime.fromisoformat(json_entry['start']).date()
+            waste_type = json_entry["title"].split(":")[1].lstrip()
+            pickup_date = datetime.fromisoformat(json_entry["start"]).date()
             entries.append(Collection(date=pickup_date, t=waste_type, icon=icon))
         return entries


Test patch: