mampfes / hacs_waste_collection_schedule

Home Assistant integration framework for (garbage collection) schedules
MIT License
1.04k stars 647 forks source link

[Bug]: sbazv_de Not working anymore #2870

Open reentier opened 4 days ago

reentier commented 4 days ago

I Have A Problem With:

The integration in general

What's Your Problem

I only receive an error-Message from this Integration singe today.

image

While trying to reconfigure and double-checking with website of the provider it seems that they have changed the requested paramaters for the API-Call. In the past there asked for City, Part of the City and Street. But now there are asking for City, Street and Number of the House.

image

If there is any more Information i should provide to solve this issue, please ask.

Thanks in advance for looking into this.

Source (if relevant)

Sbazv_de

Logs

No response

Relevant Configuration

No response

Checklist Source Error

Checklist Sensor Error

Required

maxgisel commented 3 days ago

+1

reentier commented 2 days ago

The provider has completely changed the way in which the data can be retrieved. Instead of city, district and street, a location ID is now required. You can then use additional parameters to specify which waste you want to retrieve. You can choose between residual waste, paper, yellow bags, leaf bags and Christmas trees. The URL for the query has also changed completely. The URL for the address from the example in the data now looks like this: https://fahrzeuge.sbazv.de/WasteManagementSuedbrandenburg/WasteManagementServiceServlet?ApplicationName=Calendar&SubmitAction=sync&StandortID=1448162001&AboID=495&Fra=P;R;WB;L;GS

I have temporarily solved the problem for myself by hard-coding the URL for the query at my address in the sbazv_en.py module. For the moment it works again, but I hope that the changes will soon be included in the official part.

regards

frankrehfeld commented 2 days ago

I have temporarily solved the problem for myself by hard-coding the URL for the query at my address in the sbazv_en.py module. For the moment it works again, but I hope that the changes will soon be included in the official part.

regards

Can you provide a quick and dirty hack to get the integration working again until it is fixed?

reentier commented 2 days ago

Go to the Website of sbazv, Look for your personal ics-file and copy the provided link.

use this link in file sbazv_de.py and enter this in line 53. do Not forget to delete the additional Parameters in the line.

start HA afterwards and everything should be working, ar least for the Moment.

cpohli commented 1 day ago

Thank you @reentier, it works again (for now and as a workaround at least).

But not only the way the data is retrieved changed, also the wording of the entries. For instance "Papier" has become "Papier 0240 04-wöchentl." If you use templates for icons and so on, you'll have to change all the templates as well. If this persists, there should be an truncate involved for the " 0240 ..." parts.

EDIT: Die "new" naming seems to only affect "Papier" and "Restmüll".

rmi1974 commented 1 day ago

Thank you @reentier, it works again (for now and as a workaround at least).

But not only the way the data is retrieved changed, also the wording of the entries. For instance "Papier" has become "Papier 0240 04-wöchentl." If you use templates for icons and so on, you'll have to change all the templates as well. If this persists, there should be an truncate involved for the " 0240 ..." parts.

EDIT: Die "new" naming seems to only affect "Papier" and "Restmüll".

Confirmed. I had to change my templates:

waste_collection_schedule:
  sources:
    - name: ics
      args:
        url: https://fahrzeuge.sbazv.de/WasteManagementSuedbrandenburg/WasteManagementServiceServlet?ApplicationName=Calendar&SubmitAction=sync&StandortID=xxx&Fra=P;R;WB;L;GS
      calendar_title: "Müllabfuhr"
      customize:
        - type: Restmüll 0240 02-wöchentl.
          alias: restmuell
          icon: mdi:trash-can
        - type: Gelbe Säcke
          alias: gelbersack
          icon: mdi:recycle-variant
        - type: Papier 0240 04-wöchentl.
          alias: papier
          icon: mdi:package-variant
        - type: Laubsäcke
          alias: laub
          icon: mdi:leaf

While this fixes my "next event" sensors (it displays the next date where each type of waste is collected), the calendar itself doesn't work for me.

"Events for calendar could not be retrieved" -> calendar doesn't display any items.

This doesn't make sense because the sensors can obviously display valid data which means that event data has been parsed from the received .ics

I'm a bit stumped. I've changed sbazv_en.py as suggested (same URL as in the template) but for unknown reasons calendar remains empty with the error message in web UI.

Is there a way to debug/log the parsing within python module? I've tried to reuse some logger.debug code from other modules but it doesn't work, the output goes to narnia?

import logging
from datetime import datetime

import requests
from waste_collection_schedule import Collection  # type: ignore[attr-defined]
from waste_collection_schedule.service.ICS import ICS

_LOGGER = logging.getLogger(__name__)

...

TITLE = "Südbrandenburgischer Abfallzweckverband"
DESCRIPTION = "SBAZV Brandenburg, Deutschland"
...
_LOGGER = logging.getLogger(__name__)
    def fetch(self):
        args = {
            "city": self._city,
            "district": self._district,
            "street": self._street,
        }

        _LOGGER.debug("before fetch")
        # get ics file
        # https://www.sbazv.de/entsorgungstermine/klein.ics?city=Wildau&district=Wildau&street=Miersdorfer+Str.
        r = requests.get(
            "https://fahrzeuge.sbazv.de/WasteManagementSuedbrandenburg/WasteManagementServiceServlet?ApplicationName=Calendar&SubmitAction=sync&StandortID=xxx&Fra=P;R;WB;L;GS"
        )

        # parse ics file
        dates = self._ics.convert(r.text)
        _LOGGER.debug("after ics convert")
        entries = []
        for d in dates:
            waste_type = d[1].strip()
            _LOGGER.debug("Waste Type: %s", waste_type)
            next_pickup_date = d[0]
cpohli commented 1 day ago

While this fixes my "next event" sensors (it displays the next date where each type of waste is collected), the calendar itself doesn't work for me.

"Events for calendar could not be retrieved" -> calendar doesn't display any items.

Calendar seems fine here and works as expected. The only things i changed was the URL and the customization for the two renamed entries "Papier" and "Restmüll".