Waste Collection Schedule Framework

Hi, without the ics file it is hard to guess.

The only thing that looks strange to me are the single quotes in the screenshot. They shouldn’t be there…

I have got a new topic:
How to change the weekday language from english to german?

obviously it is not possible to change the location in home assistant, so that the language of strftime is allways english …

I try to create an array with the german weekdays an try to get them by value.date and some test values

value_template: >-
  {% set wochentag = ["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"] %}
  {% if value.daysTo == 0 %}heute{% elif value.daysTo == 1 %}morgen{% else %}in {{value.daysTo}} Tagen{% endif %} am {{ wochentag[value.date.strftime("%w")] }} {{value.date.strftime("%w")}} {{ wochentag[1] }}

the result is
in 14 Tagen am 5 Dienstag

That means
{{value.date.strftime("%w")}} is working, because the result is 5
{{ wochentag[1] }} is working, because the result is Dienstag
but the combination {{ wochentag[value.date.strftime("%w")] }} do not give any result … it is just empty, but why? :smiley:

Any idea? :slight_smile:
thanks and regards

You might need to convert the result of strftime from a string to an integer to index the array:

wochentag[int(value.date.strftime("%w"))]
1 Like

Hi all
I can’t get the ics to work on my HASS, the calendar SYMAT is appearing in my sidebar but it’s empty.
I can’t find my error here. There is no warning/error in the logbook.

#===================
#= Agenda poubelles
#===================
waste_collection_schedule:
  sources:
    - name: ics
      args:
        url: "https://www.symat.fr/espace_perso/getDatesICS/symat-aureilhan-nord.ics"
      customize:
        - type: Symat - Sortie du bac ordures ménagères
          alias: SortieBacGrenat
        - type: Symat - Sortie du bac tri sélectif
          alias: SortieBacJaune
      calendar_title: SYMAT
  fetch_time: "01:00"
  day_switch_time: "10:00"

sensor:
  - platform: waste_collection_schedule
    name: RamassageGrenat
    details_format: "appointment_types"
    count: 4
    value_template: '{{value.daysTo}}'
    add_days_to: True
    types:
      - SortieBacGrenat

The url returns an empty ICS file:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//ZContent.net//ZapCalLib 1.0//EN
CALSCALE:GREGORIAN
METHOD:PUBLISH
END:VCALENDAR

I assume the file is dynamically generated (and therefore can’t be used with the generic ICS source).

Yes!!! Thats it :slight_smile: Thanks a lot :slight_smile:

I try to get this to work for a longer time, but it does not work for me.

I tried the Muellmax way and also using an own ICS file, both did not work.

In general, is it possible to use two calendar sources?

Paper collection is managed by a company that only offers a pdf file, so at least the paper collection has to be inserted by an own file…

Hi Sebastian,
this is my muellmax way and it worked. Both ways with API Request and ICS File. But I’ve decided to use the ICS Version because on the Website of my local Provider (RSAG) I can select the types of collection. This is not possible via API Call so i would need to exclude what I don’t need. so I went away from api call.

waste_collection_schedule:
  sources:
    - name: ics
      args:
#        url: URL
        file: "www/rsag_2022.ics"
#        offset: 1
#        offset: OFFSET
#        method: METHOD
#        params: PARAMS
#        year_field: YEAR_FIELD
#        split_at: SPLIT_AT
#    - name: muellmax_de
#      args:
#        service: Rsa
#        mm_frm_ort_sel: <my town>
#        mm_frm_str_sel: <my street>
      customize:
        - type: RSAG Restmülltonne 2-wö.
          alias: Restabfall
          show: true
        - type: RSAG Biotonne Regelabfuhr
          alias: Bio
          show: true
        - type: RSAG Papiertonne 4-wö.
          alias: Papier
          show: true
        - type: RSAG Wertstofftonne oder -sack 4-wö.
          alias: Wertstoff
          show: true
  fetch_time: "01:00"
  day_switch_time: "10:00"
  separator: ", "

Maybe this works also for you. Just remove comment # and add comment # where you need. Both solutions are described.

Cheers,
Ben

However I cannot use ICS and Muellmax at the same time?

For me it seems that via Muellmax I do not have to exchange the file at the end of the year, just the paper collection part.

“type” means the subject of the entry and alias the name i want to see in HA?

As far I understood, fetch time means the day the ICS file is loaded again and day_switch_time the time when HA shows the event for the next day?

you can use more than one source at the same time. this is described in the documentation. :wink:

yes, if you use muellmax there is no need for update something manually at year switch.

yes type is to say what to display (if more than one collection is inside) and how you want to name it in HA. As you can see in my case “RSAG Restmülltonne 2-wö.” is not very nice so I decided to make an alias for it.

yes, correct for fetch_time
day_switch_time means e.g. you Bio-Waste will be collected today at 7 or 8. after that (maybe 10) there is no need to show Bio-Waste Collection again for the whole day because it was already picked up…or not if you forgot to put it out on the street :slight_smile:

So now I’ve got a calendar named “Abfall” which contains the entries of the ICS file.

But there are no entities for using the entity card like in docs?

do you have created the according sensors?

  - platform: waste_collection_schedule
    name: restabfall
    details_format: upcoming
    add_days_to: True
    count: 4
    leadtime: 7
    value_template: '{{value.types|join(", ")}}|{{value.daysTo}}|{{value.date.strftime("%d.%m.%Y")}}|{{value.date.strftime("%a")}}'
    date_template: '{{value.date.strftime("%d.%m.%Y")}}'
    types:
      - 'Restabfall'

There is no need to create an private ICS file if you want to hide some waste types from being displayed. You can exclude unwanted waste types in the customize section of a source:

customize:
  - type: UnwantedWasteType
    show: False

Or are there other reasons why you chose the private ICS way?

I know that I can exclude those types of waste…but I was too lazy to do this because my local provider RSAG has aprox. 12 different types of waste which also includes “Weihnachtsbaumabholung” oder “Grosscontainer” oder “Problemabfall” several times over the year on central collection points and I don’t want to exclude each of them. for me it’s not a problem to request once a year a new file and put it in the right place. also I minimize api calls to muellmax and additional network traffic.

Hi, I am having problems with the sensors, probably an iCal error, since everything is undefined and sensors have no data. Any idea why? I created the iCal file in OSX Calendar and exported it.

Configuration:

waste_collection_schedule:
  sources:
    - name: Smeti
      args:
        file: "/local/smeti.ics"
      customize:
        - type: MKO
          icon: mdi:trash-can
        - type: EMB
          icon: mdi:recycle
        - type: PAP
          icon: mdi:trash-can
        - type: BIO
          icon: mdi:trash-can 

Sensors:

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

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

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

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

Button card:

          - type: 'custom:button-card'
            entity: sensor.MKO
            layout: icon_name_state2nd
            show_label: true
            label: |
              [[[
                var days_to = entity.state.split("|")[1]
                if (days_to == 0)
                { return "Today" }
                else if (days_to == 1)
                { 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

ICS file

BEGIN:VCALENDAR
METHOD:PUBLISH
VERSION:2.0
X-WR-CALNAME:Smeti
PRODID:-//Apple Inc.//macOS 12.0.1//EN
X-APPLE-CALENDAR-COLOR:#E6C800
X-WR-TIMEZONE:Europe/Ljubljana
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:Europe/Ljubljana
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
DTSTART:19830327T020000
TZNAME:CEST
TZOFFSETTO:+0200
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
DTSTART:19961027T030000
TZNAME:CET
TZOFFSETTO:+0100
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
CREATED:20220106T181105Z
UID:E3C2E7EE-2EE1-4739-91D4-01E453C34883
DTEND;TZID=Europe/Ljubljana:20220105T100000
TRANSP:OPAQUE
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
SUMMARY:PAP
LAST-MODIFIED:20220106T181156Z
DTSTAMP:20220106T181110Z
DTSTART;TZID=Europe/Ljubljana:20220105T090000
SEQUENCE:1
END:VEVENT
BEGIN:VEVENT
CREATED:20220106T181124Z
UID:496F87B4-8287-4716-BCDC-21236C775F81
DTEND;TZID=Europe/Ljubljana:20220110T100000
TRANSP:OPAQUE
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
SUMMARY:MKO
LAST-MODIFIED:20220106T181133Z
DTSTAMP:20220106T181133Z
DTSTART;TZID=Europe/Ljubljana:20220110T090000
SEQUENCE:1
END:VEVENT
BEGIN:VEVENT
CREATED:20220106T181139Z
UID:8D952850-31D6-4A22-AB43-F7FFD1566C37
DTEND;TZID=Europe/Ljubljana:20220118T100000
TRANSP:OPAQUE
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
SUMMARY:BIO
LAST-MODIFIED:20220106T181141Z
DTSTAMP:20220106T181141Z
DTSTART;TZID=Europe/Ljubljana:20220118T090000
SEQUENCE:1
END:VEVENT
BEGIN:VEVENT
CREATED:20220106T181143Z
UID:C57FD135-B81A-42C1-9E4C-065DFCDCF465
DTEND;TZID=Europe/Ljubljana:20220119T100000
TRANSP:OPAQUE
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
SUMMARY:EMB
LAST-MODIFIED:20220106T181151Z
DTSTAMP:20220106T181152Z
DTSTART;TZID=Europe/Ljubljana:20220119T090000
SEQUENCE:1
END:VEVENT
BEGIN:VEVENT
CREATED:20220106T181200Z
UID:3B18AADD-9BBB-486A-9955-53AD71DDC6A1
DTEND;TZID=Europe/Ljubljana:20220121T100000
TRANSP:OPAQUE
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
SUMMARY:STE
LAST-MODIFIED:20220106T181204Z
DTSTAMP:20220106T181205Z
DTSTART;TZID=Europe/Ljubljana:20220121T090000
SEQUENCE:1
END:VEVENT
BEGIN:VEVENT
CREATED:20220106T181216Z
UID:929F1D8C-4A06-4D57-B4C6-FE3495C72881
DTEND;TZID=Europe/Ljubljana:20220131T100000
TRANSP:OPAQUE
X-APPLE-TRAVEL-ADVISORY-BEHAVIOR:AUTOMATIC
SUMMARY:MKO
LAST-MODIFIED:20220106T181217Z
DTSTAMP:20220106T181217Z
DTSTART;TZID=Europe/Ljubljana:20220131T090000
SEQUENCE:1
END:VEVENT
END:VCALENDAR

The name in your source configuration has to be ics (instead of Smeti):

waste_collection_schedule:
  sources:
    - name: ics
      args:
        file: "/local/smeti.ics"

Thanks, I have changed it, but still nothing. The entries also do not appear in the Home Assistant Calendar, I think they should?

Yes, they should appear in the calendar. Did you check the HA log?

I assume that the file path doesn’t fit.

If you place the file in the <config/www> folder, than the file path is (typically): file: www/smetic.ics
or sometimes: file: config/www/smetic.ics

Hi guys,

thanks for the great extension for HA, looks actually pretty good.
I´m currently trying to get this running but it fails all the time.

Here my configuration:

waste_collection_schedule:
  sources:
    - name: ics
      args:
        url: "https://stadtplan.dresden.de/project/cardo3Apps/IDU_DDStadtplan/abfall/ical.ashx?STANDORT=81206&DUMMY=637825858134981417&DATUM_VON=11.03.2022&DATUM_BIS=31.12.2022"

PS: no worries, not my actual home :wink:
From my point of view, it looks actually good, as I compared with other examples here on the forum. But everytime I get the error:

Logger: waste_collection_schedule.scraper
Source: custom_components/waste_collection_schedule/waste_collection_schedule/scraper.py:130
Integration: waste_collection_schedule (documentation)
First occurred: 08:31:35 (1 occurrences)
Last logged: 08:31:35

fetch failed for source <waste_collection_schedule.source.ics.Source object at 0x7f3ea45539d0>: 'NoneType' object has no attribute 'upper'

Any ideas or inputs from anyone?
Thanks a lot in advance!

Daniel

1 Like

Which version of waste_collection_schedule are you using? This bug should be fixed with revision 1.16.0.

1 Like