mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
added affarserken_se
This commit is contained in:
@@ -389,6 +389,7 @@ Waste collection schedules in the following formats and countries are supported.
|
|||||||
<details>
|
<details>
|
||||||
<summary>Sweden</summary>
|
<summary>Sweden</summary>
|
||||||
|
|
||||||
|
- [Affärsverken](/doc/source/affarsverken_se.md) / affarsverken.se
|
||||||
- [Jönköping - June Avfall & Miljö](/doc/source/juneavfall_se.md) / juneavfall.se
|
- [Jönköping - June Avfall & Miljö](/doc/source/juneavfall_se.md) / juneavfall.se
|
||||||
- [Landskrona - Svalövs Renhållning](/doc/source/lsr_nu.md) / lsr.nu
|
- [Landskrona - Svalövs Renhållning](/doc/source/lsr_nu.md) / lsr.nu
|
||||||
- [Lerum Vatten och Avlopp](/doc/source/lerum_se.md) / vatjanst.lerum.se
|
- [Lerum Vatten och Avlopp](/doc/source/lerum_se.md) / vatjanst.lerum.se
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import requests
|
||||||
|
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
TITLE = "Affärsverken"
|
||||||
|
DESCRIPTION = "Source for Affärsverken."
|
||||||
|
URL = "https://www.affarsverken.se/"
|
||||||
|
|
||||||
|
TEST_CASES = {
|
||||||
|
"Albatrossvägen 5, Ramdala": {"address": "Albatrossvägen 5, Ramdala"},
|
||||||
|
"Amandas Väg 11, Sturkö": {"address": "Amandas Väg 11, Sturkö"},
|
||||||
|
"Uddabygd 107, Rödeby": {"address": "Uddabygd 107, Rödeby"},
|
||||||
|
"Zenitavägen 2, Hasslö": {"address": "Zenitavägen 2, Hasslö"},
|
||||||
|
}
|
||||||
|
|
||||||
|
ICON_MAP = {
|
||||||
|
"Restavfall": "mdi:trash-can",
|
||||||
|
"Matavfall": "mdi:leaf",
|
||||||
|
"Trädgårdsavfall": "mdi:tree"
|
||||||
|
}
|
||||||
|
|
||||||
|
API_URL = "https://kundapi.affarsverken.se/api/v1/open-api/"
|
||||||
|
|
||||||
|
class Source:
|
||||||
|
def __init__(self, address: str):
|
||||||
|
self._address: str = address
|
||||||
|
|
||||||
|
def fetch(self):
|
||||||
|
args = {
|
||||||
|
"address": self._address
|
||||||
|
}
|
||||||
|
|
||||||
|
r = requests.post(f"{API_URL}login", params={"BrandName": "Affarsverken"})
|
||||||
|
r.raise_for_status()
|
||||||
|
headers = {"Authorization": "Bearer " + r.text}
|
||||||
|
|
||||||
|
r = requests.get(f"{API_URL}waste/buildings/search", params=args, headers=headers)
|
||||||
|
data = r.json()
|
||||||
|
building_query = data[0]["query"]
|
||||||
|
|
||||||
|
r = requests.get(f"{API_URL}waste/buildings/" + building_query, headers=headers)
|
||||||
|
r.raise_for_status()
|
||||||
|
services = r.json()["services"]
|
||||||
|
|
||||||
|
entries = []
|
||||||
|
for service in services:
|
||||||
|
if not service["nextPickup"]:
|
||||||
|
continue
|
||||||
|
date = datetime.datetime.strptime(service["nextPickup"], "%Y-%m-%d").date()
|
||||||
|
icon = ICON_MAP.get(service["title"]) # Collection icon
|
||||||
|
type = service["title"]
|
||||||
|
|
||||||
|
# add bin size to description
|
||||||
|
if "binSize" in service and "binSizeUnit" in service:
|
||||||
|
type += ", " + str(service["binSize"]).replace(".0", "") + " "+ str(service["binSizeUnit"])
|
||||||
|
type = type.strip()
|
||||||
|
|
||||||
|
entries.append(Collection(date=date, t=type, icon=icon))
|
||||||
|
|
||||||
|
return entries
|
||||||
@@ -20,7 +20,7 @@ Abfallwirtschaftsbetrieb Ilm-Kreis is supported by the generic [ICS](/doc/source
|
|||||||
pois=3053.8
|
pois=3053.8
|
||||||
```
|
```
|
||||||
|
|
||||||
- Replace the numbers behind `ModID` and `pois` in the example configuration your values.
|
- Replace the numbers behind `ModID` and `pois` in the example configuration with your values from the HTML fragment.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
|
|||||||
34
doc/source/affarsverken_se.md
Normal file
34
doc/source/affarsverken_se.md
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
# Affärsverken
|
||||||
|
|
||||||
|
Support for schedules provided by [Affärsverken](https://www.affarsverken.se/), Sweden.
|
||||||
|
|
||||||
|
## Configuration via configuration.yaml
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
waste_collection_schedule:
|
||||||
|
sources:
|
||||||
|
- name: affarsverken_se
|
||||||
|
args:
|
||||||
|
address: ADDRESS
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuration Variables
|
||||||
|
|
||||||
|
**address**
|
||||||
|
*(String) (required)*
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
waste_collection_schedule:
|
||||||
|
sources:
|
||||||
|
- name: affarsverken_se
|
||||||
|
args:
|
||||||
|
address: Albatrossvägen 5, Ramdala
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## How to get the source argument
|
||||||
|
|
||||||
|
Write you address exactly like on [https://www.affarsverken.se/avfallstjanster/hamtningstider/](https://www.affarsverken.se/avfallstjanster/hamtningstider/).
|
||||||
2
info.md
2
info.md
@@ -28,7 +28,7 @@ Waste collection schedules from service provider web sites are updated daily, de
|
|||||||
| Norway | Min Renovasjon, Movar IKS, Oslo Kommune, ReMidt Orkland muni, Stavanger Kommune |
|
| Norway | Min Renovasjon, Movar IKS, Oslo Kommune, ReMidt Orkland muni, Stavanger Kommune |
|
||||||
| Poland | Ecoharmonogram, Poznań/Koziegłowy/Objezierze/Oborniki, Warsaw, Wrocław |
|
| Poland | Ecoharmonogram, Poznań/Koziegłowy/Objezierze/Oborniki, Warsaw, Wrocław |
|
||||||
| Slovenia | Moji odpadki, Ljubljana |
|
| Slovenia | Moji odpadki, Ljubljana |
|
||||||
| Sweden | Jönköping - June Avfall & Miljö, Landskrona - Svalövs Renhållning, Lerum Vatten och Avlopp, Linköping - Tekniska Verken, Region Gotland, Ronneby Miljöteknik, Samverkan Återvinning Miljö (SÅM), SRV Återvinning, SSAM, Sysav Sophämntning, Uppsala Vatten och Avfall AB, VA Syd Sophämntning |
|
| Sweden | Affärsverken, Jönköping - June Avfall & Miljö, Landskrona - Svalövs Renhållning, Lerum Vatten och Avlopp, Linköping - Tekniska Verken, Region Gotland, Ronneby Miljöteknik, Samverkan Återvinning Miljö (SÅM), SRV Återvinning, SSAM, Sysav Sophämntning, Uppsala Vatten och Avfall AB, VA Syd Sophämntning |
|
||||||
| Switzerland | A-Region, Andwil, Appenzell, Berg, Bühler, Eggersriet, Gais, Gaiserwald, Goldach, Grosswangen, Grub, Heiden, Herisau, Horn, Hundwil, Häggenschwil, Lindau, Lutzenberg, Muolen, Mörschwil, Münchenstein, Rehetobel, Rorschach, Rorschacherberg, Schwellbrunn, Schönengrund, Speicher, Stein, Steinach, Teufen, Thal, Trogen, Tübach, Untereggen, Urnäsch, Wald, Waldkirch, Waldstatt, Wittenbach, Wolfhalden |
|
| Switzerland | A-Region, Andwil, Appenzell, Berg, Bühler, Eggersriet, Gais, Gaiserwald, Goldach, Grosswangen, Grub, Heiden, Herisau, Horn, Hundwil, Häggenschwil, Lindau, Lutzenberg, Muolen, Mörschwil, Münchenstein, Rehetobel, Rorschach, Rorschacherberg, Schwellbrunn, Schönengrund, Speicher, Stein, Steinach, Teufen, Thal, Trogen, Tübach, Untereggen, Urnäsch, Wald, Waldkirch, Waldstatt, Wittenbach, Wolfhalden |
|
||||||
| United Kingdom | Amber Valley Borough Council, Ashfield District Council, Basingstoke and Deane Borough Council, Binzone, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Buckinghamshire Waste Collection - Former Chiltern, South Bucks or Wycombe areas, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of Doncaster Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, East Northamptonshire and Wellingborough, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, Fenland District Council, Fife Council, Gateshead Council, Glasgow City Council, Guildford Borough Council, Harborough District Council, Harlow Council, Herefordshire City Council, Horsham District Council, Huntingdonshire District Council, Leicester City Council, Lewes District Council, Liverpool City Council, London Borough of Bromley, London Borough of Lewisham, London Borough of Merton, Maldon District Council, Manchester City Council, Mid-Sussex District Council, Middlesbrough Council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Herts Council, North Lincolnshire Council, North Somerset Council, Nottingham City Council, Oxford City Council, Peterborough City Council, Richmondshire District Council, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushmoor Borough Council, Salford City Council, Sheffield City Council, South Cambridgeshire District Council, South Derbyshire District Council, South Hams District Council, South Norfolk and Broadland Council, South Oxfordshire District Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Stockton-on-Tees Borough Council, Swindon Borough Council, Telford and Wrekin Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Tonbridge and Malling Borough Council, Uttlesford District Council, Vale of White Horse District Council, Walsall Council, Waverley Borough Council, West Berkshire Council, West Devon Borough Council, West Dunbartonshire Council, Wigan Council, Wiltshire Council, Wyre Forest District Council |
|
| United Kingdom | Amber Valley Borough Council, Ashfield District Council, Basingstoke and Deane Borough Council, Binzone, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Buckinghamshire Waste Collection - Former Chiltern, South Bucks or Wycombe areas, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of Doncaster Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, East Northamptonshire and Wellingborough, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, Fenland District Council, Fife Council, Gateshead Council, Glasgow City Council, Guildford Borough Council, Harborough District Council, Harlow Council, Herefordshire City Council, Horsham District Council, Huntingdonshire District Council, Leicester City Council, Lewes District Council, Liverpool City Council, London Borough of Bromley, London Borough of Lewisham, London Borough of Merton, Maldon District Council, Manchester City Council, Mid-Sussex District Council, Middlesbrough Council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Herts Council, North Lincolnshire Council, North Somerset Council, Nottingham City Council, Oxford City Council, Peterborough City Council, Richmondshire District Council, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushmoor Borough Council, Salford City Council, Sheffield City Council, South Cambridgeshire District Council, South Derbyshire District Council, South Hams District Council, South Norfolk and Broadland Council, South Oxfordshire District Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Stockton-on-Tees Borough Council, Swindon Borough Council, Telford and Wrekin Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Tonbridge and Malling Borough Council, Uttlesford District Council, Vale of White Horse District Council, Walsall Council, Waverley Borough Council, West Berkshire Council, West Devon Borough Council, West Dunbartonshire Council, Wigan Council, Wiltshire Council, Wyre Forest District Council |
|
||||||
| United States of America | City of Pittsburgh, Republic Services, Seattle Public Utilities |
|
| United States of America | City of Pittsburgh, Republic Services, Seattle Public Utilities |
|
||||||
|
|||||||
Reference in New Issue
Block a user