diff --git a/README.md b/README.md index 11ba7f7ff..9097ceaea 100644 --- a/README.md +++ b/README.md @@ -1502,6 +1502,7 @@ If your service provider is not listed, feel free to open a [source request issu - [Gästrike Återvinnare](/doc/source/gastrikeatervinnare_se.md) / gastrikeatervinnare.se - [Jönköping - June Avfall & Miljö](/doc/source/juneavfall_se.md) / juneavfall.se - [Kretslopp Sydost](/doc/source/edpevent_se.md) / kretsloppsydost.se +- [Kristianstad Renhållning](/doc/source/renhallningen_kristianstad_se.md) / renhallningen-kristianstad.se - [Landskrona - Svalövs Renhållning](/doc/source/lsr_nu.md) / lsr.nu - [Lerum Vatten och Avlopp](/doc/source/lerum_se.md) / vatjanst.lerum.se - [Linköping - Tekniska Verken](/doc/source/tekniskaverken_se.md) / tekniskaverken.se diff --git a/custom_components/waste_collection_schedule/sources.json b/custom_components/waste_collection_schedule/sources.json index c22d9e9d5..3dcbcf6c5 100644 --- a/custom_components/waste_collection_schedule/sources.json +++ b/custom_components/waste_collection_schedule/sources.json @@ -9611,6 +9611,12 @@ }, "id": "edpevent_se" }, + { + "title": "Kristianstad Renh\u00e5llning", + "module": "renhallningen_kristianstad_se", + "default_params": {}, + "id": "renhallningen_kristianstad_se" + }, { "title": "Landskrona - Sval\u00f6vs Renh\u00e5llning", "module": "lsr_nu", diff --git a/custom_components/waste_collection_schedule/translations/de.json b/custom_components/waste_collection_schedule/translations/de.json index 54d0b09c9..29811ac16 100644 --- a/custom_components/waste_collection_schedule/translations/de.json +++ b/custom_components/waste_collection_schedule/translations/de.json @@ -9923,6 +9923,26 @@ }, "data_description": {} }, + "args_renhallningen_kristianstad_se": { + "title": "Quelle konfigurieren", + "description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/renhallningen_kristianstad_se.md", + "data": { + "calendar_title": "Kalender Titel", + "street_address": "Street Address" + }, + "data_description": { + "calendar_title": "Ein lesbarerer oder benutzerfreundlicherer Name für den Müllkalender. Wenn nichts angegeben wird, wird der Name der Quelle verwendet." + } + }, + "reconfigure_renhallningen_kristianstad_se": { + "title": "Quelle Neu Konfigurieren", + "description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/renhallningen_kristianstad_se.md", + "data": { + "calendar_title": "Kalender Titel", + "street_address": "Street Address" + }, + "data_description": {} + }, "args_lsr_nu": { "title": "Quelle konfigurieren", "description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/lsr_nu.md", diff --git a/custom_components/waste_collection_schedule/translations/en.json b/custom_components/waste_collection_schedule/translations/en.json index ad36bc632..d3fa177b4 100644 --- a/custom_components/waste_collection_schedule/translations/en.json +++ b/custom_components/waste_collection_schedule/translations/en.json @@ -9923,6 +9923,26 @@ }, "data_description": {} }, + "args_renhallningen_kristianstad_se": { + "title": "Configure Source", + "description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/renhallningen_kristianstad_se.md.", + "data": { + "calendar_title": "Calendar Title", + "street_address": "Street Address" + }, + "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." + } + }, + "reconfigure_renhallningen_kristianstad_se": { + "title": "Reconfigure Source", + "description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/renhallningen_kristianstad_se.md.", + "data": { + "calendar_title": "Calendar Title", + "street_address": "Street Address" + }, + "data_description": {} + }, "args_lsr_nu": { "title": "Configure Source", "description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/lsr_nu.md.", diff --git a/custom_components/waste_collection_schedule/translations/it.json b/custom_components/waste_collection_schedule/translations/it.json index 1de917e6c..042f9c24a 100644 --- a/custom_components/waste_collection_schedule/translations/it.json +++ b/custom_components/waste_collection_schedule/translations/it.json @@ -9912,6 +9912,26 @@ }, "data_description": {} }, + "args_renhallningen_kristianstad_se": { + "title": "Configurazione Sorgente", + "description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. Maggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/renhallningen_kristianstad_se.md.", + "data": { + "calendar_title": "Nome Calendario", + "street_address": "Indirizzo Strada" + }, + "data_description": { + "calendar_title": "Puoi cambiare il nome del calendario della raccolta dei rifiuti, altrimenti di default verra' utilizzato il nome del tuo fornitore di servizi." + } + }, + "reconfigure_renhallningen_kristianstad_se": { + "title": "Riconfigurazione Sorgente", + "description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. Per maggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/renhallningen_kristianstad_se.md.", + "data": { + "calendar_title": "Nome Calendario", + "street_address": "Indirizzo Strada" + }, + "data_description": {} + }, "args_lsr_nu": { "title": "Configurazione Sorgente", "description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. Maggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/lsr_nu.md.", diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/renhallningen_kristianstad_se.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/renhallningen_kristianstad_se.py new file mode 100644 index 000000000..5b2bb0c6d --- /dev/null +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/renhallningen_kristianstad_se.py @@ -0,0 +1,65 @@ +import json +import urllib +from datetime import datetime + +import requests +from waste_collection_schedule import Collection # type: ignore[attr-defined] + +TITLE = "Kristianstad Renhållning" +DESCRIPTION = "Source for Kristianstad Renhållning waste collection." +URL = "https://renhallningen-kristianstad.se" +TEST_CASES = { + "Case_0": {"street_address": "Östra Boulevarden 1"}, + "Case_1": {"street_address": "Grenadjärvägen 1"}, + "Case_2": {"street_address": "Skogsvägen 18"}, + "Case_3": {"street_address": "Önnestadsvägen 7"}, +} + + +class Source: + def __init__(self, street_address): + self._street_address = street_address + + def fetch(self): + headers = { + "Module": "universal", + "Accept": "application/json, text/plain, */*", + "Unit": "dd905ce7-b16d-4422-be36-564169af4035", + } + query_street_address = urllib.parse.quote(self._street_address) + response = requests.get( + f"https://api-universal.appbolaget.se/waste/addresses/search?query={query_street_address}", + headers=headers, + ) + + building_data = json.loads(response.text)["data"] + building_id = None + if building_data and len(building_data) > 0: + building_id = building_data[0]["uuid"] + + if not building_id: + raise ValueError("Unknown street address") + + headers = { + "Module": "universal", + "Accept": "application/json, text/plain, */*", + "Unit": "dd905ce7-b16d-4422-be36-564169af4035", + } + response = requests.get( + f"https://api-universal.appbolaget.se/waste/addresses/{building_id}", + headers=headers, + ) + + data = json.loads(response.text)["data"]["services"] + + entries = [] + for item in data: + waste_type = item["type"] + icon = "mdi:trash-can" + if waste_type == "Trädgårdsavfall": + icon = "mdi:leaf" + next_pickup = item["collection_at"] + next_pickup_date = datetime.fromisoformat(next_pickup).date() + entries.append(Collection(date=next_pickup_date, t=waste_type, icon=icon)) + + return entries diff --git a/doc/source/renhallningen_kristianstad_se.md b/doc/source/renhallningen_kristianstad_se.md new file mode 100644 index 000000000..8e5d444e4 --- /dev/null +++ b/doc/source/renhallningen_kristianstad_se.md @@ -0,0 +1,32 @@ +# Kristianstad Renhållning Sophämntning + +Support for schedules provided by [Kristianstad Renhållning](https://renhallningen-kristianstad.se/villa-fritidshus/tomning-av-sopkarl/tomningschema/), serving the municipality of Kristianstad Sweden. + +## Configuration via configuration.yaml + +```yaml +waste_collection_schedule: + sources: + - name: renhallningen_kristianstad_se + args: + street_address: STREET_ADDRESS +``` + +### Configuration Variables + +**street_address** +*(string) (required)* + +## Example + +```yaml +waste_collection_schedule: + sources: + - name: renhallningen_kristianstad_se + args: + street_address: Östra Boulevarden 1 +``` + +## How to get the source argument + +The source argument is the address to the house with waste collection. The address can be tested [here](https://renhallningen-kristianstad.se/villa-fritidshus/tomning-av-sopkarl/tomningschema/). diff --git a/info.md b/info.md index 73baaeffa..f6609b4bb 100644 --- a/info.md +++ b/info.md @@ -35,7 +35,7 @@ Waste collection schedules from service provider web sites are updated daily, de | Norway | BIR (Bergensområdets Interkommunale Renovasjonsselskap), Fosen Renovasjon, IRiS, Min Renovasjon, Movar IKS, Oslo Kommune, ReMidt Orkland muni, Sandnes Kommune, Stavanger Kommune, Trondheim | | Poland | App Moje Odpady, Bydgoszcz Pronatura, Czerwonak, Murowana Goślina, Oborniki, Ecoharmonogram, Gmina Miękinia, Koziegłowy/Objezierze/Oborniki, MPGK Katowice, Poznań, Warsaw, Wrocław | | Slovenia | Moji odpadki, Ljubljana, Snaga Maribor | -| Sweden | Affärsverken, Boden, Borås Energi och Miljö, EDPEvent - Multi Source, Gästrike Återvinnare, Jönköping - June Avfall & Miljö, Kretslopp Sydost, Landskrona - Svalövs Renhållning, Lerum Vatten och Avlopp, Linköping - Tekniska Verken, Luleå, Lund Waste Collection, Mölndal, Norrtalje Vatten & Avfall, North / Middle Bohuslän - Rambo AB, Region Gotland, Ronneby Miljöteknik, Roslagsvatten, 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, Västervik Miljö & Energi | +| Sweden | Affärsverken, Boden, Borås Energi och Miljö, EDPEvent - Multi Source, Gästrike Återvinnare, Jönköping - June Avfall & Miljö, Kretslopp Sydost, Kristianstad Renhållning, Landskrona - Svalövs Renhållning, Lerum Vatten och Avlopp, Linköping - Tekniska Verken, Luleå, Lund Waste Collection, Mölndal, Norrtalje Vatten & Avfall, North / Middle Bohuslän - Rambo AB, Region Gotland, Ronneby Miljöteknik, Roslagsvatten, 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, Västervik Miljö & Energi | | Switzerland | A-Region, Alchenstorf, Andwil, Appenzell, Berg, Bühler, Canton of Zürich, Eggersriet, Gais, Gaiserwald, Gasel, Goldach, Grosswangen, Grub, Heiden, Herisau, Horn, Hundwil, Häggenschwil, Köniz, Köniz, Liebefeld, Lindau, Lutzenberg, Mittelhäusern, Muolen, Mörschwil, Münchenstein, Münsingen BE, Switzerland, Nieder-/Oberscherli, Niederwangen, Oberwangen, Rapperswil, Real Luzern, Real Luzern, Rehetobel, Rorschach, Rorschacherberg, Sammelkalender.ch, Schliern, Schwellbrunn, Schönengrund, Speicher, Spiegel, Stadt Bülach, Stein, Steinach, Teufen, Thal, Thörishaus, Trogen, Tübach, Untereggen, Urnäsch, Wabern, Wald, Waldkirch, Waldstatt, Winterthur, Wittenbach, Wolfhalden, ZAKU Entsorgung, Zeba, ZKRI | | United Kingdom | Aberdeenshire Council, Adur & Worthing Councils, Allerdale Borough Council, Amber Valley Borough Council, Anglesey, Antrim and Newtownabbey, Apps by imactivate, Ards and North Down Borough Council, Arun District Council, Ashfield District Council, Ashford Borough Council, Aylesbury Vale District Council, Barnsley Metropolitan Borough Council, Basildon Council, Basingstoke and Deane Borough Council, Bath & North East Somerset Council, BCP Council, Bedford Borough Council, Binzone, Birmingham City Council, Blackburn with Darwen Borough Council, Blackpool Council, Blaenau Gwent County Borough Council, Borough Council of King's Lynn & West Norfolk, Borough of Broxbourne Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Brent Council, Bristol City Council, Broadland District Council, Bromsgrove City Council, Broxtowe Borough Council, Buckinghamshire: Former (Chiltern, South Bucks, Wycombe), Burnley Council, Bury Council, Caerphilly, Wales, Cambridge City Council, Canterbury City Council, Cardiff Council, Carmarthenshire County Council, Central Bedfordshire Council, Charnwood, Chelmsford City Council, Cherwell District Council, Cheshire East Council, Cheshire West and Chester Council, Chesterfield Borough Council, Chichester District Council, City of Doncaster Council, City Of Lincoln Council, City of York Council, Colchester City Council, Conwy County Borough Council, Cornwall Council, Crawley Borough Council (myCrawley), Croydon Council, Darlington Borough Council, Denbighshire County Council, Deprecated: Buckinghamshire, Derby City Council, Dorset Council, Dover District Council, Dudley Metropolitan Borough Council, Dundee City Council, Dundee MyBins, Durham County Council, East Ayrshire Council, East Cambridgeshire District Council, East Devon District Council, East Herts Council, East Lothian, East Northamptonshire and Wellingborough, East Renfrewshire Council, East Riding of Yorkshire Council, Eastbourne Borough Council, Eastleigh Borough Council, Elmbridge Borough Council, Environment First, Exeter City Council, Falkirk, Fareham Borough Council, FCC Environment, Fenland, Fenland District Council, Fife Council, Flintshire, Folkestone and Hythe District Councol, Fylde Council, Gateshead Council, Gedling Borough Council (unofficial), Glasgow City Council, Guildford Borough Council, Gwynedd, Harborough District Council, Haringey Council, Harlow Council, Hart District Council, Herefordshire City Council, High Peak Borough Council, Highland, Horsham District Council, Hull City Council, Huntingdonshire District Council, Islington Council, iTouchVision, Itouchvision Source using the encrypted API, Joint Waste Solutions, Kirklees Council, Lancaster City Council, Leeds, Leicester City Council, Lewes District Council, Lichfield District Council, Lisburn and Castlereagh City Council, Liverpool City Council, London Borough of Barking and Dagenham, London Borough of Bexley, London Borough of Bromley, London Borough of Camden, London Borough of Harrow, London Borough of Hounslow, London Borough of Lewisham, London Borough of Merton, London Borough of Newham, Luton, Maidstone Borough Council, Maldon District Council, Malvern Hills, Malvern Hills District Council, Manchester City Council, Mansfield District Council, Mendip District Council, Mid-Sussex District Council, Middlesbrough Council, Milton Keynes council, Moray Council, Newark & Sherwood District Council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, Newport City Council, North Ayrshire Council, North Herts Council, North Kesteven District Council, North Lincolnshire Council, North Northamptonshire council, North Somerset Council, North West Leicestershire District Council, North Yorkshire Council - Hambleton, North Yorkshire Council - Harrogate, North Yorkshire Council - Scarborough, North Yorkshire Council - Selby, Nottingham City Council, Oadby and Wigston Council, Oxford City Council, Pembrokeshire County Council, Peterborough City Council, Portsmouth City Council, Reading Council, Redbridge Council, Reigate & Banstead Borough Council, Renfrewshire Council, Rhondda Cynon Taf County Borough Council, Richmondshire District Council, Rotherham, Rotherham Metropolitan Borough Council, Runnymede Borough Council, Rushcliffe Brough Council, Rushmoor Borough Council, Salford City Council, Sedgemoor District Council, Sheffield City Council, Shropshire Council, Solihull Council, Somerset Council, Somerset County Council, Somerset West & Taunton District Council, South Cambridgeshire District Council, South Derbyshire District Council, South Gloucestershire Council, South Hams District Council, South Holland District Council, South Kesteven District Council, South Norfolk Council, South Oxfordshire District Council, South Somerset District Council, South Tyneside Council, Southampton City Council, St Albans City & District Council, Stafford Borough Council, Stevenage Borough Council, Stirling.gov.uk, Stockport Council, Stockton-on-Tees Borough Council, Stoke-on-Trent, Stratford District Council, Stroud District Council, Surrey Heath Borough Council, Sutton Council, London, Swansea Council, Swindon Borough Council, Tameside Metropolitan Borough Council, Telford and Wrekin Council, Test Valley Borough Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Tonbridge and Malling Borough Council, Tunbridge Wells, UK Bin Collection Schedule (UKBCD) project, Uttlesford District Council, Vale of Glamorgan Council, Vale of White Horse District Council, Walsall Council, Warrington Borough Council, Warwick District Council, Waverley Borough Council, Wealden District Council, Welwyn Hatfield Borough Council, West Berkshire Council, West Devon Borough Council, West Dunbartonshire Council, West Northamptonshire council, West Oxfordshire District Council, West Suffolk Council, Westmorland & Furness Council, Barrow area, Westmorland & Furness Council, South Lakeland area, Wigan Council, Wiltshire Council, Windsor and Maidenhead, Wirral Council, Woking Borough Council, Wokingham Borough Council, Worcester City, Wychavon, Wychavon District Council (Deprecated), Wyre Borough Council, Wyre Forest District Council | | United States of America | Albuquerque, New Mexico, USA, City of Austin, TX, City of Bloomington, City of Cambridge, City of Gastonia, NC, City of Georgetown, TX, City of McKinney, TX, City of Oklahoma City (unofficial), City of Pittsburgh, Louisville, Kentucky, USA, New York City, Newark, Delaware, USA, Olympia, Washington, USA, ReCollect, Recycle Coach, Republic Services, Round Rock Texas, Seattle Public Utilities, Tucson, Arizona, USA, University Park, TX, Waste Connections |