mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
add monaloga_de
This commit is contained in:
@@ -17,7 +17,7 @@ repos:
|
||||
hooks:
|
||||
- id: codespell
|
||||
args:
|
||||
- --ignore-words-list=hass,alot,datas,dof,dur,farenheit,hist,iff,ines,ist,lightsensor,mut,nd,pres,referer,ser,serie,te,technik,ue,uint,visability,wan,wanna,withing,Adresse,termine,adresse,oder,alle,assistent,hart,marz,worthing,linz,celle,vor,leibnitz
|
||||
- --ignore-words-list=hass,alot,datas,dof,dur,farenheit,hist,iff,ines,ist,lightsensor,mut,nd,pres,referer,ser,serie,te,technik,ue,uint,visability,wan,wanna,withing,Adresse,termine,adresse,oder,alle,assistent,hart,marz,worthing,linz,celle,vor,leibnitz,januar,februar,juni,juli,oktober,dezember
|
||||
- --skip="./.*,*.csv,*.json"
|
||||
- --quiet-level=2
|
||||
exclude_types: [csv, json]
|
||||
|
||||
@@ -642,6 +642,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [AWIDO Online](/doc/source/awido_de.md) / awido-online.de
|
||||
- [AWIGO Abfallwirtschaft Landkreis Osnabrück GmbH](/doc/source/awigo_de.md) / awigo.de
|
||||
- [AWISTA Düsseldorf](/doc/source/muellmax_de.md) / awista.de
|
||||
- [AWISTA LOGISTIK Stadt Remscheid](/doc/source/monaloga_de.md) / monaloga.de
|
||||
- [Awista Starnberg](/doc/ics/awista_starnberg_de.md) / awista-starnberg.de
|
||||
- [AWL Neuss](/doc/source/awlneuss_de.md) / buergerportal.awl-neuss.de
|
||||
- [AWM München](/doc/source/awm_muenchen_de.md) / awm-muenchen.de
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
from datetime import date, datetime
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
|
||||
TITLE = "AWISTA LOGISTIK Stadt Remscheid"
|
||||
DESCRIPTION = "Source for AWISTA LOGISTIK Stadt Remscheid."
|
||||
URL = "https://www.monaloga.de/"
|
||||
TEST_CASES = {
|
||||
"Adolf-Clarenbach-Straße 42899": {
|
||||
"street": "Adolf-Clarenbach-Straße",
|
||||
"plz": 42899,
|
||||
},
|
||||
"Alte Wendung": {"street": "Alte Wendung"},
|
||||
}
|
||||
|
||||
|
||||
ICON_MAP = {
|
||||
"Leichtverpackungen": "mdi:recycle",
|
||||
}
|
||||
|
||||
GERMAN_MONTHS = {
|
||||
"Januar": 1,
|
||||
"Februar": 2,
|
||||
"März": 3,
|
||||
"April": 4,
|
||||
"Mai": 5,
|
||||
"Juni": 6,
|
||||
"Juli": 7,
|
||||
"August": 8,
|
||||
"September": 9,
|
||||
"Oktober": 10,
|
||||
"November": 11,
|
||||
"Dezember": 12,
|
||||
}
|
||||
|
||||
|
||||
API_URL = "https://www.monaloga.de/mportal/awista-logistik/stadt-remscheid/index.php"
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, street: str, plz: str | int | None = None):
|
||||
self._street: str = street
|
||||
self._plz: str | None = str(plz).strip() if plz else None
|
||||
|
||||
def fetch(self):
|
||||
args = {
|
||||
"form_ident": ["1", "0"],
|
||||
"sessionid": "",
|
||||
"form_ident_source": "1",
|
||||
"year": datetime.now().year,
|
||||
"next": "Suchen",
|
||||
}
|
||||
|
||||
# get json file
|
||||
r = requests.post(API_URL, data=args)
|
||||
r.raise_for_status()
|
||||
|
||||
soup = BeautifulSoup(r.text, "html.parser")
|
||||
select = soup.find("select", {"name": "a_street"})
|
||||
options = select.find_all("option")
|
||||
street_id = None
|
||||
|
||||
street_search = self._street.lower().strip()
|
||||
|
||||
for option in options:
|
||||
street_name = option.text.split("(")[0].lower().strip()
|
||||
if street_name == street_search and (
|
||||
not self._plz or self._plz in option.text
|
||||
):
|
||||
street_id = option["value"]
|
||||
break
|
||||
if street_id is None:
|
||||
raise ValueError(
|
||||
f"Street PLZ combination not found: {self._street} with {self._plz}"
|
||||
)
|
||||
|
||||
args["form_ident"] = "1"
|
||||
args["a_street"] = street_id + "|" + self._street.strip()
|
||||
|
||||
r = requests.post(API_URL, args)
|
||||
r.raise_for_status()
|
||||
|
||||
soup = BeautifulSoup(r.text, "html.parser")
|
||||
data = soup.find("div", {"id": "tab1"})
|
||||
data = data.find("table")
|
||||
|
||||
rows = data.find_all("tr")
|
||||
|
||||
entries = []
|
||||
for row in rows:
|
||||
cols = row.find_all("td")
|
||||
bin_type = cols[-1].text.strip()
|
||||
date_str = cols[0].text.split(",")[-1].strip()
|
||||
|
||||
date_parts = date_str.split(" ")
|
||||
day = int(date_parts[0].strip(".").strip())
|
||||
month = GERMAN_MONTHS[date_parts[1].strip()]
|
||||
year = int(date_parts[2].strip())
|
||||
d = date(year=year, month=month, day=day)
|
||||
icon = ICON_MAP.get(bin_type.lower()) # Collection icon
|
||||
entries.append(Collection(date=d, t=bin_type, icon=icon))
|
||||
|
||||
return entries
|
||||
39
doc/source/monaloga_de.md
Normal file
39
doc/source/monaloga_de.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# AWISTA LOGISTIK Stadt Remscheid
|
||||
|
||||
Support for schedules provided by [AWISTA LOGISTIK Stadt Remscheid](https://www.monaloga.de/), serving Remscheid, Germany.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: monaloga_de
|
||||
args:
|
||||
street: STREET
|
||||
plz: "PLZ"
|
||||
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**street**
|
||||
*(String) (required)*
|
||||
|
||||
**plz**
|
||||
*(String | Integer) (optional)*
|
||||
*The postal code of the address only use this if the street on the website shows a PLZ*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: monaloga_de
|
||||
args:
|
||||
street: Adolf-Clarenbach-Straße
|
||||
plz: "42899"
|
||||
```
|
||||
|
||||
## How to get the source argument
|
||||
|
||||
Find the parameter of your address using [https://www.monaloga.de/mportal/awista-logistik/stadt-remscheid/index.php](https://www.monaloga.de/mportal/awista-logistik/stadt-remscheid/index.php) and write them exactly like on the web page.
|
||||
Reference in New Issue
Block a user