Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding dedicated mijnafvalwijzer nl #3244

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ If your service provider is not listed, feel free to open a [source request issu

- ['s-Hertogenbosch](/doc/source/afvalstoffendienst_nl.md) / afvalstoffendienst.nl
- [ACV Group](/doc/source/ximmio_nl.md) / acv-afvalkalender.nl
- [Afval Wijzer](/doc/ics/mijnafvalwijzer_nl.md) / mijnafvalwijzer.nl
- [Afval Wijzer](/doc/source/mijnafvalwijzer_nl.md) / mijnafvalwijzer.nl
- [Afvalstoffendienst.nl](/doc/source/afvalstoffendienst_nl.md) / afvalstoffendienst.nl
- [Alpen an den Rijn](/doc/source/hvcgroep_nl.md) / alphenaandenrijn.nl
- [Altena](/doc/source/afvalstoffendienst_nl.md) / altena.afvalstoffendienstkalender.nl
Expand Down
4 changes: 2 additions & 2 deletions custom_components/waste_collection_schedule/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -11189,9 +11189,9 @@
},
{
"title": "Afval Wijzer",
"module": "ics",
"module": "mijnafvalwijzer_nl",
"default_params": {},
"id": "ics_mijnafvalwijzer_nl"
"id": "mijnafvalwijzer_nl"
},
{
"title": "Afvalstoffendienst.nl",
Expand Down
38 changes: 10 additions & 28 deletions custom_components/waste_collection_schedule/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -9662,45 +9662,27 @@
},
"data_description": {}
},
"args_ics_mijnafvalwijzer_nl": {
"args_mijnafvalwijzer_nl": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. \n\n- Visit https://www.mijnafvalwijzer.nl and search for your location. \n- Click on the calendar icon button to get a webcal link.\n- Use this url as the `url` parameter.\n\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/mijnafvalwijzer_nl.md",
"description": "Konfiguriere deinen Service Provider. \n\nINPUT ARGUMENTS ARE THE SAME AS THE ONES YOU FILL IN FOR YOUR HOME ADDRESS AT: https://www.mijnafvalwijzer.nl/\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mijnafvalwijzer_nl.md",
"data": {
"calendar_title": "Kalender Titel",
"file": "Datei",
"headers": "Headers",
"method": "Methode",
"offset": "Offset",
"params": "Parameter",
"regex": "Regulärer Ausdruck",
"split_at": "Trennen bei",
"title_template": "Titelvorlage",
"url": "URL",
"verify_ssl": "SSL-Verifizierung aktivieren",
"version": "Version",
"year_field": "Jahresfeld"
"add": "Add",
"number": "Nummer",
"postcode": "PLZ"
},
"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_ics_mijnafvalwijzer_nl": {
"reconfigure_mijnafvalwijzer_nl": {
"title": "Quelle Neu Konfigurieren",
"description": "Konfiguriere deinen Service Provider. \n\n- Visit https://www.mijnafvalwijzer.nl and search for your location. \n- Click on the calendar icon button to get a webcal link.\n- Use this url as the `url` parameter.\n\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/mijnafvalwijzer_nl.md",
"description": "Konfiguriere deinen Service Provider. \n\nINPUT ARGUMENTS ARE THE SAME AS THE ONES YOU FILL IN FOR YOUR HOME ADDRESS AT: https://www.mijnafvalwijzer.nl/\n\nMehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mijnafvalwijzer_nl.md",
"data": {
"calendar_title": "Kalender Titel",
"file": "Datei",
"headers": "Headers",
"method": "Methode",
"offset": "Offset",
"params": "Parameter",
"regex": "Regulärer Ausdruck",
"split_at": "Trennen bei",
"title_template": "Titelvorlage",
"url": "URL",
"verify_ssl": "SSL-Verifizierung aktivieren",
"version": "Version",
"year_field": "Jahresfeld"
"add": "Add",
"number": "Nummer",
"postcode": "PLZ"
},
"data_description": {}
},
Expand Down
38 changes: 10 additions & 28 deletions custom_components/waste_collection_schedule/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9671,45 +9671,27 @@
},
"data_description": {}
},
"args_ics_mijnafvalwijzer_nl": {
"args_mijnafvalwijzer_nl": {
"title": "Configure Source",
"description": "Configure your service provider. \n\n- Visit https://www.mijnafvalwijzer.nl and search for your location. \n- Click on the calendar icon button to get a webcal link.\n- Use this url as the `url` parameter.\n\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/mijnafvalwijzer_nl.md.",
"description": "Configure your service provider. \n\nINPUT ARGUMENTS ARE THE SAME AS THE ONES YOU FILL IN FOR YOUR HOME ADDRESS AT: https://www.mijnafvalwijzer.nl/\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mijnafvalwijzer_nl.md.",
"data": {
"calendar_title": "Calendar Title",
"file": "File",
"headers": "Headers",
"method": "Method",
"offset": "Offset",
"params": "Parameters",
"regex": "Regex",
"split_at": "Split At",
"title_template": "Title Template",
"url": "Url",
"verify_ssl": "Verify Ssl",
"version": "Version",
"year_field": "Year Field"
"add": "Add",
"number": "Number",
"postcode": "Postcode"
},
"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_ics_mijnafvalwijzer_nl": {
"reconfigure_mijnafvalwijzer_nl": {
"title": "Reconfigure Source",
"description": "Configure your service provider. \n\n- Visit https://www.mijnafvalwijzer.nl and search for your location. \n- Click on the calendar icon button to get a webcal link.\n- Use this url as the `url` parameter.\n\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/mijnafvalwijzer_nl.md.",
"description": "Configure your service provider. \n\nINPUT ARGUMENTS ARE THE SAME AS THE ONES YOU FILL IN FOR YOUR HOME ADDRESS AT: https://www.mijnafvalwijzer.nl/\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mijnafvalwijzer_nl.md.",
"data": {
"calendar_title": "Calendar Title",
"file": "File",
"headers": "Headers",
"method": "Method",
"offset": "Offset",
"params": "Parameters",
"regex": "Regex",
"split_at": "Split At",
"title_template": "Title Template",
"url": "Url",
"verify_ssl": "Verify Ssl",
"version": "Version",
"year_field": "Year Field"
"add": "Add",
"number": "Number",
"postcode": "Postcode"
},
"data_description": {}
},
Expand Down
38 changes: 10 additions & 28 deletions custom_components/waste_collection_schedule/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -9644,45 +9644,27 @@
},
"data_description": {}
},
"args_ics_mijnafvalwijzer_nl": {
"args_mijnafvalwijzer_nl": {
"title": "Configurazione Sorgente",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\n- Visit https://www.mijnafvalwijzer.nl and search for your location. \n- Click on the calendar icon button to get a webcal link.\n- Use this url as the `url` parameter.\n\n\nMaggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/mijnafvalwijzer_nl.md.",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\nINPUT ARGUMENTS ARE THE SAME AS THE ONES YOU FILL IN FOR YOUR HOME ADDRESS AT: https://www.mijnafvalwijzer.nl/\n\nMaggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mijnafvalwijzer_nl.md.",
"data": {
"calendar_title": "Nome Calendario",
"file": "Nome File",
"headers": "Headers",
"method": "Metodo",
"offset": "Offset",
"params": "Parametri",
"regex": "Regex",
"split_at": "Split At",
"title_template": "Title Template",
"url": "Url",
"verify_ssl": "Verifica SSL",
"version": "Versione",
"year_field": "Year Field"
"add": "Add",
"number": "Numero",
"postcode": "Codice Postale CAP"
},
"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_ics_mijnafvalwijzer_nl": {
"reconfigure_mijnafvalwijzer_nl": {
"title": "Riconfigurazione Sorgente",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\n- Visit https://www.mijnafvalwijzer.nl and search for your location. \n- Click on the calendar icon button to get a webcal link.\n- Use this url as the `url` parameter.\n\n\nPer maggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/mijnafvalwijzer_nl.md.",
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. \n\nINPUT ARGUMENTS ARE THE SAME AS THE ONES YOU FILL IN FOR YOUR HOME ADDRESS AT: https://www.mijnafvalwijzer.nl/\n\nPer maggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mijnafvalwijzer_nl.md.",
"data": {
"calendar_title": "Nome Calendario",
"file": "Nome File",
"headers": "Headers",
"method": "Metodo",
"offset": "Offset",
"params": "Parametri",
"regex": "Regex",
"split_at": "Split At",
"title_template": "Title Template",
"url": "Url",
"verify_ssl": "Verifica SSL",
"version": "Versione",
"year_field": "Year Field"
"add": "Add",
"number": "Numero",
"postcode": "Codice Postale CAP"
},
"data_description": {}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import re
import datetime
import requests
from bs4 import BeautifulSoup
from waste_collection_schedule import Collection # type: ignore[attr-defined]
from waste_collection_schedule.service.ICS import ICS

TITLE = "Afval Wijzer"
DESCRIPTION = "Source for all cities regions supported in mijnafvalwijzer.nl"
URL = "https://www.mijnafvalwijzer.nl"
TEST_CASES = {
"Eindhoven1": {"postcode": "5651AN", "number": "34", "add": "A"},
"Eindhoven2": {"postcode": "5651AN", "number": "34"},
"Tilburg": {"postcode": "5014NN", "number": "174"},
"Meierijstad": {"postcode": "5481LR", "number": "6"},
"Rotterdam": {"postcode": "3067AL", "number": "53"},
}

ICON_MAP = { # Optional: Dict of waste types and suitable mdi icons
"Restafval": "mdi:trash-can",
"Papier en karton": "mdi:paper-roll",
"Groente, Fruit en Tuinafval": "mdi:leaf",
"PMD": "mdi:bottle-soda-classic-outline",
"Plastic, Metalen en Drankkartons": "mdi:bottle-soda-classic-outline",
"papier": "mdi:paper-roll",
"GFT": "mdi:leaf",
"GFT ": "mdi:leaf",
"restafval": "mdi:trash-can",
}

#### Arguments affecting the configuration GUI ####

HOW_TO_GET_ARGUMENTS_DESCRIPTION = { # Optional dictionary to describe how to get the arguments, will be shown in the GUI configuration form above the input fields, does not need to be translated in all languages
"en": "INPUT ARGUMENTS ARE THE SAME AS THE ONES YOU FILL IN FOR YOUR HOME ADDRESS AT: https://www.mijnafvalwijzer.nl/",
}

#### End of arguments affecting the configuration GUI ####

class Source:
def __init__(self, postcode, number, add=""):
self._postcode = postcode
self._number = number
if add is None:
self._add = ""
else:
self._add = add

def fetch(self):
s = requests.Session()

r = s.get(URL + '/nl/' + self._postcode.replace(" ","") + '/' + self._number.replace(" ","") + '/' + self._add.replace(" ",""))
r.raise_for_status()

soup = BeautifulSoup(r.text, "html.parser")
soup = soup.find('div', id= 'jaaroverzicht', class_ = 'pageBlock')
years = soup.find_all('div', id = re.compile('^jaar-'), class_ = 'ophaaldagen')

dict_month = {"januari":1,
"februari":2,
"maart":3,
"april":4,
"mei":5,
"juni":6,
"juli":7,
"augustus":8,
"september":9,
"oktober":10,
"november":11,
"december":12
}

date_day = []
date_month = []
date_year =[]
types_list = []
for year in years:
year_int = int(year.get('id')[-4:])
dates = soup.find_all('span', class_='span-line-break')
for date in dates:
date_day.append(int(date.string.split()[1]))
date_month.append(dict_month[date.string.split()[2]])
date_year.append(year_int)
types = soup.find_all('span', class_='afvaldescr')
for type in types:
types_list.append(type.string)

#entries = [] # List that holds collection schedule
entries: list[Collection] = []

for day, month, year, bin_type in zip(date_day, date_month, date_year, types_list):
try:
entries.append(
Collection(
date = datetime.date(year, month, day), # Collection date
t = bin_type, # Collection type
icon = ICON_MAP.get(bin_type), # Collection icon
)
)
except:
pass

return entries
22 changes: 0 additions & 22 deletions doc/ics/mijnafvalwijzer_nl.md

This file was deleted.

11 changes: 0 additions & 11 deletions doc/ics/yaml/mijnafvalwijzer_nl.yaml

This file was deleted.

1 change: 0 additions & 1 deletion doc/source/ics.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ This source has been successfully tested with the following service providers:

### Netherlands

- [Afval Wijzer](/doc/ics/mijnafvalwijzer_nl.md) / mijnafvalwijzer.nl
- [Edam-Volendam](/doc/ics/edam_volendam_nl.md) / edam-volendam.nl
- [Goes](/doc/ics/goes_nl.md) / goes.nl
- [Ôffalkalinder van Noardeast-Fryslân & Dantumadiel](/doc/ics/offalkalinder_nl.md) / offalkalinder.nl
Expand Down
49 changes: 49 additions & 0 deletions doc/source/mijnafvalwijzer_nl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Afval Wijzer

Afval Wijzer is a platform where users from many dutch municipalities can check their waste collection schedules.
Supported municipalities include, but are not limited to:
- Eindhoven
- Rotterdam
- Tilburg
- Midden-Groningen
- Waalwijk
- Kampen
- Oirschoot
- Oss
- ...

## How to get the configuration arguments

- Visit <https://www.mijnafvalwijzer.nl> and search for your location to make sure it is recogniced
- Write down your postcode, house number and house number addition, if any (e.g. A)


### Configuration via yaml

```yaml
waste_collection_schedule:
sources:
- name: mijnafvalwijzer_nl
args:
postcode: YOUR_POSTCODE
number: HOUSE_NUMBER
add: HOUSE_NUMBER_ADDITION
```

**Configuration Variables**

**postcode** _(string) (required)_ : Postcode of your property (e.g. 5014NN)
**postcode** _(string) (required)_ : House number (e.g. 174)
**add** _(string)_ : House number addition (e.g. A)

Example: Hoefstraat 174, Tilburg

```yaml
waste_collection_schedule:
sources:
- name: mijnafvalwijzer_nl
args:
postcode: 5014NN
number: 174
add:
```
Loading