Home-Assistant integration of 'Abfall.IO' waste collection dates & schedule

There is this library: https://github.com/temesinko/python-abfallplus
Maybe its useful for you guys

@karl1986
You API key is: e5543a3e190cb8d91c645660ad60965f

1 Like

Very nice! Don’t know about this.

Just wanted you let you know that I created a framework which supports multiple waste collection services, including abfall.io. The framework provides some extra features, including wizard’s which help to get the configuration settings for a lot of cities.

Have fun!

1 Like

Hi All,

I have performed a full rewrite of the previous abfallio custom component with the goal to no longer need code editing to apply this component for you.

The rewrite brings configuration for your location (kommune, bezirk, strasse) into the ususal way of YAML.
Furthermore it automatically creates sensors for all available trash types (abfalltypen).

Check it out at:

1 Like

Thanks a lot @mk-maddin
Works like a charm.

Unfortunatelly in my region there is a “abfallart” 299 which is not in your default range of 99
For now I changed --init–.py
DEFAULT_ABFALLARTEN=["XX","XX","XX","299"]

Would be great if you could find the bug in your code.

Is anyone able to get the key from here?
I can’t seem to find it…

https://www.awg.de/kundenportal/abfuhrtermine/

Seems that AWG ist not using abfall.io
Based on the sourcecode of the website they are using a service from athos.com

Oh wow. Now that you mention it, I finally noticed that header… :man_facepalming:
I just assumed it would use it, because they list their Android and iOS app on the www.abfallplus.de website…
Thanks for that! I should try opening my eyes next time :sweat_smile:.

@mk-maddin
seem that the component only updates on reboots.
image
Could you look into this?

Where can I change the path form the local csv file? Or is local csv not possible?

For my commune (Ortenaukreis) I can download: ics, pdf and csv

https://www.abfallwirtschaft-ortenaukreis.de/abfallkalender-abfuhrtermine/abfuhrkalender-strauchgut-und-sperrmuelltermine-2020/

ok, I take a look at the html code and just recognize that this are working over Abfall.io API as well…

I changed the settings like below (incl. http -> https), but it doesn’t show anything. Did I missed something?

    @Throttle(MIN_TIME_BETWEEN_UPDATES)
    def update(self):
        _LOGGER.debug("Updating Abfall dates using remote API")
        try:
            payload = {
                "f_id_kommune": "5735",
                "f_id_bezirk": "71",
                "f_id_strasse": "1657",
                "f_id_abfalltyp_0": "66",
                "f_id_abfalltyp_1": "177",
                "f_id_abfalltyp_2": "951",
                "f_id_abfalltyp_3": "190",
                "f_id_abfalltyp_4": "1455",
                "f_id_abfalltyp_5": "33",
                "f_id_abfalltyp_6": "347",
                "f_abfallarten_index_max": "7",
                "f_abfallarten": "66,177,951,190,1455,33,347",
                "f_zeitraum": "20200101-20201231"
            }

            j = requests.post(
                "https://api.abfall.io/?key=bb296b78763112266a391990f803f032&modus=d6c5855a62cf32a4dadbc2831f0f295f&waction=export_csv", data=payload, timeout=10)
            apiRequest = j.text.split('\n')
            reader = csv.reader(apiRequest, delimiter=";")
            rowCounter = 0
            columns = None
            gelberSack = []
            restMuell = []
            papierTonne = []

            for row in reader:
                if rowCounter == 0:
                    columns = {k:row.index(k) for k in row}
                
                else:
                    if (row[columns["Gelber Sack"]] != ""):
                        gelberSack.append(datetime.strptime(row[columns["Gelber Sack"]], "%d.%m.%Y"))

                    if (row[columns["Graue Tonne"]] != ""):
                        restMuell.append(datetime.strptime(row[columns["Graue Tonne"]], "%d.%m.%Y"))

                    if (row[columns["Grüne Tonne"]] != ""):
                        papierTonne.append(datetime.strptime(row[columns["Grüne Tonne"]], "%d.%m.%Y"))

                rowCounter = rowCounter + 1

            gelberSack.sort(key=lambda date: date)
            restMuell.sort(key=lambda date: date)
            papierTonne.sort(key=lambda date: date)

            nextDates = {}

            for nextDate in gelberSack:
                if nextDate.date() >= datetime.now().date():
                    nextDates["gelberSack"] = nextDate
                    break

            for nextDate in restMuell:
                if nextDate.date() >= datetime.now().date():
                    nextDates["restMuell"] = nextDate
                    break

            for nextDate in papierTonne:
                if nextDate.date() >= datetime.now().date():
                    nextDates["papierTonne"] = nextDate
                    break

            self.data = nextDates

        except requests.exceptions.RequestException as exc:
            _LOGGER.error("Error occurred while fetching data: %r", exc)
            self.data = None
            return False