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 4 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,8 +1747,8 @@ 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
- [Afvalstoffendienst.nl](/doc/source/afvalstoffendienst_nl.md) / afvalstoffendienst.nl
- [Afval Wijzer](/doc/source/mijnafvalwijzer_nl.md) / mijnafvalwijzer.nl
- [Alpen an den Rijn](/doc/source/hvcgroep_nl.md) / alphenaandenrijn.nl
- [Altena](/doc/source/afvalstoffendienst_nl.md) / altena.afvalstoffendienstkalender.nl
- [Area Afval](/doc/source/ximmio_nl.md) / area-afval.nl
Expand Down
12 changes: 6 additions & 6 deletions custom_components/waste_collection_schedule/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -11187,12 +11187,6 @@
},
"id": "ximmio_nl"
},
{
"title": "Afval Wijzer",
"module": "ics",
"default_params": {},
"id": "ics_mijnafvalwijzer_nl"
},
{
"title": "Afvalstoffendienst.nl",
"module": "afvalstoffendienst_nl",
Expand Down Expand Up @@ -11291,6 +11285,12 @@
"default_params": {},
"id": "ics_edam_volendam_nl"
},
{
"title": "Afval Wijzer",
"module": "mijnafvalwijzer_nl",
"default_params": {},
"id": "mijnafvalwijzer_nl"
},
{
"title": "GAD",
"module": "hvcgroep_nl",
Expand Down
42 changes: 0 additions & 42 deletions custom_components/waste_collection_schedule/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -9662,48 +9662,6 @@
},
"data_description": {}
},
"args_ics_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",
"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"
},
"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": {
"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",
"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"
},
"data_description": {}
},
"args_hvcgroep_nl": {
"title": "Quelle konfigurieren",
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/hvcgroep_nl.md",
Expand Down
73 changes: 31 additions & 42 deletions custom_components/waste_collection_schedule/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9671,48 +9671,6 @@
},
"data_description": {}
},
"args_ics_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.",
"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"
},
"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": {
"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.",
"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"
},
"data_description": {}
},
"args_hvcgroep_nl": {
"title": "Configure Source",
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/hvcgroep_nl.md.",
Expand Down Expand Up @@ -9805,6 +9763,37 @@
},
"data_description": {}
},
"args_mijnafvalwijzer_nl": {
"title": "Configure Source",
"description": "Configure your service provider. \n\nHOW TO GET ARGUMENTS DESCRIPTION\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mijnafvalwijzer_nl.md.",
"data": {
"calendar_title": "Calendar Title",
"add": "Addition",
"number": "House 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.",
"add": "Addition",
"number": "House number",
"postcode": "Postcode"
}
},
"reconfigure_mijnafvalwijzer_nl": {
"title": "Reconfigure Source",
"description": "Configure your service provider. \n\nHOW TO GET ARGUMENTS DESCRIPTION\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/mijnafvalwijzer_nl.md.",
"data": {
"calendar_title": "Calendar Title",
"add": "Addition",
"number": "House number",
"postcode": "Postcode"
},
"data_description": {
"add": "Addition",
"number": "House number",
"postcode": "Postcode"
}
},
"args_ics_goes_nl": {
"title": "Configure Source",
"description": "Configure your service provider. \n\n- Visit https://afvalkalender.goes.nl/ and select your location. \n- Right click copy link address on the `Persoonlijke afvalkalender` button.\n- Replace the `url` in the example configuration with this link.\n- Replace the current year with '{%Y}' in the link.\n\n\nMore details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/ics/goes_nl.md.",
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\nCOME OTTENERE GLI ARGOMENTI\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\nCOME OTTENERE GLI ARGOMENTI\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,122 @@
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"},
}

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": "HOW TO GET ARGUMENTS DESCRIPTION",
"de": "WIE MAN DIE ARGUMENTE ERHÄLT",
"it": "COME OTTENERE GLI ARGOMENTI",
}
gilaberticus marked this conversation as resolved.
Show resolved Hide resolved

PARAM_DESCRIPTIONS = { # Optional dict to describe the arguments, will be shown in the GUI configuration below the respective input field
"en": {
"postcode": "Postcode",
"number": "House number",
"add": "Addition"
},
}
gilaberticus marked this conversation as resolved.
Show resolved Hide resolved

PARAM_TRANSLATIONS = { # Optional dict to translate the arguments, will be shown in the GUI configuration form as placeholder text
"en": {
"postcode": "Postcode",
"number": "House number",
"add": "Addition"
},
}

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

class Source:
def __init__(self, postcode, number, add=""):
self._postcode = postcode
self._number = number
self._add = add
gilaberticus marked this conversation as resolved.
Show resolved Hide resolved

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:])
print(year_int)
gilaberticus marked this conversation as resolved.
Show resolved Hide resolved
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] = []

ii=0
while ii < len(date_day):
try:
entries.append(
Collection(
date = datetime.date(date_year[ii], date_month[ii], date_day[ii]), # Collection date
t = types_list[ii], # Collection type
icon = ICON_MAP.get(types_list[ii]), # Collection icon
)
)
except:
pass
# raise Exception("Error in date: " + str(date_year[ii]) + "-" + str(date_month[ii]) + "-" + str(date_day[ii]))
ii = ii+1
gilaberticus marked this conversation as resolved.
Show resolved Hide resolved

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
Loading
Loading