mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 02:04:22 +01:00
first commit
This commit is contained in:
@@ -80,6 +80,7 @@ Currently the following service providers are supported:
|
||||
- [Abfallwirtschaft Südholstein](./doc/source/awsh_de.md)
|
||||
- [Abfallwirtschaft Zollernalbkreis](./doc/source/abfall_zollernalbkreis_de.md)
|
||||
- [AWB Bad Kreuznach](./doc/source/awb_bad_kreuznach_de.md)
|
||||
- [AWB Oldenburg](./doc/source/awb_oldenburg_de.md)
|
||||
- [AWBKoeln.de](./doc/source/awbkoeln_de.md)
|
||||
- [AWIDO-online.de](./doc/source/awido_de.md)
|
||||
- [Berlin-Recycling.de](./doc/source/berlin_recycling_de.md)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import requests
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
|
||||
import urllib
|
||||
import icalendar
|
||||
|
||||
|
||||
TITLE = "AWB Oldenburg"
|
||||
DESCRIPTION = "Source for 'Abfallwirtschaftsbetrieb Stadt Oldenburg (Oldb)'."
|
||||
URL = "https://services.oldenburg.de/index.php"
|
||||
TEST_CASES = {
|
||||
"Polizeiinspektion Oldenburg": {"street": "Friedhofsweg", "house_number": 30}
|
||||
}
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, street, house_number):
|
||||
self._street = street
|
||||
self._house_number = house_number
|
||||
|
||||
def fetch(self):
|
||||
|
||||
args = {
|
||||
'id': 430,
|
||||
'tx_citkoabfall_abfallkalender[strasse]': self._street.encode('utf-8'),
|
||||
'tx_citkoabfall_abfallkalender[hausnummer]': self._house_number.encode('utf-8'),
|
||||
'tx_citkoabfall_abfallkalender[abfallarten][0]': 61,
|
||||
'tx_citkoabfall_abfallkalender[abfallarten][1]': 60,
|
||||
'tx_citkoabfall_abfallkalender[abfallarten][2]': 59,
|
||||
'tx_citkoabfall_abfallkalender[abfallarten][3]': 58,
|
||||
'tx_citkoabfall_abfallkalender[action]': 'ics',
|
||||
'tx_citkoabfall_abfallkalender[controller]': 'FrontendIcs'
|
||||
}
|
||||
|
||||
# use '%20' instead of '+' in URL
|
||||
# https://stackoverflow.com/questions/21823965/use-20-instead-of-for-space-in-python-query-parameters
|
||||
args = urllib.parse.urlencode(args, quote_via=urllib.parse.quote)
|
||||
|
||||
# post request
|
||||
reply = requests.get(URL, params=args)
|
||||
|
||||
# create calender from reply
|
||||
gcal = icalendar.Calendar.from_ical(reply.text)
|
||||
|
||||
# iterate over events and add to waste collection
|
||||
entries = []
|
||||
for component in gcal.walk():
|
||||
if component.name == "VEVENT":
|
||||
type = component.get('summary')
|
||||
start_date = component.get('dtstart').dt
|
||||
|
||||
entries.append(Collection(start_date, type))
|
||||
|
||||
return entries
|
||||
33
doc/source/awb_oldenburg_de.md
Normal file
33
doc/source/awb_oldenburg_de.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Abfallwirtschaftsbetrieb Stadt Oldenburg (Oldb)
|
||||
|
||||
Support for schedules provided by [services.oldenburg.de](https://services.oldenburg.de/index.php?id=430).
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: awb_oldenburg_de
|
||||
args:
|
||||
street: STREET
|
||||
house_number: HOUSE_NUMBER
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**street**<br>
|
||||
*(string) (required)*
|
||||
|
||||
**house_number**<br>
|
||||
*(string) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: awb_oldenburg_de
|
||||
args:
|
||||
street: 'Friedhofsweg'
|
||||
house_number: 30
|
||||
```
|
||||
1
info.md
1
info.md
@@ -66,6 +66,7 @@ Currently the following service providers are supported:
|
||||
- [Abfallwirtschaft Südholstein](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/awsh_de.md)
|
||||
- [Abfallwirtschaft Zollernalbkreis](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/abfall_zollernalbkreis_de.md)
|
||||
- [AWB Bad Kreuznach](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/awb_bad_kreuznach_de.md)
|
||||
- [AWB Oldenburg](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/awb_oldenburg_de.md)
|
||||
- [AWBKoeln.de](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/awbkoeln_de.md)
|
||||
- [AWIDO-online.de](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/awido_de.md)
|
||||
- [Berlin-Recycling.de](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/berlin_recycling_de.md)
|
||||
|
||||
Reference in New Issue
Block a user