renoweb dk (#1817)

* Added renoweb.dk

* README.md updated

* info.md updated

* requested modifications

* requested modifications

* reformatting

* Better error handling, issue with using address_id fixed

---------

Co-authored-by: Rune <{ID}+{username}@users.noreply.github.com>
Co-authored-by: 5ila5 <5ila5@users.noreply.github.com>
This commit is contained in:
r-poulsen
2024-02-21 17:19:34 +01:00
committed by GitHub
parent aa489a858c
commit 361cb4ec19
2 changed files with 10 additions and 3 deletions

View File

@@ -91,7 +91,7 @@ class Source:
@property @property
def _address_id(self) -> int: def _address_id(self) -> int:
"""Return the address id.""" """Return the address id."""
if not hasattr(self, "__address_id"): if not hasattr(self, f"_{self.__class__.__name__}__address_id"):
self._get_address_id() self._get_address_id()
return self.__address_id return self.__address_id
@@ -110,7 +110,12 @@ class Source:
response.raise_for_status() response.raise_for_status()
# For some reason the response is a JSON structure inside a JSON string # For some reason the response is a JSON structure inside a JSON string
for entry in json.loads(response.json()["d"])["list"]: waste_schemes = json.loads(response.json()["d"])["list"]
if not waste_schemes:
raise ValueError("No waste schemes found, check address or address_id")
for entry in waste_schemes:
if not entry["afhentningsbestillingmateriel"] and re.search( if not entry["afhentningsbestillingmateriel"] and re.search(
r"dag den \d{2}-\d{2}-\d{4}", entry["toemningsdato"] r"dag den \d{2}-\d{2}-\d{4}", entry["toemningsdato"]
): ):

View File

@@ -22,7 +22,7 @@ _(String) (required)_
The name of the municipality as it appears in the URL. E.g. https://htk.renoweb.dk/Legacy/selvbetjening/mit_affald.aspx where "htk" is for Høje-Taastrup municipality. The name of the municipality as it appears in the URL. E.g. https://htk.renoweb.dk/Legacy/selvbetjening/mit_affald.aspx where "htk" is for Høje-Taastrup municipality.
**address** **address**
_(String) (required)_ _(String) (optional)_
The address to look up. It should be exactly as it is on the website until the comma between the street address and the postal code. The address to look up. It should be exactly as it is on the website until the comma between the street address and the postal code.
@@ -31,6 +31,8 @@ _(Int) (optional)_
Use address_id if the address lookup fails. Use address_id if the address lookup fails.
_Note that while both **address** and **address_id** are optional, one of them must be supplied and if both are used, **address_id** will take precedence._
## Example ## Example
```yaml ```yaml