Skip to content

Commit

Permalink
add snaga_mb_si
Browse files Browse the repository at this point in the history
  • Loading branch information
5ila5 committed Sep 21, 2024
1 parent 6c1a3b5 commit c5346c2
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1479,6 +1479,7 @@ If your service provider is not listed, feel free to open a [source request issu
<summary>Slovenia</summary>

- [Moji odpadki, Ljubljana](/doc/source/mojiodpadki_si.md) / mojiodpadki.si
- [Snaga Maribor](/doc/source/snaga_mb_si.md) / snaga-mb.si
</details>

<details>
Expand Down
6 changes: 6 additions & 0 deletions custom_components/waste_collection_schedule/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -9516,6 +9516,12 @@
"module": "mojiodpadki_si",
"default_params": {},
"id": "mojiodpadki_si"
},
{
"title": "Snaga Maribor",
"module": "snaga_mb_si",
"default_params": {},
"id": "snaga_mb_si"
}
],
"Sweden": [
Expand Down
22 changes: 22 additions & 0 deletions custom_components/waste_collection_schedule/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -15637,6 +15637,28 @@
"subarea": "Subarea"
},
"data_description": {}
},
"args_snaga_mb_si": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/snaga_mb_si.md",
"data": {
"calendar_title": "Kalender Titel",
"house_number": "Hausnummer",
"street": "Straße"
},
"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_snaga_mb_si": {
"title": "Quelle Neu Konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/snaga_mb_si.md",
"data": {
"calendar_title": "Kalender Titel",
"house_number": "Hausnummer",
"street": "Straße"
},
"data_description": {}
}
},
"error": {
Expand Down
22 changes: 22 additions & 0 deletions custom_components/waste_collection_schedule/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -15637,6 +15637,28 @@
"subarea": "Subarea"
},
"data_description": {}
},
"args_snaga_mb_si": {
"title": "Configure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/snaga_mb_si.md.",
"data": {
"calendar_title": "Calendar Title",
"house_number": "House Number",
"street": "Street"
},
"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_snaga_mb_si": {
"title": "Reconfigure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/snaga_mb_si.md.",
"data": {
"calendar_title": "Calendar Title",
"house_number": "House Number",
"street": "Street"
},
"data_description": {}
}
},
"error": {
Expand Down
22 changes: 22 additions & 0 deletions custom_components/waste_collection_schedule/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -15612,6 +15612,28 @@
"subarea": "Subarea"
},
"data_description": {}
},
"args_snaga_mb_si": {
"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/snaga_mb_si.md.",
"data": {
"calendar_title": "Nome Calendario",
"house_number": "Civico",
"street": "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_snaga_mb_si": {
"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/snaga_mb_si.md.",
"data": {
"calendar_title": "Nome Calendario",
"house_number": "Civico",
"street": "Strada"
},
"data_description": {}
}
},
"error": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from datetime import date, datetime

import requests
from waste_collection_schedule import Collection # type: ignore[attr-defined]

TITLE = "Snaga Maribor"
DESCRIPTION = "Source for Snaga Maribor."
URL = "https://snaga-mb.si/"
TEST_CASES = {
"Ruska ulica 24": {"street": "Ruska ulica", "house_number": 24},
}


BIN_TYPES = {
"O": "Ost.",
"B": "Bio.",
"U": "Emb.",
"P": "Pap.",
"S": "Stek.",
}
ICON_MAP = {
"O": "mdi:trash-can",
"B": "mdi:leaf",
"U": "mdi:recycle",
"P": "mdi:newspaper",
"S": "mdi:glass-cocktail",
}

BASE_URL = "https://arhiv.snaga-mb.si/mso"
ADDRESS_ID_URL = f"{BASE_URL}/tmRSkjpgG.php"
COLLECTION_URL = f"{BASE_URL}/tmRSk.php"


class Source:
def __init__(self, street: str, house_number: str | int):
self._street: str = street
self._house_number: str | int = house_number

def fetch(self) -> list[Collection]:
args = {
"Naziv": self._street,
"HS": self._house_number,
"IDo": "0",
"_": int(datetime.now().timestamp() * 1000),
}
r = requests.get(ADDRESS_ID_URL, params=args)
r.raise_for_status()
if r.text == "null" or not r.json():
raise Exception("Invalid address")

entries = []
for id in r.json():
address_id = id["OM"]
r = requests.get(
COLLECTION_URL,
params={"sql": address_id, "_": int(datetime.now().timestamp() * 1000)},
)

for collection in r.json():
day = int(collection["Dan"])
month = int(collection["Mesec"])
year = int(collection["Leto"])
date_ = date(year, month, day)
type_char = collection["Odp"]
bin_type = BIN_TYPES.get(type_char, type_char)
icon = ICON_MAP.get(type_char)
entries.append(Collection(date=date_, t=bin_type, icon=icon))

return entries
39 changes: 39 additions & 0 deletions doc/source/snaga_mb_si.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Snaga Maribor

Support for schedules provided by [Snaga Maribor](https://snaga-mb.si/), serving Snaga Maribor, Slovenia.

## Configuration via configuration.yaml

```yaml
waste_collection_schedule:
sources:
- name: snaga_mb_si
args:
street: STREET (Naziv)
house_number: "HOUSE NUMBER (HS)"

```
### Configuration Variables
**street**
*(String) (required)*
**house_number**
*(String | Integer) (required)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: snaga_mb_si
args:
street: Ruska ulica
house_number: "24"

```
## How to get the source argument
Find the parameter of your address using [https://snaga-mb.si/koledar-odvoza-odpadkov/](https://snaga-mb.si/koledar-odvoza-odpadkov/) and write them exactly like on the web page.
2 changes: 1 addition & 1 deletion info.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Waste collection schedules from service provider web sites are updated daily, de
| New Zealand | Auckland Council, Christchurch City Council, Dunedin District Council, Gore, Invercargill & Southland, Hamilton City Council, Horowhenua District Council, Hutt City Council, Napier City Council, Porirua City, Rotorua Lakes Council, Tauranga City Council, Waipa District Council, Wellington City Council |
| 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 |
| 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 |
| 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, Cambridge City Council, Canterbury City Council, Cardiff Council, Carmarthenshire County Council, Central Bedfordshire Council, Charnwood, 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, 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, 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 |
Expand Down

0 comments on commit c5346c2

Please sign in to comment.