mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
add sutton_gov_uk
This commit is contained in:
@@ -1344,6 +1344,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Stoke-on-Trent](/doc/source/stoke_gov_uk.md) / stoke.gov.uk
|
||||
- [Stratford District Council](/doc/source/stratford_gov_uk.md) / stratford.gov.uk
|
||||
- [Surrey Heath Borough Council](/doc/source/jointwastesolutions_org.md) / surreyheath.gov.uk
|
||||
- [Sutton Council, London](/doc/source/sutton_gov_uk.md) / sutton.gov.uk
|
||||
- [Swansea Council](/doc/source/swansea_gov_uk.md) / swansea.gov.uk
|
||||
- [Swindon Borough Council](/doc/source/swindon_gov_uk.md) / swindon.gov.uk
|
||||
- [Tameside Metropolitan Borough Council](/doc/source/tameside_gov_uk.md) / tameside.gov.uk
|
||||
|
||||
@@ -195,6 +195,7 @@ class Source:
|
||||
raise RuntimeError(
|
||||
"Error: unknown method to fetch URL, use GET or POST; got {self._method}"
|
||||
)
|
||||
print(r.text)
|
||||
r.raise_for_status()
|
||||
|
||||
if r.apparent_encoding == "UTF-8-SIG":
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
from time import sleep
|
||||
|
||||
import requests
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
from waste_collection_schedule.service.ICS import ICS
|
||||
|
||||
TITLE = "Sutton Council, London"
|
||||
DESCRIPTION = "Source for Sutton Council, London."
|
||||
URL = "https://sutton.gov.uk"
|
||||
TEST_CASES = {"4721996": {"id": 4721996}, "4499298": {"id": "4499298"}}
|
||||
|
||||
|
||||
ICON_MAP = {
|
||||
"non-recyclable": "mdi:trash-can",
|
||||
"paper": "mdi:package-variant",
|
||||
"mixed": "mdi:recycle",
|
||||
"food": "mdi:food",
|
||||
}
|
||||
|
||||
|
||||
API_URL = "https://waste-services.sutton.gov.uk/waste/{id}"
|
||||
ICAL_URL = API_URL + "/calendar.ics"
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, id: str | int):
|
||||
self._id: str | int = id
|
||||
self._ics = ICS()
|
||||
|
||||
def fetch(self):
|
||||
s = requests.Session()
|
||||
api_url = API_URL.format(id=self._id)
|
||||
ical_url = ICAL_URL.format(id=self._id)
|
||||
|
||||
r = s.get(api_url)
|
||||
while f'hx-get="/waste/{self._id}"' in r.text:
|
||||
sleep(2)
|
||||
r = s.get(api_url)
|
||||
r.raise_for_status()
|
||||
|
||||
r = s.get(ical_url)
|
||||
r.raise_for_status()
|
||||
|
||||
dates = self._ics.convert(r.text)
|
||||
entries = []
|
||||
for d in dates:
|
||||
entries.append(
|
||||
Collection(d[0], d[1], ICON_MAP.get(d[1].split(" ")[0].lower()))
|
||||
)
|
||||
|
||||
return entries
|
||||
@@ -7,8 +7,8 @@ Abfallwirtschaft der Stadt St. Pölten is supported by the generic [ICS](/doc/so
|
||||
|
||||
- Goto <https://www.st-poelten.at/sonstiges/17653-abfallkalender> and click "Inhalte von services.st-poelten.at laden"
|
||||
- fill out your address
|
||||
- klick F12 or start the dev-mode on your browser another way
|
||||
- klick on "Download Kalenderexport" and discard or save the file (you'll not need it for that)
|
||||
- click F12 or start the dev-mode on your browser another way
|
||||
- click on "Download Kalenderexport" and discard or save the file (you'll not need it for that)
|
||||
- find the link for the ics-file in the "Network"-section of your browsers Dev-tools
|
||||
- copy the link - for the Landhaus it's https://services.infeo.at/awm/api/st.p%C3%B6lten/wastecalendar/v2/export/?calendarId=135&cityId=162&streetId=124691&housenumber=1&outputType=ical
|
||||
- (the only values changing here shall be "streetId" and "housenumber")
|
||||
|
||||
34
doc/source/sutton_gov_uk.md
Normal file
34
doc/source/sutton_gov_uk.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# Sutton Council, London
|
||||
|
||||
Support for schedules provided by [Sutton Council, London](https://sutton.gov.uk), serving Sutton Council, London, UK.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: sutton_gov_uk
|
||||
args:
|
||||
id: "ID"
|
||||
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**id**
|
||||
*(String | Integer) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: sutton_gov_uk
|
||||
args:
|
||||
id: "4721996"
|
||||
|
||||
```
|
||||
|
||||
## How to get the source argument
|
||||
|
||||
Goto [https://waste-services.sutton.gov.uk/waste](https://waste-services.sutton.gov.uk/waste) and select your location. Your address bar should show the internal ID of your address. Use this ID as the source argument. (e.g. `https://waste-services.sutton.gov.uk/waste/4721996` the ID is `4721996`)
|
||||
Reference in New Issue
Block a user