mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 03:04:09 +01:00
add Fosen Norway
This commit is contained in:
@@ -1176,6 +1176,7 @@ If your service provider is not listed, feel free to open a [source request issu
|
||||
<summary>Norway</summary>
|
||||
|
||||
- [BIR (Bergensområdets Interkommunale Renovasjonsselskap)](/doc/source/bir_no.md) / bir.no
|
||||
- [Fosen Renovasjon](/doc/source/fosenrenovasjon_no.md) / fosenrenovasjon.no
|
||||
- [IRiS](/doc/source/iris_salten_no.md) / iris-salten.no
|
||||
- [Min Renovasjon](/doc/source/minrenovasjon_no.md) / norkart.no
|
||||
- [Movar IKS](/doc/source/movar_no.md) / movar.no
|
||||
|
||||
@@ -6302,6 +6302,11 @@
|
||||
"module": "bir_no",
|
||||
"default_params": {}
|
||||
},
|
||||
{
|
||||
"title": "Fosen Renovasjon",
|
||||
"module": "fosenrenovasjon_no",
|
||||
"default_params": {}
|
||||
},
|
||||
{
|
||||
"title": "IRiS",
|
||||
"module": "iris_salten_no",
|
||||
|
||||
@@ -276,7 +276,8 @@
|
||||
"garden_cutomer": "Garden Cutomer",
|
||||
"app": "App",
|
||||
"service_provider": "Service Provider",
|
||||
"facility_id": "Facility Id"
|
||||
"facility_id": "Facility Id",
|
||||
"abfall": "Abfall"
|
||||
},
|
||||
"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."
|
||||
@@ -524,7 +525,8 @@
|
||||
"garden_cutomer": "Garden Cutomer",
|
||||
"app": "App",
|
||||
"service_provider": "Service Provider",
|
||||
"facility_id": "Facility Id"
|
||||
"facility_id": "Facility Id",
|
||||
"abfall": "Abfall"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
from datetime import datetime
|
||||
from urllib.parse import quote
|
||||
|
||||
import requests
|
||||
from waste_collection_schedule import Collection
|
||||
|
||||
TITLE = "Fosen Renovasjon"
|
||||
DESCRIPTION = "Source for Fosen Renovasjon."
|
||||
URL = "https://fosenrenovasjon.no/"
|
||||
TEST_CASES = {"Lysøysundveien 117": {"address": "Lysøysundveien 117"}}
|
||||
|
||||
|
||||
ICON_MAP = {
|
||||
"Restavfall til forbrenning": "mdi:trash-can",
|
||||
"Matavfall": "mdi:leaf",
|
||||
"Papir og plastemballasje": "mdi:recycle",
|
||||
}
|
||||
|
||||
|
||||
ADDRESS_URL = "https://fosen.renovasjonsportal.no/api/address/{address}"
|
||||
COLLECTIONS_URL = ADDRESS_URL + "/details"
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, address: str):
|
||||
self._address = address.lower().strip()
|
||||
self._address_id: str | None = None
|
||||
|
||||
def _fetch_address_id(self):
|
||||
url = ADDRESS_URL.format(address=quote(self._address))
|
||||
r = requests.get(url)
|
||||
r.raise_for_status()
|
||||
data = r.json()
|
||||
for address in data["searchResults"]:
|
||||
if address["title"].lower().strip() == self._address:
|
||||
self._address_id = address["id"]
|
||||
return
|
||||
|
||||
raise ValueError("Address not found", self._address)
|
||||
|
||||
def fetch(self) -> list[Collection]:
|
||||
new_id = False
|
||||
if self._address_id is None:
|
||||
new_id = False
|
||||
self._fetch_address_id()
|
||||
try:
|
||||
return self._get_collections()
|
||||
except Exception:
|
||||
if new_id:
|
||||
raise
|
||||
self._fetch_address_id()
|
||||
return self._get_collections()
|
||||
|
||||
def _get_collections(self) -> list[Collection]:
|
||||
if self._address_id is None:
|
||||
raise ValueError("Address not found", self._address)
|
||||
url = COLLECTIONS_URL.format(address=self._address_id)
|
||||
r = requests.get(url)
|
||||
r.raise_for_status()
|
||||
data = r.json()
|
||||
|
||||
entries: list[Collection] = []
|
||||
for d in data["disposals"]:
|
||||
date = datetime.strptime(d["date"], "%Y-%m-%dT%H:%M:%S").date()
|
||||
entries.append(
|
||||
Collection(date=date, t=d["fraction"], icon=ICON_MAP.get(d["fraction"]))
|
||||
)
|
||||
|
||||
return entries
|
||||
34
doc/source/fosenrenovasjon_no.md
Normal file
34
doc/source/fosenrenovasjon_no.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Fosen Renovasjon
|
||||
|
||||
Support for schedules provided by [Fosen Renovasjon](https://fosenrenovasjon.no/), serving Fosen, Norway.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: fosenrenovasjon_no
|
||||
args:
|
||||
address: ADDRESS
|
||||
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**address**
|
||||
*(String) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: fosenrenovasjon_no
|
||||
args:
|
||||
address: Lysøysundveien 117
|
||||
|
||||
```
|
||||
|
||||
## How to get the source argument
|
||||
|
||||
Visit <https://fosenrenovasjon.no/tommekalender/#!/main> and search for your address, then use the address spelled exactly as the autocomplete suggests.
|
||||
2
info.md
2
info.md
@@ -31,7 +31,7 @@ Waste collection schedules from service provider web sites are updated daily, de
|
||||
| Luxembourg | Esch-sur-Alzette |
|
||||
| Netherlands | ACV Group, Alpen an den Rijn, Area Afval, Avalex, Avri, Bar Afvalbeheer, 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, HVC Groep, Meerlanden, Mijn Blink, PreZero, Purmerend, RAD BV, Reinis, Spaarnelanden, Twente Milieu, 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, Porirua City, Tauranga City Council, Waipa District Council, Wellington City Council |
|
||||
| Norway | BIR (Bergensområdets Interkommunale Renovasjonsselskap), IRiS, Min Renovasjon, Movar IKS, Oslo Kommune, ReMidt Orkland muni, Sandnes Kommune, Stavanger Kommune, Trondheim |
|
||||
| Norway | BIR (Bergensområdets Interkommunale Renovasjonsselskap), Fosen Renovasjon, IRiS, Min Renovasjon, Movar IKS, Oslo Kommune, ReMidt Orkland muni, Sandnes Kommune, Stavanger Kommune, Trondheim |
|
||||
| Poland | Bydgoszcz Pronatura, Ecoharmonogram, Gmina Miękinia, Koziegłowy/Objezierze/Oborniki, Poznań, Warsaw, Wrocław |
|
||||
| Slovenia | Moji odpadki, Ljubljana |
|
||||
| Sweden | Affärsverken, Boden, Borås Energi och Miljö, EDPEvent - Multi Source, Gästrike Återvinnare, Jönköping - June Avfall & Miljö, Landskrona - Svalövs Renhållning, Lerum Vatten och Avlopp, Linköping - Tekniska Verken, Lund Waste Collection, Mölndal, Norrtalje Vatten & Avfall, North / Middle Bohuslän - Rambo AB, Region Gotland, Ronneby Miljöteknik, Samverkan Återvinning Miljö (SÅM), Skellefteå, SRV Återvinning, SSAM (Deprecated), SSAM Södra Smalånds Avfall & Miljö, Sysav Sophämntning, Uppsala Vatten, Uppsala Vatten och Avfall AB (Deprecated), VA Syd Sophämntning, VIVAB Sophämtning |
|
||||
|
||||
Reference in New Issue
Block a user