mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 05:06:33 +01:00
umweltverbaende_at now supports more complex calendar arguments
This commit is contained in:
@@ -151,7 +151,13 @@ TEST_CASES = {
|
||||
"Hollabrunn": {"district": "hollabrunn", "municipal": "Retz"},
|
||||
"Horn": {"district": "horn", "municipal": "Japons"},
|
||||
"Klosterneuburg": {"district": "klosterneuburg", "municipal": "Klosterneuburg"},
|
||||
"Korneuburg": {"district": "korneuburg", "municipal": "Bisamberg"},
|
||||
"Korneuburg": {
|
||||
"district": "korneuburg",
|
||||
"municipal": "Bisamberg",
|
||||
"calendar": "Zone B",
|
||||
"calendar_title_separator": ",",
|
||||
"calendar_splitter": ":",
|
||||
},
|
||||
"Krems": {"district": "krems", "municipal": "Aggsbach"},
|
||||
"Stadt Krems Old Version": {"district": "kremsstadt", "municipal": "Rehberg"},
|
||||
"Stadt Krems New Version": {"district": "kremsstadt", "calendar": "Rehberg"},
|
||||
@@ -190,7 +196,14 @@ ICON_MAP = {
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, district, municipal=None, calendar=None):
|
||||
def __init__(
|
||||
self,
|
||||
district,
|
||||
municipal=None,
|
||||
calendar=None,
|
||||
calendar_title_separator=":",
|
||||
calendar_splitter=None,
|
||||
):
|
||||
self._district = district.lower()
|
||||
self._municipal = municipal
|
||||
|
||||
@@ -201,6 +214,9 @@ class Source:
|
||||
else:
|
||||
self._calendars = None
|
||||
|
||||
self.calendar_title_separator = calendar_title_separator
|
||||
self.calendar_splitter = calendar_splitter
|
||||
|
||||
if (
|
||||
district == "kremsstadt" and not calendar
|
||||
): # Keep compatibility with old configs
|
||||
@@ -263,8 +279,16 @@ class Source:
|
||||
txt = day.text.strip().split(" \u00a0")
|
||||
if self._calendars: # Filter for calendar if there are multiple calendars
|
||||
if any(cal.upper() in txt[2].upper() for cal in self._calendars):
|
||||
txt[2] = txt[2].split(":")[-1].strip()
|
||||
self.append_entry(entries, txt)
|
||||
for entry_text in (
|
||||
[txt[2]]
|
||||
if self.calendar_splitter is None
|
||||
else txt[2].split(self.calendar_splitter)
|
||||
):
|
||||
new_txt = txt.copy()
|
||||
new_txt[2] = entry_text.split(self.calendar_title_separator)[
|
||||
-1
|
||||
].strip()
|
||||
self.append_entry(entries, new_txt)
|
||||
else: # Process all other municipals
|
||||
self.append_entry(entries, txt)
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ waste_collection_schedule:
|
||||
district: DISTRICT_ARG
|
||||
municipal: MUNICIPAL
|
||||
calendar: CALENDAR
|
||||
calendar_title_separator: CALENDAR_TITLE_SEPERATOR
|
||||
calendar_splitter: CALENDAR_SPLITTER
|
||||
```
|
||||
|
||||
**district**
|
||||
@@ -30,10 +32,22 @@ Is not needed for Stadt Krems you should provide a calendar for each Rayon.
|
||||
For Stadt Krems, the district is divided into 12 Rayon, so supply your Rayon name for the municipal arg. For example: _Rehberg (Rayon 30)_ would be `Rehberg`, whereas _Innenstadt 2 (Rayon 200)_ would be `Innenstadt 2`
|
||||
|
||||
**calendar**
|
||||
(string) (optional)
|
||||
(string) (optional)
|
||||
|
||||
If you see multiple collection calendars for your municipal (different streets or Rayons), you can specify the calendar name here. The calendar name should be spelt as it appears on the Abholtermine page below `Kalenderansicht`.
|
||||
|
||||
**calendar_title_separator**
|
||||
(string) (optional | default: ":")
|
||||
|
||||
rarely needed, only works if `calendar` is set. This is the character that separates the calendar title from the collection dates. Like `Tour 1: Restmüll` (`:` is the separator which is the default value) or `Bisamberg Zone B, Restmüll 14-tägig` (`,` is the separator). You can see the text, the integration will use, at the Abholtermine page below `Kalenderansicht`
|
||||
|
||||
**calendar_splitter**
|
||||
(string) (optional)
|
||||
|
||||
rarely needed, only works if `calendar` is set. Only needed if multiple collections are shown in one line. This is the character that separates the collection times, that are listed in one line. Like `Bisamberg Zone B, Restmüll 14-tägig: Gelber Sack` (`:` is the separator) You can see the text, the integration will use, at the Abholtermine page below `Kalenderansicht`
|
||||
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
```yaml
|
||||
@@ -86,6 +100,19 @@ waste_collection_schedule:
|
||||
- "Biotonne"
|
||||
```
|
||||
|
||||
*Advanced calendar options are needed*
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: umweltverbaende_at
|
||||
args:
|
||||
district: "korneuburg" # Korneuburg
|
||||
municipal: "Bisamberg" # Municipal
|
||||
calendar: "Zone B" # Rayon
|
||||
calendar_title_separator: ","
|
||||
calendar_splitter: ":"
|
||||
```
|
||||
|
||||
*Old Version*
|
||||
```yaml
|
||||
|
||||
Reference in New Issue
Block a user