mampfes / hacs_waste_collection_schedule

Home Assistant integration framework for (garbage collection) schedules
MIT License
972 stars 628 forks source link

[Bug]: muellabfuhr_de.py / client "Saalekreis" need more Parameter #1506

Closed MedicusOne closed 8 months ago

MedicusOne commented 8 months ago

I Have A Problem With:

A specific source

What's Your Problem

The source “muellabfahrt_de.py” only contains the parameters for client and city. However, the client "Saalekreis" needs 2 additional subqueries: client > city > district > street.

Solution: Example for Saalekreis > Kabelsketal > Großkugel > Am Markt

  1. get Client: https://portal.muellabfuhr-deutschland.de/api-portal/mandators {"id":"35","name":"Saalekreis"}

  2. get client config: https://portal.muellabfuhr-deutschland.de/api-portal/mandators/35/config "calendarRootLocationId":"5ca7ca7e-3304-4fe4-933e-58706084dac9"

  3. get city list: https://portal.muellabfuhr-deutschland.de/api-portal/mandators/35/cal/location/5ca7ca7e-3304-4fe4-933e-58706084dac9?includeChildren=true ...,{"id":"140a18d5-76f9-4117-a07e-4f9b1aaec6e7","name":"Kabelsketal","isFinal":false,"children":[]},...

  4. If isFinal is false, we need another request. Here then the district, if configured https://portal.muellabfuhr-deutschland.de/api-portal/mandators/35/cal/location/140a18d5-76f9-4117-a07e-4f9b1aaec6e7?includeChildren=true ...,{"id":"4709579d-3f7f-4aeb-ac90-350535fb035f","name":"Großkugel","isFinal":false,"children":[]},...

  5. If isFinal is false, we need another request. Here then the street, if configured https://portal.muellabfuhr-deutschland.de/api-portal/mandators/35/cal/location/4709579d-3f7f-4aeb-ac90-350535fb035f?includeChildren=true ...,{"id":"d21f9227-7916-4c9d-8814-46dc0c15a7ff","name":"Am Markt","isFinal":true,"children":[]},...

  6. get pickups https://portal.muellabfuhr-deutschland.de/api-portal/mandators/35/cal/location/d21f9227-7916-4c9d-8814-46dc0c15a7ff/pickups

Steps 4 and 5 are currently missing and would have to be implemented as optional. Other destrics from Kabelsketal do not require street information, only step 4. (isFinal is then true)

Source (if relevant)

muellabfuhr_de

Logs

No response

Relevant Configuration

waste_collection_schedule:
  sources:
    - name: muellabfuhr_de
      args:
        client: "Saalekreis"
        city: "Kabelsketal"

Checklist Source Error

Checklist Sensor Error

Required

MedicusOne commented 8 months ago

Hi, here is my patch. Please check und test it, because I only rarely work with Phyton. muellabfuhr_de.py_diff.txt

5ila5 commented 8 months ago

looks fine on first look. Can you create a pull request? Then I will have a more detailed look

MedicusOne commented 8 months ago

I created a pull request