diff --git a/README.md b/README.md index e7ad92586..a46625266 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,6 @@ Currently the following service providers are supported: - [A-Region.ch](./doc/source/a_region_ch.md) - [Lindau.ch](./doc/source/lindau_ch.md) -- [Münchenstein](./doc/source/muenchenstein_ch.md) ### United States of America diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/muenchenstein_ch.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/muenchenstein_ch.py deleted file mode 100755 index 3a5cb59f5..000000000 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/muenchenstein_ch.py +++ /dev/null @@ -1,76 +0,0 @@ -import json -from datetime import datetime, timedelta - -import requests -from bs4 import BeautifulSoup -from waste_collection_schedule import Collection # type: ignore[attr-defined] - -TITLE = "Abfallsammlung Münchenstein" -DESCRIPTION = "Source for Muenchenstein waste collection." -URL = "https://www.muenchenstein.ch/abfallsammlung" -TEST_CASES = { - "Abfuhrkreis Ost": {"waste_district": "Abfuhrkreis Ost"}, - "Abfuhrkreis West": {"waste_district": "492"}, -} - - -IconMap = { - "kehricht": "mdi:trash-can", - "hackseldienst": "mdi:leaf", - "papierabfuhr": "mdi:newspaper-variant-multiple-outline", - "kartonabfuhr": "mdi:package-variant", - "altmetalle": "mdi:nail", -} - - -class Source: - def __init__(self, waste_district): - self._waste_district = waste_district - - def fetch(self): - response = requests.get(URL) - - html = BeautifulSoup(response.text, "html.parser") - - table = html.find("table", attrs={"id": "icmsTable-abfallsammlung"}) - data = json.loads(table.attrs["data-entities"]) - - entries = [] - for item in data["data"]: - if ( - self._waste_district in item["abfallkreisIds"] - or self._waste_district in item["abfallkreisNameList"] - ): - next_pickup = item["_anlassDate-sort"].split()[0] - next_pickup_date = datetime.fromisoformat(next_pickup).date() - - waste_type = BeautifulSoup(item["name"], "html.parser").text - waste_type_sorted = BeautifulSoup(item["name-sort"], "html.parser").text - - entries.append( - Collection( - date=next_pickup_date, - t=waste_type, - icon=IconMap.get(waste_type_sorted, "mdi:trash-can"), - ) - ) - - # Collection of "Kehricht und Kleinsperrgut brennbar" are not listed with dates as events on website. - # Instead it states the day of the week for each waste district: tuesday for east and friday for west - # So we're going to set those collections programmatically for the next 4 occurrences - weekday_collection = 2 if self._waste_district == 'Abfuhrkreis Ost' or self._waste_district == 491 else 4 - weekday_today = datetime.now().isoweekday() - for x in range(4): - days_to_pickup = (x * 7) + ((weekday_collection - weekday_today) % 7) - next_pickup_date = (datetime.now() + timedelta(days=days_to_pickup)).date() - waste_type = "Kehricht und Kleinsperrgut brennbar" - - entries.append( - Collection( - date=next_pickup_date, - t=waste_type, - icon=IconMap.get(waste_type_sorted, "mdi:trash-can"), - ) - ) - - return entries diff --git a/doc/source/muenchenstein_ch.md b/doc/source/muenchenstein_ch.md deleted file mode 100644 index 6ecc64f26..000000000 --- a/doc/source/muenchenstein_ch.md +++ /dev/null @@ -1,38 +0,0 @@ -# Abfallsammlung Münchenstein, BL, Switzerland - -Support for schedules provided by [https://www.muenchenstein.ch/abfallsammlung](https://www.muenchenstein.ch/abfallsammlung). - -This source is just a slight modification of [@atrox06](https://github.com/atrox06)'s work for lindau_ch. So kudos to him. - -## Configuration via configuration.yaml - -```yaml -waste_collection_schedule: - sources: - - name: muenchenstein_ch - args: - waste_district: DISTRICT - -``` - -### Configuration Variables - -**waste_district**
-*(string) (required)* - -Valid options for waste_district: -- Abfuhrkreis Ost -- Abfuhrkreis West - -or use one the following IDs: 491 for "Ost", 492 for "West" - -## Example - -```yaml -waste_collection_schedule: - sources: - - name: muenchenstein_ch - args: - waste_district: Abfuhrkreis West - -``` diff --git a/info.md b/info.md index a904563c3..49e399563 100644 --- a/info.md +++ b/info.md @@ -165,7 +165,6 @@ Currently the following service providers are supported: - [A-Region.ch](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/a_region_ch.md) - [Lindau.ch](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/lindau_ch.md) -- [Münchenstein](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/muenchenstein_ch.md) ### United States of America