mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
Add Mölndal source (#2332)
* Add Mölndal source * reformatting --------- Co-authored-by: 5ila5 <5ila5@users.noreply.github.com>
This commit is contained in:
@@ -1212,6 +1212,7 @@ Waste collection schedules in the following formats and countries are supported.
|
|||||||
- [Lerum Vatten och Avlopp](/doc/source/lerum_se.md) / vatjanst.lerum.se
|
- [Lerum Vatten och Avlopp](/doc/source/lerum_se.md) / vatjanst.lerum.se
|
||||||
- [Linköping - Tekniska Verken](/doc/source/tekniskaverken_se.md) / tekniskaverken.se
|
- [Linköping - Tekniska Verken](/doc/source/tekniskaverken_se.md) / tekniskaverken.se
|
||||||
- [Lund Waste Collection](/doc/source/lund_se.md) / eservice431601.lund.se
|
- [Lund Waste Collection](/doc/source/lund_se.md) / eservice431601.lund.se
|
||||||
|
- [Mölndal](/doc/source/molndal_se.md) / molndal.se
|
||||||
- [Norrtalje Vatten & Avfall](/doc/source/nvaa_se.md) / sjalvservice.nvaa.se
|
- [Norrtalje Vatten & Avfall](/doc/source/nvaa_se.md) / sjalvservice.nvaa.se
|
||||||
- [North / Middle Bohuslän - Rambo AB](/doc/source/rambo_se.md) / rambo.se
|
- [North / Middle Bohuslän - Rambo AB](/doc/source/rambo_se.md) / rambo.se
|
||||||
- [Region Gotland](/doc/source/gotland_se.md) / gotland.se
|
- [Region Gotland](/doc/source/gotland_se.md) / gotland.se
|
||||||
|
|||||||
@@ -6425,6 +6425,11 @@
|
|||||||
"module": "lund_se",
|
"module": "lund_se",
|
||||||
"default_params": {}
|
"default_params": {}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"title": "M\u00f6lndal",
|
||||||
|
"module": "molndal_se",
|
||||||
|
"default_params": {}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"title": "Norrtalje Vatten & Avfall",
|
"title": "Norrtalje Vatten & Avfall",
|
||||||
"module": "nvaa_se",
|
"module": "nvaa_se",
|
||||||
|
|||||||
@@ -275,7 +275,8 @@
|
|||||||
"zipCode": "Zip Code",
|
"zipCode": "Zip Code",
|
||||||
"garden_cutomer": "Garden Cutomer",
|
"garden_cutomer": "Garden Cutomer",
|
||||||
"app": "App",
|
"app": "App",
|
||||||
"service_provider": "Service Provider"
|
"service_provider": "Service Provider",
|
||||||
|
"facility_id": "Facility Id"
|
||||||
},
|
},
|
||||||
"data_description": {
|
"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."
|
"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."
|
||||||
@@ -522,7 +523,8 @@
|
|||||||
"zipCode": "Zip Code",
|
"zipCode": "Zip Code",
|
||||||
"garden_cutomer": "Garden Cutomer",
|
"garden_cutomer": "Garden Cutomer",
|
||||||
"app": "App",
|
"app": "App",
|
||||||
"service_provider": "Service Provider"
|
"service_provider": "Service Provider",
|
||||||
|
"facility_id": "Facility Id"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||||
|
|
||||||
|
TITLE = "Mölndal"
|
||||||
|
DESCRIPTION = "Source for Mölndal waste collection."
|
||||||
|
URL = "https://molndal.se"
|
||||||
|
TEST_CASES = {"105000": {"facility_id": "105000"}, "109400": {"facility_id": 109400}}
|
||||||
|
|
||||||
|
API_URL = "https://future.molndal.se/FutureWeb/SimpleWastePickup"
|
||||||
|
|
||||||
|
|
||||||
|
class Source:
|
||||||
|
def __init__(self, facility_id: int | str):
|
||||||
|
self.facility_id: str = str(facility_id)
|
||||||
|
|
||||||
|
def fetch(self):
|
||||||
|
url = f"{API_URL}/GetWastePickupSchedule"
|
||||||
|
params = {"address": f"({self.facility_id})"}
|
||||||
|
response = requests.get(url, params=params, timeout=30)
|
||||||
|
response.raise_for_status()
|
||||||
|
|
||||||
|
data = response.json()
|
||||||
|
|
||||||
|
entries = []
|
||||||
|
for item in data["RhServices"]:
|
||||||
|
next_pickup = item["NextWastePickup"]
|
||||||
|
if not next_pickup:
|
||||||
|
continue
|
||||||
|
|
||||||
|
next_pickup_date = datetime.strptime(next_pickup, "%Y-%m-%d").date()
|
||||||
|
waste_type = item["WasteType"]
|
||||||
|
|
||||||
|
entries.append(
|
||||||
|
Collection(date=next_pickup_date, t=waste_type, icon="mdi:trash-can")
|
||||||
|
)
|
||||||
|
|
||||||
|
return entries
|
||||||
34
doc/source/molndal_se.md
Normal file
34
doc/source/molndal_se.md
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Mölndal
|
||||||
|
|
||||||
|
This is a waste collection schedule integration for the Mölndal.
|
||||||
|
Mölndal is using EDPEvent but does not allow for address search.
|
||||||
|
|
||||||
|
## Configuration via configuration.yaml
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
waste_collection_schedule:
|
||||||
|
sources:
|
||||||
|
- name: molndal_se
|
||||||
|
args:
|
||||||
|
facility_id: FACILITY_ID
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuration Variables
|
||||||
|
|
||||||
|
**facility_id**
|
||||||
|
*(number) (required)*
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
waste_collection_schedule:
|
||||||
|
sources:
|
||||||
|
- name: molndal_se
|
||||||
|
args:
|
||||||
|
facility_id: 105000
|
||||||
|
```
|
||||||
|
|
||||||
|
## How to get the correct facility id
|
||||||
|
|
||||||
|
Your facility_id (Anläggning) can be found on invoices from Mölndals stad or
|
||||||
|
by the [Mölndals stad e-tjänst](https://etjanst.molndal.se/oversikt/overview/720).
|
||||||
Reference in New Issue
Block a user