mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 03:04:09 +01:00
Added samiljo_se and updated readme.md+info.md
This commit is contained in:
@@ -195,8 +195,8 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Landkreis Rotenburg (Wümme)](/doc/source/abfall_io.md) / lk-awr.de
|
||||
- [Landkreis Roth](/doc/source/c_trace_de.md) / landratsamt-roth.de
|
||||
- [Landkreis Schweinfurt](/doc/source/awido_de.md) / landkreis-schweinfurt.de
|
||||
- [Landkreis Schwäbisch Hall](/doc/source/lrasha_de.md) / lrasha.de
|
||||
- [Landkreis Schwäbisch Hall](/doc/source/cmcitymedia_de.md) / sslslim.cmcitymedia.de/v1
|
||||
- [Landkreis Schwäbisch Hall](/doc/source/lrasha_de.md) / lrasha.de
|
||||
- [Landkreis Sigmaringen](/doc/source/abfall_io.md) / landkreis-sigmaringen.de
|
||||
- [Landkreis Südliche Weinstraße](/doc/source/awido_de.md) / suedliche-weinstrasse.de
|
||||
- [Landkreis Tirschenreuth](/doc/source/awido_de.md) / kreis-tir.de
|
||||
@@ -351,6 +351,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Linköping - Tekniska Verken](/doc/source/tekniskaverken_se.md) / tekniskaverken.se
|
||||
- [Region Gotland](/doc/source/gotland_se.md) / gotland.se
|
||||
- [Ronneby Miljöteknik](/doc/source/miljoteknik_se.md) / fyrfackronneby.se
|
||||
- [Samverkan Återvinning Miljö (SÅM)](/doc/source/samiljo_se.md) / samiljo.se
|
||||
- [SRV Återvinning](/doc/source/srvatervinning_se.md) / srvatervinning.se
|
||||
- [SSAM](/doc/source/ssam_se.md) / ssam.se
|
||||
- [Sysav Sophämntning](/doc/source/sysav_se.md) / sysav.se
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
import datetime
|
||||
from waste_collection_schedule import Collection
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
import urllib.parse
|
||||
|
||||
TITLE = "Samverkan Återvinning Miljö (SÅM)"
|
||||
DESCRIPTION = "Source script for samiljo.se"
|
||||
URL = "https://www.samiljo.se"
|
||||
|
||||
TEST_CASES = {
|
||||
"Test1": {"city": "Reftele", "street": "Storgatan 6"},
|
||||
"Test2": {"city": "Värnamo", "street": "Västra Kyrkogårdsgatan 2"},
|
||||
"Test3": {"city": "Burseryd", "street": "Storgatan 1"},
|
||||
}
|
||||
|
||||
API_URLS = {
|
||||
"address_search": "https://webbservice.indecta.se/kunder/sam/kalender/basfiler/laddaadresser.php",
|
||||
"collection": "https://webbservice.indecta.se/kunder/sam/kalender/basfiler/onlinekalender.php"
|
||||
}
|
||||
|
||||
ICON_MAP = {
|
||||
"HKARL1": "mdi:trash-can",
|
||||
"HKARL1-H": "mdi:trash-can",
|
||||
"HKARL2": "mdi:recycle",
|
||||
"HKARL2-H": "mdi:recycle",
|
||||
"HMAT": "mdi:leaf",
|
||||
"HMAT-H": "mdi:leaf",
|
||||
"HREST": "mdi:trash-can",
|
||||
"HREST-H": "mdi:trash-can",
|
||||
"HOSORT": "mdi:trash-can",
|
||||
"HOSORT-H": "mdi:trash-can",
|
||||
}
|
||||
|
||||
NAME_MAP = {
|
||||
"HKARL1": "Fyrfackskärl 1", # Matavfall, Restavfall, Tidningar & Färgat glas
|
||||
"HKARL1-H": "Fyrfackskärl 1 (Helgvecka - hämtningsdagen kan avika)", # Matavfall, Restavfall, Tidningar & Färgat glas
|
||||
"HKARL2": "Fyrfackskärl 2", # Förpackningar av Papper, Plast & Metall samt Ofärgat glas
|
||||
"HKARL2-H": "Fyrfackskärl 2 (Helgvecka - hämtningsdagen kan avika)", # Förpackningar av Papper, Plast & Metall samt Ofärgat glas
|
||||
"HMAT": "Matavfall",
|
||||
"HMAT-H": "Matavfall (Helgvecka - hämtningsdagen kan avika)",
|
||||
"HREST": "Restavfall",
|
||||
"HREST-H": "Restavfall (Helgvecka - hämtningsdagen kan avika)",
|
||||
"HOSORT": "Blandat Mat- och Restavfall",
|
||||
"HOSORT-H": "Blandat Mat- och Restavfall (Helgvecka - hämtningsdagen kan avika)",
|
||||
}
|
||||
|
||||
MONTH_MAP = {
|
||||
"Januari": 1,
|
||||
"Februari": 2,
|
||||
"Mars": 3,
|
||||
"April": 4,
|
||||
"Maj": 5,
|
||||
"Juni": 6,
|
||||
"Juli": 7,
|
||||
"Augusti": 8,
|
||||
"September": 9,
|
||||
"Oktober": 10,
|
||||
"November": 11,
|
||||
"December": 12
|
||||
}
|
||||
|
||||
class Source:
|
||||
def __init__(self, street, city):
|
||||
self.street = street
|
||||
self.city = city
|
||||
|
||||
|
||||
def fetch(self):
|
||||
#request to get an adresslist containing the parameter A used for the wasteschedule request.
|
||||
adresslist = requests.get(API_URLS["address_search"], params={"svar": self.street})
|
||||
|
||||
adresstaddict = (self.street.lower(), self.city.lower())
|
||||
adresstadjoined = "|".join(adresstaddict)
|
||||
adresslistalines = adresslist.text.lower().splitlines()
|
||||
for line in adresslistalines:
|
||||
if adresstadjoined in line:
|
||||
A = line.split("|")[-1]
|
||||
|
||||
payload = {
|
||||
"hsG": self.street,
|
||||
"hsO": self.city,
|
||||
"nrA": A
|
||||
}
|
||||
payload_str = urllib.parse.urlencode(payload, encoding="cp1252")
|
||||
#request for the wasteschedule
|
||||
wasteschedule = requests.get(API_URLS["collection"], params=payload_str)
|
||||
|
||||
soup = BeautifulSoup(wasteschedule.text, "html.parser")
|
||||
|
||||
entries = []
|
||||
#get a list of all tags with waste collection days for the current year
|
||||
for wasteday in soup.find_all("td", "styleDayHit"):
|
||||
wasteday_wastetype = wasteday.parent.parent
|
||||
#find month and year for given day
|
||||
monthyear = wasteday_wastetype.find_previous("td", "styleMonthName").contents
|
||||
monthyear_parts = str(monthyear).split('-')
|
||||
month = MONTH_MAP[monthyear_parts[0].strip(" []/'")]
|
||||
year = int(monthyear_parts[1].strip(" []/'"))
|
||||
day = int(str(wasteday_wastetype.find("div", "styleInteIdag").contents).strip(" []/'"))
|
||||
#list of bins collected for given day
|
||||
for td in wasteday_wastetype.contents[3].find_all("td"):
|
||||
if td.has_attr("class"):
|
||||
waste = str(td.get_attribute_list('class')).strip(" []/'")
|
||||
entries.append(
|
||||
Collection(
|
||||
t = NAME_MAP.get(waste),
|
||||
#t = waste, #used when identifying new types of bins
|
||||
date = datetime.date(year, month, day),
|
||||
icon = ICON_MAP.get(waste),
|
||||
)
|
||||
)
|
||||
return entries
|
||||
39
doc/source/samiljo_se.md
Normal file
39
doc/source/samiljo_se.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# Samverkan Återvinning Miljö (SÅM)
|
||||
|
||||
Support for schedules provided by [Samverkan Återvinning Miljö (SÅM)](https://samiljo.se/avfallshamtning/hamtningskalender/), serving the municipality of Gislaved, Gnosjö, Vaggeryd and Värnamo, Sweden.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: samiljo_se
|
||||
args:
|
||||
street: STREET_NAME
|
||||
city: CITY_NAME
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**street**
|
||||
*(string) (required)*
|
||||
|
||||
**city**
|
||||
*(string) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: samiljo_se
|
||||
args:
|
||||
street: Storgatan 1
|
||||
city: Burseryd
|
||||
```
|
||||
|
||||
|
||||
## How to get the source argument
|
||||
|
||||
The source argument is the street including number and the city to the house with waste collection.
|
||||
The address can be tested [here](https://samiljo.se/avfallshamtning/hamtningskalender/).
|
||||
2
info.md
2
info.md
@@ -27,7 +27,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 |
|
||||
| Poland | Ecoharmonogram, Poznań/Koziegłowy/Objezierze/Oborniki, Warsaw |
|
||||
| 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, SRV Återvinning, SSAM, Sysav Sophämntning, VA Syd Sophämntning |
|
||||
| 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, 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 |
|
||||
| United Kingdom | Amber Valley Borough Council, Ashfield District Council, Basingstoke and Deane Borough Council, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, Glasgow City Council, Guildford Borough Council, Harborough District Council, Harlow Council, Herefordshire City Council, Horsham District Council, Huntingdonshire District Council, Lewes District Council, London Borough of Lewisham, Maldon District Council, Manchester City Council, Mid-Sussex District Council, Middlesbrough Council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Somerset Council, Nottingham City Council, Oxford City Council, Peterborough City Council, Richmondshire District 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, Southampton City Council, Stevenage Borough Council, Stockport Council, Telford and Wrekin Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Uttlesford District Council, Walsall Council, Waverley Borough Council, West Berkshire Council, West Devon Borough Council, Wiltshire Council, Wyre Forest District Council |
|
||||
| United States of America | City of Pittsburgh, Republic Services, Seattle Public Utilities |
|
||||
|
||||
Reference in New Issue
Block a user