diff --git a/README.md b/README.md index 397029704..67521a0ae 100644 --- a/README.md +++ b/README.md @@ -1391,7 +1391,7 @@ Waste collection schedules in the following formats and countries are supported. - [Newark & Sherwood District Council](/doc/source/newark_sherwooddc_gov_uk.md) / newark-sherwooddc.gov.uk - [Newcastle City Council](/doc/source/newcastle_gov_uk.md) / community.newcastle.gov.uk - [Newcastle Under Lyme Borough Council](/doc/source/newcastle_staffs_gov_uk.md) / newcastle-staffs.gov.uk -- [Newport City Council](/doc/source/newport_gov_uk.md) / newport.gov.uk +- [Newport City Council](/doc/source/iweb_itouchvision_com.md) / newport.gov.uk/ - [North Ayrshire Council](/doc/source/north_ayrshire_gov_uk.md) / north-ayrshire.gov.uk - [North Herts Council](/doc/source/northherts_gov_uk.md) / north-herts.gov.uk - [North Kesteven District Council](/doc/source/north_kesteven_org_uk.md) / n-kesteven.org.uk diff --git a/custom_components/waste_collection_schedule/sources.json b/custom_components/waste_collection_schedule/sources.json index 1f80047db..29fc38572 100644 --- a/custom_components/waste_collection_schedule/sources.json +++ b/custom_components/waste_collection_schedule/sources.json @@ -7359,8 +7359,10 @@ }, { "title": "Newport City Council", - "module": "newport_gov_uk", - "default_params": {} + "module": "iweb_itouchvision_com", + "default_params": { + "council": "NEWPORT" + } }, { "title": "North Ayrshire Council", diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/iweb_itouchvision_com.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/iweb_itouchvision_com.py index a30d4b4b8..62f711616 100644 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/iweb_itouchvision_com.py +++ b/custom_components/waste_collection_schedule/waste_collection_schedule/source/iweb_itouchvision_com.py @@ -55,8 +55,15 @@ "country": "uk", "default_params": {"council": "TEST_VALLEY"}, }, + { + "title": "Newport City Council", + "url": "https://www.newport.gov.uk//", + "country": "uk", + "default_params": {"council": "NEWPORT"}, + }, ] DESCRIPTION = """Consolidated source for waste collection services from: + Newport City Council Somerset Council, comprising four former District Councils (Mendip, Sedgemoor, Somerset West & Taunton, South Somerset) and Somerset County Council Test Valley Borough Council """ @@ -66,6 +73,7 @@ URLS = { "TEST_VALLEY": "https://iweb.itouchvision.com/portal/f?p=customer:BIN_DAYS:::NO:RP:UID:13353F039C4B1454827EE05536414091A8C058F4", "SOMERSET": "https://iweb.itouchvision.com/portal/f?p=customer:BIN_DAYS:::NO:RP:UID:625C791B4D9301137723E9095361401AE8C03934", + "NEWPORT": "https://iweb.itouchvision.com/portal/f?p=customer:BIN_DAYS:::NO:RP:UID:6CDD2A34C912312074D8E2410531401A8C00EFF7", "FLOW.ACCEPT": "https://iweb.itouchvision.com/portal/wwv_flow.accept", "BIN_DAYS": "https://iweb.itouchvision.com/portal/itouchvision/r/customer/bin_days", } @@ -114,6 +122,11 @@ "uprn": 100060571645, "council": "TEST_VALLEY", }, + "Newport #1": { + "postcode": "NP20 2QL", + "uprn": "10090955364", + "council": "NEWPORT", + }, } ICON_MAP = { "GARDEN": "mdi:leaf", diff --git a/custom_components/waste_collection_schedule/waste_collection_schedule/source/newport_gov_uk.py b/custom_components/waste_collection_schedule/waste_collection_schedule/source/newport_gov_uk.py deleted file mode 100644 index be9680da8..000000000 --- a/custom_components/waste_collection_schedule/waste_collection_schedule/source/newport_gov_uk.py +++ /dev/null @@ -1,64 +0,0 @@ -from dateutil import parser -import re - -from xml.dom.minidom import parseString -import requests -from waste_collection_schedule import Collection - -TITLE = "Newport City Council" -DESCRIPTION = "Source for newport.gov.uk, Newport City Council, UK" -URL = "https://www.newport.gov.uk" -TEST_CASES = { - "The Coach House, Newport": {"uprn": 100100688837}, -} - -API_URL = "https://api.newport.gov.uk/PropertyData/bincollection/properties/{uprn}/Waste Collection" - -ICON_MAP = { - "rubbish bin": "mdi:trash-can", - "kerbside recycling": "mdi:recycle", - "garden waste": "mdi:leaf", -} - -def getText(element): - s = "" - for e in element.childNodes: - if e.nodeType == e.TEXT_NODE: - s += e.nodeValue - return s - -class Source: - def __init__(self, uprn=None): - self._uprn = uprn - - def fetch(self): - q = str(API_URL).format(uprn=self._uprn) - - r = requests.get(q) - r.raise_for_status() - - responseContent = r.text - - entries = [] - - doc = parseString(responseContent) - collections = doc.getElementsByTagName("channel") - - for collection in collections: - nameFull = getText(collection.getElementsByTagName("title")[0]) - when = getText(collection.getElementsByTagName("title")[1]) - if "Info:" in when: - continue - if "will resume" in when: - continue - - name = re.search('next (.+?) collection', nameFull).group(1) - entries.append( - Collection( - date=parser.parse(when).date(), - t=name, - icon=ICON_MAP.get(name), - ) - ) - - return entries