Waste Collection Schedule Framework

There are some minor errors in your configuration (esp. alias and missing space in sensor types). The following configuration should work for you:

waste_collection_schedule:
  sources:
    - name: ics
      args:
        url: "https://gwa-abfuhrkalender.de/ical.html?jahr=2021&kommune=7&bezirk=56&filter=3,6,2,1,13"
      customize:
        - type: Biotonne
          icon: mdi:trash-can
        - type: Glas
          icon: mdi:trash-can
        - type: Wertstofftonne
          icon: mdi:recycle
        - type: Papiertonne
          icon: mdi:trash-can
        - type: Restmüll 2-wchtl.
          alias: Restmüll
          icon: mdi:trash-can

sensor:
  - platform: waste_collection_schedule
    name: Biotonne
    details_format: "upcoming"
    value_template: '{{value.daysTo}}'
    types:
      - Biotonne
  - platform: waste_collection_schedule
    name: Glas
    details_format: "upcoming"
    value_template: '{{value.daysTo}}'
    types:
      - Glas
  - platform: waste_collection_schedule
    name: Wertstofftonne
    details_format: "upcoming"
    value_template: '{{value.daysTo}}'
    types:
      - Wertstofftonne
  - platform: waste_collection_schedule
    name: Papiertonne
    details_format: "upcoming"
    value_template: '{{value.daysTo}}'
    types:
      - Papiertonne
  - platform: waste_collection_schedule
    name: Restmüll
    details_format: "upcoming"
    value_template: '{{value.daysTo}}'
    types:
      - Restmüll

Thank you for your quick response. The problem is now fixed.

I’m having a slight problem since a few days, something with the calendar is not working as expected, at least my log tells me this:

Logger: homeassistant.components.recorder
Source: components/recorder/__init__.py:454
Integration: Recorder (documentation, issues)
First occurred: 15:50:51 (1 occurrences)
Last logged: 15:50:51

Event is not JSON serializable: <Event platform_discovered[L]: service=load_platform.calendar, platform=waste_collection_schedule, discovered=api=<custom_components.waste_collection_schedule.WasteCollectionApi object at 0xb1536a78>>

Funny thing, I’ve disabled calendar and excluded the calendar domain from recorder, history and logbook… Any ideas or a direction where to look at? Or could we disable calendarat all from this integration?

Thanks for the info. Do you still observe this issue with Home Assistant 2021.4 ?

I’ve seen it in an older log, but I’m unable to reproduce it with 2021.4.

Hi, is there anyone out there who can help me to draw a nice icon for Waste Collection Schedule? I want to add it the Home Assistant brands repository, so that is shows up in the list of available integrations in HACS.
The icon shall be free of any license requirements that requires attribution or more.

Thanks in advance.

Sorry, didn’t get notice about your reply. Everything fine, works without any errors or log messages. :slight_smile:

Someone can help me to show the days and colorize the icon accorgndly?

type: 'custom:button-card'
entity: sensor.restmull
show_label: true
label: |
  [[[
    var days_to = entity.state.split("|")[1]
    if (days_to == 0)
    { return "Today" }
    else if (days_to == 0)
    { return "Tomorrow" }
    else
    { return "in " + days_to + " days" }
  ]]]
show_name: true
name: |
  [[[
    return entity.state.split("|")[0]
  ]]]
state:
  - color: red
    operator: template
    value: '[[[ return entity.state.split("|")[1] == 0 ]]]'
  - color: orange
    operator: template
    value: '[[[ return entity.state.split("|")[1] == 1 ]]]'
  - value: default

and this is the sensor configuration:

- platform: waste_collection_schedule
    name: Restmüll
    details_format: "upcoming"
    value_template: "{{value.daysTo}}"
    types:
      - Restmülltonne

I get this:
image

Hi, the value_template doesn’t match the button-card configuration. Please use value_template from the example (see FAQ No. 11).

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

The example is using sensor entity for all waste types. If you want to have dedicated sensors per waste type, you can simplify the value_template and also the button card configuration (remove split and index operator []).

Worked like a charm. Now I understood how to manage the value template. Thanks.

1 Like

Hi!
I am quite new to Home Assistant but the learning curve is steep and I enjoy the flexibility, that HA offers in many aspects.
At the moment however, I struggle with the implementation of the waste collection scheduler, in particular when trying to run the Python script to retrieve the args for Stadtreinigun Hamburg as described here. https://github.com/mampfes/hacs_waste_collection_schedule/blob/00c065b43bd6bf30022e8eee2a2faaa24501a82c/doc/source/stadtreinigung_hamburg.md.
I get the following error:
grafik

I am able to run other simple python scripts from the same folder, so it seems to me, the file could be somehow corrupt.

Has anyone successfully run the script? Any other ideas what mistake I could make?
Thanks, Holger

Hi, I assume you stored the HTML view of the file instead of the raw file.

If I interpret the command line correctly, you try to run the wizard script on Windows. This will probably not work because the necessary inquirer library is currently not supported on Windows. If you don’t have access to a Linux box, you can also send me a PN and I will extract the IDs for you.

Thank for your swift reply.

It seems, both your assumptions are correct. I have saved the file as raw and the resulting error confirms, that inquirer service is missing. I tried on a windows machine, indeed.
grafik

I have an linux machine running, so I will take the opportunity to learn.
However, I really appreciate your offer to extract the ID as I would like to thank you for your great, very versatile HO integration.

Hi,
thanks for this very usefull framwork. I’m living in Berlin and I have three different waste collection provider at my location: BSR for Restmüll and Biotonne, Berlin Recycling for Altpapier further Alba for Gelber Sack.
BSR source works fine. Berlin Recycling offers an ICS file but I have to login to Kundenportal for download. So I stored this file local and defined it as ICS source.
My source definition:

# Müllabfuhr
waste_collection_schedule:
  sources:
    - name: bsr_de
      args:
        abf_strasse: "............str., 13127 Berlin (Pankow)"
        abf_hausnr: 1...
      customize:
        - type: Abholung Hausmüll
          alias: restabfall
          icon: mdi:trash-can-outline
        - type: Abholung Biogut
          alias: bioabfall
          icon: mdi:trash-can
          
    - name: ics
      args:
        file: "www/Event.ics"
      calendar_title: Berliner Recycling
      customize:
        - type: Abholung Altpapier
          alias: altpapier
          icon: mdi:trash-can
          
    - name: ics
      args:
        file: "www/wertstoffe.ics"
      customize:
        - type: Abholung Wertstoffe
          alias: wertstoffe
          icon: mdi:recycle

  fetch_time: "04:00"
  day_switch_time: "09:00"

My sensor definition for Alpapier

  - platform: waste_collection_schedule
    name: Altpapier
    details_format: "upcoming"
    value_template: '{% if value.daysTo == 0 %}heute{% elif value.daysTo == 1 %}morgen{% else %}in {{value.daysTo}} Tagen{% endif %}'
    types:
     - altpapier

And my downloaded and anonymized snipp of ICS file

BEGIN:VCALENDAR
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
UID:dd2207f4-a341-415a-9bd0-ed9f1c1ab420
DESCRIPTION:120 L MGB Leerung
DTSTART;VALUE=DATE:20210713
DTEND;VALUE=DATE:20210714
SUMMARY:5.01 Altpapier, gemischt
LOCATION:...str. 1..
END:VEVENT
BEGIN:VEVENT
UID:298a6104-d8e0-41cd-90c1-fac1d36def1b
DESCRIPTION:120 L MGB Leerung
DTSTART;VALUE=DATE:20210727
DTEND;VALUE=DATE:20210728
SUMMARY:5.01 Altpapier, gemischt
LOCATION:...str. 1..
END:VEVENT
BEGIN:VEVENT
UID:80505391-6967-42e0-a863-879a86f85a96
DESCRIPTION:120 L MGB Leerung
DTSTART;VALUE=DATE:20210810
DTEND;VALUE=DATE:20210811
SUMMARY:5.01 Altpapier, gemischt
LOCATION:...str. 1..
END:VEVENT
END:VCALENDAR

Altpapier events are displayed in my calendar but the card stays empty
2021-06-30 21_13_37-Window

Thanks in advance for your help

2 Likes
  - platform: waste_collection_schedule
    name: Altpapier
    details_format: "upcoming"
    value_template: '{% if value.daysTo == 0 %}heute{% elif value.daysTo == 1 %}morgen{% else %}in {{value.daysTo}} Tagen{% endif %}'
    types:
      - altpapier

Looks like a missing space before “- altpapier”. There should be two spaces.

1 Like

Hi,
no I think there is no mistake. I use the build in File Editor, it looks for missing spaces. My other sensors have the same syntax and they working fine.

Compare the code you wrote with the code I wrote. I already added the missing space. Maybe it’s a c&p mistake of yours but there’s is missing one.

What is your sensor showing under Developer Tools?

customizetype has to match the summary field in the ICS file, which is “5.01 Altpapier, gemischt” in your example. So please try:

      customize:
        - type: 5.01 Altpapier, gemischt
          alias: altpapier
          icon: mdi:trash-can
1 Like

Thanks for your hint. I have adjusted type but no success. Card entry for Altpapier is still empty.
I tried to read my clendar with the HACS ICS integration https://github.com/KoljaWindeler/ics and it works

ICS configuration

/config/sensors.yaml 
  - platform: ics
    name: Altpapier_ICS
    url: http://localhost:8123/local/Event.ics
    id: 1  

2021-07-02 22_39_35-Clipboard

My Framework configuration again:

/config/configuration.yaml
    - name: ics
      args:
        file: "www/Event.ics"
      calendar_title: Berliner Recycling
      customize:
        - type: 5.01 Altpapier, gemischt
          alias: altpapier
          icon: mdi:trash-can
/config/sensors.yaml 
 - platform: waste_collection_schedule
    name: Altpapier
    details_format: "upcoming"
    value_template: '{% if value.daysTo == 0 %}heute{% elif value.daysTo == 1 %}morgen{% else %}in {{value.daysTo}} Tagen{% endif %}'
    types:
     - altpapier

Thanks for your support
Andreas

You are using multiple sources (BSR + ICS), right? Then you have to add the attribute source_index to the sensor configuration.
So if Altpapier is the 2nd source in your configuration, the sensor config would like this:

/config/sensors.yaml 
 - platform: waste_collection_schedule
    name: Altpapier
    source_index: 1
    details_format: "upcoming"
    value_template: '{% if value.daysTo == 0 %}heute{% elif value.daysTo == 1 %}morgen{% else %}in {{value.daysTo}} Tagen{% endif %}'
    types:
     - altpapier

Yes I’m using three sources. Adding source_index attribute helped.
Unbenannt

Thank you very much
Best greetings
Andreas