Waste Collection Schedule Framework

Thanks a lot for your component! :slight_smile: Itā€™s exactly what I was looking for, as my waste collection provider changed his ā€œapiā€ a few weeks ago, so my old setup didnā€™t work anymore. :slight_smile:

Problem is, I donā€™t get any values for the sensors. I assume / guess, that is has something to do with the format I get the iCal data. E.g. I have LANGUAGE=de right before the entry in summary. Could you take a look at that?

Here are all my settings:

# configuration.yaml
waste_collection_schedule:
  sources:
    - name: ics
      args:
        url: "https://xmlcall.awista-starnberg.de/WasteManagementStarnberg/WasteManagementServiceServlet?ApplicationName=Calendar&SubmitAction=sync&StandortID=183695001&AboID=4310&Fra=R;P;G;B;S"
        offset: 0
      customize:
        - type: Restmuelltonne
          alias: RestmĆ¼ll
        - type: Papiertonne
          alias: Altpapier
        - type: Biotonne
          alias: Biotonne
        - type: Gelber Sack
          alias: Gelber Sack
        - type: Problemabfaelle
          alias: SondermĆ¼ll
  fetch_time: "04:23"
  day_switch_time: "09:30"

and the sensors

sensor:
  - platform: waste_collection_schedule
    name: waste_collection_waste
    details_format: upcoming
    types:
      - Restmuelltonne
  - platform: waste_collection_schedule
    name: waste_collection_paper
    details_format: upcoming
    types:
      - Papiertonne
  - platform: waste_collection_schedule
    name: waste_collection_bio
    details_format: upcoming
    types:
      - Biotonne
  - platform: waste_collection_schedule
    name: waste_collection_plastic
    details_format: upcoming
    types:
      - Gelber Sack
  - platform: waste_collection_schedule
    name: waste_collection_hazard
    details_format: upcoming
    types:
      - Problemabfaelle

and here is the link to the iCal download (no worry, itā€™s not my address in the file):
https://xmlcall.awista-starnberg.de/WasteManagementStarnberg/WasteManagementServiceServlet?ApplicationName=Calendar&SubmitAction=sync&StandortID=183695001&AboID=4310&Fra=R;P;G;B;S

Would be great, if you could take a look at it. Thanks a lot! :slight_smile:

1 Like

Hi, I think I was able to reproduce your issue. However, to fix it I need some more time. I come back to youā€¦

1 Like

Please try the lastest version from HACS.

The problem was that your service provider adds an unnecessary whitespace to the appointment type, e.g. "Restmuell ". Therefore your type filters didnā€™t match. You could fix this also in your configuration.yaml, but I decided to now strip all leading and tailing whitespaces from the appointment types. Therefore your current configuration should work after the update.

2 Likes

Yep, that totally sounds like themā€¦ :laughing: :laughing: The last ā€œapiā€ they provided was an Excel or *.pdf download, so I donā€™t want to complain! :laughing: :laughing:

Thanks a lot for the really quick fix, all is working as intended now! I assume the other way via configuration.yaml would be to put an ā€™ ā€™ at the end like 'Restmuell '. But as said, it works out-of-the-box right now, thank you! :slight_smile:

Correct, "Restmuell " is the alternative way in yaml.

Hello together.

I tried to use the waste collection schedule with a local ics file as well as with an url but it does not show anything in my sensor an in the home-assistant.log I have this entry:

2020-09-04 15:19:13 ERROR (SyncWorker_19) [custom_components.waste_collection_schedule.package.scraper] fetch failed for source <custom_components.waste_collection_schedule.package.source.ics.Source object at 0x51e8cd50>: Expected datetime, date, or time, got: '5'

Can someone help me with that error?

Thanks.

Hi Christian, please share your ics file or the url.

Here is the link to the file: https://www.abfallkalender-ab.de/cache/ical/Gruenmorsbach-2020-1599244426.ics

I donā€™t know how to attach the file directly, but you can download it via the link :wink:

And regarding the link I have also a question. The link contains the current unix timestamp after the year. Do you know how I have to edit the ics.py skript that it adds the timestamp automatically after the {%Y} wildcard?

EDIT: I deleted line by line of the ics file to figure what causes the error.

So now I know that this line of my ics file causes the error:

DURATION:5

Without that line everything is working fine.

So any idea what to change in the ics skript that it is working for me?

Right: ā€œ5ā€ for duration is an invalid value. Please inform your service provider to fix the problem in their ics file generator.

As a workaround you could use filter to remove the invalid lines. Example (not tested!!!):
Add after line 117 in ics.py:
data = filter(lambda line: 'DURATION' not in line, data.splitlines())

Regarding the timestamp: Although it looks like a unix timestamp, it is probably a unique id for the choices (city, types, ā€¦) you made previously in the web frontend. The generated link is only valid for a certain period of time (the link above already doesnā€™t work any more). If you want to retrieve the schedule daily (instead of storing it once into a file) you have to write a dedicated scraper for abfallkalender-ab.de (for examples see other scrapers).

1 Like

Have been running the waste collection schedule against my own calendar ics file with the bin collection days for a while now - but in the last few days since my home assistant had a segmentation fault the waste_collection_schedule isnā€™t working - it does not contain any information and if I restart Home assistant it doesnā€™t do anything. In the logs there is only the reference to the usual loading;

[homeassistant.loader] You are using a custom integration for waste_collection_schedule which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.

Any idea on how to get the component working again?

You could try to delete the pycache directory. Maybe this ist corrupted, too.

Deleted, it recreated no difference, tried reinstalling via HACS and that didnā€™t do anything either.

I tried removing sensor and configuration, restart and readding and restarting - same issue.

However if I changed the source URL to an invalid URL the wastecollection component did report an error in the log - so seems to be runningā€¦

I take it there is no debug option on the component that will help?

Could it be that simple that all your appointments are in the past?

interestingly they were recurring events, but had finished at the end of this month as I could still see them in the calendar the ics file is published from so shouldā€™ve still shown something on the schedule.

I extended the same reoccurring events for another month and they are now appearing! So may not have got the last entry for each of those events

Hi Steffen, thanks for your great work. I tried to figure out, how to integrate the ics-File provided for the Berlin recycling-garbage on the website ā€œTrenntstadt Berlinā€. (the BSR is not doing all the ā€œdirty jobsā€ here in Berlin :wink:) As a javascript/php-dumb i think, that the website is buildig the ics ā€œreal-timeā€, based on the information/xml it is getting from this ā€œapiā€ https://trenntstadt-berlin.de/api-abfuhr.php?adrkey=6985692&step=2 which leads to an xml file: https://sep.bsr.de/bsr/services/trenntstadt/YemTGarbageDisposal(ā€˜6985692ā€™)

But i have no clue how to use that output for getting it as a source in your framework. If you have an idea to push me in the right direction, go for it. Thanx in advance!

Hi MaDtze,

I tried to figure out how the ā€œTrenntstadtā€ api is working, but I failed to find a valid combination of Strasse of PLZ. Could you please share one?

I wonder, why this automation doesnā€™t work. The status ā€œRestmĆ¼ll-Tonne in 1 Tagenā€ is correct and it should produce a notification one day before the garbage will be collected:

alias: Nachricht RestmĆ¼ll
description: ''
trigger:
  - platform: state
    entity_id: sensor.waste_collection_waste
    to: RestmĆ¼ll-Tonne in 1 Tagen
condition:
  - condition: time
    after: '13:30'
action:
  - data:
      message: Morgen wird der RestmĆ¼ll abgeholt.
    service: notify.telegram_ha_message
mode: single

Maybe, because the status was already ā€œRestmĆ¼ll-Tonne in 1 Tagenā€, when I created the rule and it will only run, when the status changed?

Okay, this works:

alias: Nachricht RestmĆ¼ll
description: ''
trigger:
  - platform: time
    at: '13:30'
condition:
  - condition: state
    entity_id: sensor.waste_collection_waste
    state: RestmĆ¼ll-Tonne in 1 Tagen
action:
  - data:
      message: Morgen wird der RestmĆ¼ll abgeholt.
    service: notify.telegram_ha_message
mode: single

Notification is not working for meā€¦

I have a sensor like this:

  - platform: waste_collection_schedule
    name: MyButtonCardSensorrest
    value_template: '{{value.types|join(", ")}}|{{value.daysTo}}|{{value.date.strftime("%d.%m.%Y")}}|{{value.date.strftime("%a")}}'
    types:
      - Restabfall

This brings me up the UI message:

ha

Now I try the automation like:

- id: 'xxx'
  alias: RestmĆ¼llinfo
  description: ''
  trigger:
  - platform: time
    at: '13:00'
  condition:
  - condition: state
    entity_id: sensor.mybuttoncardsensorrest
    state: Restabfall Morgen # or in 7 Tagen, or something
  action:
  - service: notify.mobile_app_daves_samsung
    data:
      message: Morgen wird die RestmĆ¼lltonne abgeholt.
  mode: single

ā€¦ but the state of sensor.mybuttoncardsensorrest never is like ā€œRestabfall Morgenā€ - it is a formated date from the value template of the sensor.

ha2

I donā€™t get the idea how to format my automation condition state to get the state like in the value template or as the shown ā€œreadable wordsā€.

Any idea anyone? THANKS!

Got it!

I used a template as trigger:

- condition: template
    value_template: >
        {{ (states.sensor.MyButtonCardSensorpapier.state.split('|')[1]) =='1' }}  action:
  - service: notify.mobile_app_daves_samsung
1 Like