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

Hello,

did i need a init.py file and how can i find it ?

This is what i have:

(hass) homeassi:~$ cat .homeassistant/custom_components/abfall_wabue/__init__.py 
DOMAIN = "abfall_wabue"

Hi Ingo,

i uploaded everything to my git, you can take a look there:

https://git.relict.de/tom/ha_abfall_landshut

Cheers
Tom

Hello everybody,

thanks for the work - I would very much like to use it too. Unfortunately I fail because I can’t find the ID for my district. If I look at abfall.io, my district is supported. but if i search on the official site, i only get a PDF or ics for download. Examine elements etc. doesn’t work or I can’t get the district ID. It’s about the community of Pleidelsheim near Ludwigsburg. The waste disposal company is called AVL. Can someone help me please?

Thank you very much
Frank

1 Like

Hi Frank,

are you talking about this service?
https://www.avl-ludwigsburg.de/privatkunden/termine/abfallkalender/abfallkalender/suche/

If yes: I couldnt find any link to abfall.io services. It seems you directly download the waste-collecting-schdules from their Typo3 file storage. So the approach which i was using doesnt work here.

Sorry

Cheers
Tom

1 Like

Hi Tom, yes correct, thats this service. Ok, so not good for me and cant use this solution here. But thanks anyway for your help.

Would like to contribute:

Service: regioIT
Regions:

  • Bergisch Gladbach (AWB / Neuenhaus)
  • Lindlar
  • ZEW
  • Dinslaken
  • Pinneberg
  • Lüdenscheid
  • Bergischer Abfallwirtschaftverbund
  • WML
  • KRWAF AWG / GEG
  • Aachen
  • Dorsten
  • Gütersloh
  • Halver
  • Coesfeld

Repository: https://github.com/tuxuser/abfallapi_regioit_ha
HA Community thread: German Müllabfuhr sensor (regioIT)
Available on HACS: YES

Service: Jumomind
Regions:

  • ZAW
  • Aurich
  • Altötting
  • Lübbecke
  • Barnim
  • Minden
  • Rhein-Hunsrück
  • Recklinghausen
  • Uckermark
    Non-working regions:
  • Bad Homburg vdH
  • Hattersheim am Main
  • Ingolstadt
  • Groß-Gerau

Repository: https://github.com/tuxuser/abfallapi_jumomind_ha
Available on HACS: YES

Service: AWB Köln
Regions:

  • Köln

Repository: https://github.com/jensweimann/awb
HA Community thread: AWB Köln garbage collection schedule
Available on HACS: YES

Hi@all

I wanted to ask if there is an easy way to get this addon work by https://daten.zkri.ch/web/Sammelkalender/sammelkalender.html, a service in switzerland with only import the csv file from rhis site??

I reverse engineered the abfallplus app and wrote a litle bash script to pull the data.
You have to login into the abfall plus app to get your cookie.
Then choose your Street and select the trash info you want to recive.

Trash ids:

664-704-v0 - 664-704-v1 - Rest
664-695-v0 - 664-695-v1 - Plastic
664-691-v0 - 664-691-v1 - Bio
664-694-v0 - 664-694-v1 - Paper
664-699-v0 - Chrismas Trees

script:

#!/bin/bash

rm /home/homeassistant/abfalldaten/data.json
rm /home/homeassistant/abfalldaten/data.xml

curl -s -H 'User-Agent: Android / MuellALARM 5.1.1 (1915051100) / DM=XT1052;DP=ghost_retasia;DN=qcom;DT=ghost;SN=motorola;SV=4.4.2 (19);MF=motorola' -H 'Host: app.abfallplus.de' -H 'Cookie:  xxxxx988cfaf08370df05cfd18c=de.k4systems.muellalarm%7C9c8bfbbb-e95c-4fe3-9af9-0d2b183d9482' --data "client=xxxxxxx-e95c-4fe3-9af9-0d2b183d9482&app_id=de.k4systems.muellalarm" --compressed 'https://app.abfallplus.de/struktur.xml.zip' > /home/homeassistant/abfalldaten/data.xml
/home/homeassistant/abfalldaten/xml2json.py -t xml2json -o /home/homeassistant/abfalldaten/data.json /home/homeassistant/abfalldaten/data.xml

data=$(cat /home/homeassistant/abfalldaten/data.json)

arrays=$(echo $data | jq '.plist.dict.array[3].dict[] | length' | wc -l)
x=0

rest=()
plastik=()
bio=()
papier=()


while [ $x -lt $arrays ];
do

     restcheck=$(echo $data | jq '.plist.dict.array[3].dict['$x'] | select(.string[].text == "664-704-v0" or .string[].text  == "664-704-v1") | .string[3].text' | head -1)
	if [ $restcheck ]; then
		rest+=("$restcheck")
	fi

     plastcheck=$(echo $data | jq '.plist.dict.array[3].dict['$x'] | select(.string[].text == "664-695-v0" or .string[].text == "664-695-v1") | .string[3].text' | head -1)
	if [ $plastcheck ]; then
		plastik+=("$plastcheck")
        fi

     biocheck=$(echo $data | jq '.plist.dict.array[3].dict['$x'] | select(.string[].text == "664-691-v0" or .string[].text == "664-691-v1") | .string[3].text' | head -1)
	if [ $biocheck ]; then
		bio+=("$biocheck")
	fi


     papiercheck=$(echo $data | jq '.plist.dict.array[3].dict['$x'] | select(.string[].text == "664-694-v0" or .string[].text == "664-694-v1") | .string[3].text' | head -1)
	if [ $papiercheck ]; then
		papier+=("$papiercheck")
	fi

x=$(( $x + 1 ))
done

rest_out=${rest[0]}
plast_out=${plastik[0]}
bio_out=${bio[0]}
papier_out=${papier[0]}

json=('{"Restmull": '$rest_out', "Plastik": '$plast_out', "Bio": '$bio_out', "Papier": '$papier_out'}')

mosquitto_pub -h 192.168.50.4 -t abfall/leerungen -m "$json" -r

Maybe this help somebody

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