mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 03:04:09 +01:00
add Sicaapp LU
This commit is contained in:
@@ -1245,6 +1245,7 @@ If your service provider is not listed, feel free to open a [source request issu
|
||||
|
||||
- [Esch-sur-Alzette](/doc/source/esch_lu.md) / esch.lu
|
||||
- [SICA](/doc/source/sica_lu.md) / sica.lu
|
||||
- [SICA](/doc/source/sicaapp_lu.md) / sicaapp.lu
|
||||
</details>
|
||||
|
||||
<details>
|
||||
|
||||
@@ -6820,6 +6820,11 @@
|
||||
"title": "SICA",
|
||||
"module": "sica_lu",
|
||||
"default_params": {}
|
||||
},
|
||||
{
|
||||
"title": "SICA",
|
||||
"module": "sicaapp_lu",
|
||||
"default_params": {}
|
||||
}
|
||||
],
|
||||
"Netherlands": [
|
||||
|
||||
@@ -283,7 +283,8 @@
|
||||
"building_id": "Building Id",
|
||||
"addressNo": "Address No",
|
||||
"territory": "Territory",
|
||||
"addition": "Addition"
|
||||
"addition": "Addition",
|
||||
"commune": "Commune"
|
||||
},
|
||||
"data_description": {
|
||||
"calendar_title": "A more readable, or user-friendly, name for the waste calendar. If nothing is provided, the name returned by the source will be used."
|
||||
@@ -538,7 +539,8 @@
|
||||
"building_id": "Building Id",
|
||||
"addressNo": "Address No",
|
||||
"territory": "Territory",
|
||||
"addition": "Addition"
|
||||
"addition": "Addition",
|
||||
"commune": "Commune"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import json
|
||||
import re
|
||||
from datetime import datetime
|
||||
from typing import Literal
|
||||
|
||||
import requests
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
|
||||
TITLE = "SICA"
|
||||
DESCRIPTION = "Source for SICA."
|
||||
URL = "https://sicaapp.lu/"
|
||||
TEST_CASES = {
|
||||
"Steinfort": {"commune": "Steinfort"},
|
||||
"Kopstal": {"commune": "Kopstal"},
|
||||
}
|
||||
|
||||
|
||||
ICON_MAP = {
|
||||
"RESIDUAL": "mdi:trash-can",
|
||||
"ORGANIC": "mdi:food-apple",
|
||||
"VALORLUX": "mdi:package-variant",
|
||||
"PAPER": "mdi:newspaper",
|
||||
"GLASS": "mdi:bottle-soda",
|
||||
"TREES": "mdi:tree",
|
||||
"CLOTHING": "mdi:tshirt-crew",
|
||||
}
|
||||
|
||||
|
||||
API_URL = "https://sicaapp.lu/commune/"
|
||||
# obj = JSON.parse("
|
||||
JSON_REGEX = re.compile(r'obj = JSON.parse\("(?P<json>.*)"\);')
|
||||
|
||||
COMMUNES = [
|
||||
"Bertrange",
|
||||
"Garnich",
|
||||
"Kehlen",
|
||||
"Koerich",
|
||||
"Kopstal",
|
||||
"Mamer",
|
||||
"Steinfort",
|
||||
"Habscht",
|
||||
]
|
||||
COMMUNES_LITERAL = Literal[
|
||||
"Bertrange",
|
||||
"Garnich",
|
||||
"Kehlen",
|
||||
"Koerich",
|
||||
"Kopstal",
|
||||
"Mamer",
|
||||
"Steinfort",
|
||||
"Habscht",
|
||||
]
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, commune: COMMUNES_LITERAL):
|
||||
self._commune: str = commune
|
||||
|
||||
def fetch(self) -> list[Collection]:
|
||||
args = {"commune": self._commune, "submitcommune": "save", "language": ""}
|
||||
|
||||
r = requests.get(API_URL, params=args)
|
||||
r.raise_for_status()
|
||||
|
||||
m = JSON_REGEX.search(r.text)
|
||||
if m is None:
|
||||
raise ValueError("No JSON data found")
|
||||
data_str = m.group("json").encode().decode("unicode_escape")
|
||||
data = json.loads(data_str)
|
||||
if "code" in data and data["code"] == "rest_no_route":
|
||||
raise ValueError(f"Commune {self._commune} not, use one of {COMMUNES}")
|
||||
|
||||
entries = []
|
||||
for month in data:
|
||||
for day in month["schedule"]:
|
||||
if not day["pickupTypes"]:
|
||||
continue
|
||||
date = datetime.strptime(day["date"], "%Y%m%d").date()
|
||||
for waste_type_dict in day["pickupTypes"]:
|
||||
waste_type = waste_type_dict["name"]
|
||||
icon = ICON_MAP.get(re.split(r"\s|,", waste_type)[0])
|
||||
entries.append(Collection(date=date, t=waste_type, icon=icon))
|
||||
|
||||
return entries
|
||||
45
doc/source/sicaapp_lu.md
Normal file
45
doc/source/sicaapp_lu.md
Normal file
@@ -0,0 +1,45 @@
|
||||
# SICA
|
||||
|
||||
Support for schedules provided by [SICA](https://sicaapp.lu/), serving multiple, Luxembourg.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: sicaapp_lu
|
||||
args:
|
||||
commune: COMMUNE
|
||||
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**commune**
|
||||
*(String) (required)*
|
||||
|
||||
Use one of:
|
||||
|
||||
- Bertrange
|
||||
- Garnich
|
||||
- Kehlen
|
||||
- Koerich
|
||||
- Kopstal
|
||||
- Mamer
|
||||
- Steinfort
|
||||
- Habscht
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: sicaapp_lu
|
||||
args:
|
||||
commune: Steinfort
|
||||
|
||||
```
|
||||
|
||||
## How to get the source argument
|
||||
|
||||
Find the parameter of your address using [https://sicaapp.lu/](https://sicaapp.lu/) and write them exactly like on the web page.
|
||||
2
info.md
2
info.md
@@ -28,7 +28,7 @@ Waste collection schedules from service provider web sites are updated daily, de
|
||||
| Hungary | FKF Budapest, FKF Budaörs, ÉTH (Érd, Diósd, Nagytarcsa, Sóskút, Tárnok) |
|
||||
| Italy | CIDIU S.p.A., Contarina S.p.A, Il Rifiutologo |
|
||||
| Lithuania | Kauno švara, Telšių keliai |
|
||||
| Luxembourg | Esch-sur-Alzette, SICA |
|
||||
| Luxembourg | Esch-sur-Alzette, SICA, SICA |
|
||||
| Netherlands | 's-Hertogenbosch, ACV Group, Afvalstoffendienst.nl, Alpen an den Rijn, Altena, Area Afval, Avalex, Avri, Bar Afvalbeheer, Bernheze, Circulus, Cyclus NV, Dar, Den Haag, GAD, Gemeente Almere, Gemeente Berkelland, Gemeente Cranendonck, Gemeente Hellendoorn, Gemeente Lingewaard, Gemeente Meppel, Gemeente Middelburg + Vlissingen, Gemeente Peel en Maas, Gemeente Schouwen-Duiveland, Gemeente Sudwest-Fryslan, Gemeente Venray, Gemeente Voorschoten, Gemeente Waalre, Gemeente Westland, Goes, Heusden, HVC Groep, Meerlanden, Mijn Blink, Oisterwijk, PreZero, Purmerend, RAD BV, Rd4, Reinis, Spaarnelanden, Twente Milieu, Vught, Waardlanden, Ximmio, ZRD, Ôffalkalinder van Noardeast-Fryslân & Dantumadiel |
|
||||
| New Zealand | Auckland Council, Christchurch City Council, Dunedin District Council, Gore, Invercargill & Southland, Hamilton City Council, Horowhenua District Council, Hutt City Council, Napier City Council, Porirua City, Rotorua Lakes Council, Tauranga City Council, Waipa District Council, Wellington City Council |
|
||||
| Norway | BIR (Bergensområdets Interkommunale Renovasjonsselskap), Fosen Renovasjon, IRiS, Min Renovasjon, Movar IKS, Oslo Kommune, ReMidt Orkland muni, Sandnes Kommune, Stavanger Kommune, Trondheim |
|
||||
|
||||
Reference in New Issue
Block a user