Waste Collection Schedule Framework

Hi :wave:!
The sledgehammer solution for your problem would probably be RegEx Templating - Home Assistant

BTW. Knx strings are usually 14 chars max (your device may drop 4 - I don’t know). knx.send will raise an error if you try to send longer strings whereas expose will drop everything after the 14th char.

1 Like

thanks!

I found this

string|regex_replace(find=’’, replace=’’, ignorecase=False)

and it worked… :slight_smile:

value_template: '{{value.types|join(", ")| replace(“Papier”, “P”)}}: {% if value.daysTo == 0 %}Heute{% elif value.daysTo == 1 %}Morgen{% else %}in {{value.daysTo}} Tage{% endif %}’

gives ne this:

P: Morgen

2 Likes

sorry, of course I mean 14. couldn’t remember the exact number of signs

I am having difficulties putting more than one static sensor in my yaml file. The documentation does show any examples like this. Is it allowed?. I have tested each of my four static sensors by themselves and the all work. If I add more than one 1 shows up and the others unavailable.

Hi Hohenloherin
can you please share your config?
I also live in Nuremberg, unfortunately I can’t get the configuration to work.

@bschatzow: The source index doesn’t match the waste types in your sensor config. Recycle has the source index 1 (not 2), and Yard Waste has the source index 2 (not 1).

You can also omit the 2 lines

  types:
    - <waste type>

per sensor, because each source only provides one waste type. Therefore you don’t have to filter for a specific waste type (which causes your problem because the waste type filter doesn’t match any waste type provided by the named source).

Having an issue setting up this particular static sensor…

- name: static
      args:
        type: Bulk Trash
        frequency: MONTHLY
        weekdays: { WE:1 }

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/setup.py", line 257, in _async_setup_component
result = await task
File "/config/custom_components/waste_collection_schedule/__init__.py", line 109, in async_setup
api.add_source_shell(
File "/config/custom_components/waste_collection_schedule/__init__.py", line 202, in add_source_shell
SourceShell.create(
File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/source_shell.py", line 196, in create
source = source_module.Source(**source_args) # type: ignore
File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/source/static.py", line 76, in __init__
[
File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/source/static.py", line 77, in <listcomp>
self.add_weekday(weekday, count)
File "/config/custom_components/waste_collection_schedule/waste_collection_schedule/source/static.py", line 106, in add_weekday
raise Exception(f"invalid weekday: {weekday}")
Exception: invalid weekday: WE:1

Can anyone explain this?

My solution using static cards, and the Waste collection Schedule Framework is posted here:

https://community.home-assistant.io/t/garbage-collection-recommendations-for-replacement-of-bruxy-integration/566964/11?u=bschatzow

I believe I can help others with static sensors as I had lots of questions to get mine working.

@b3voholic Are the 3 backticks behind { WE:1 } are just an artefact or do you really have them in your config? If yes, just remove them.

Hi all,
as a non-tech guy I love to fiddle around with my pi3 homeassistant instance but from time to time get to a roadblock where I have no clue how to help myself. This time I would love to include a waste calendar to my information screen.

I read through parts of this thread but fail to find a solution. Maybe someone here has a clue and would be so kind to help. I installed the “Waste Collection Schedule” over HACS. I can see the added files in /config/custom_components/waste_collection_schedule.
I added the following in my configuration.yaml:

sensor: !include sensor.yaml
waste_collection_schedule:
 sources:
    - name: stadtreinigung_hamburg
      args:
        hnId: ***** #(number removed here)

And my sensor.yaml had been empty but I added the following:

- platform: waste_collection_schedule
  name: Abfuhr Blacksack
  details_format: "upcoming"

I do not seem to find any entity or sensor when trying to add a new card. Any suggestion how to find out whether data is retrieved and available?

I downloaded the relevant ics file manually from another computer which contains the following:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:Stadtreinigung Hamburg//Abfuhrkalender//DE
NAME:SRH-Abfuhren
X-WR-CALNAME:SRH-Abfuhren
DESCRIPTION:Aktuelle Abholtermine in Hamburg
X-WR-CALDESC:Aktuelle Abholtermine in Hamburg
SOURCE;VALUE=URI:https://backend.stadtreinigung.hamburg/kalender/abholtermi
 ne.ics?hnIds=***** #(number removed here)
REFRESH-INTERVAL;VALUE=DURATION:PT720M
X-PUBLISHED-TTL:PT720M
BEGIN:VTIMEZONE
TZID:Europe/Berlin
BEGIN:STANDARD
(...)  #(lines removed here)
DTSTAMP:20230520T002747Z
SUMMARY:Abfuhr Blacksack
DESCRIPTION:Die Abholung erfolgt ab 6:00 Uhr
LOCATION: ************* #(Street removed here)
TRANSP:TRANSPARENT
DTSTART;TZID=Europe/Berlin;VALUE=DATE:20230525
DTEND;TZID=Europe/Berlin;VALUE=DATE:20230526
X-SRH-CONTAINER-TYPE:blacksack
BEGIN:VALARM
ACTION:DISPLAY
TRIGGER:-PT360M
END:VALARM
END:VEVENT
BEGIN:VEVENT
UID:646f81c5a9a81
DTSTAMP:20220719T113636Z

There are “blacksack” and “yellow” collections. The relevant lines for “yellow” in the ics file should be as follows:

SUMMARY:Abfuhr gelbe Wertstofftonne/-sack
(...) #(lines removed here)
X-SRH-CONTAINER-TYPE:yellow

In the “home-assistant.log” (which I just discovered) the only reference to “waste” is the following:

2023-05-24 22:04:02.645 WARNING (SyncWorker_1) [homeassistant.loader] We found a custom integration 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

It would be great if someone could help me to get back on track to get this sorted. Apologies that also standard procedures may be unknown to me. Happy to learn new stuff.

No they are not in the config. Not sure why they showed up here.

The colon needs to be followed by a space, otherwise it will not be detected as a dictionary.

The documention was wrong. I also fixed the issue there.

@Paluty The warning regarding ... has not been tested ... is unavoidable. This message will be printed for every custom component.

Do you see valid entries in the Home Assistant calendar? If yes, then the problem relates to the sensor config.

stadtreinigung_hamburg returns valid entries with the test address on my machine.

Thanks! That seemed to fix it. I appreciate your help.

1 Like

Hi Kabala,

please find my code I use in my config:

 MĂźllabfuhr Informationen
waste_collection_schedule:
  sources:
    - name: abfallnavi_de
      args:
        service: nuernberg
        ort: NĂźrnberg
        strasse: xyzstrasse
        hausnummer: 00
      customize:
        - type: Restabfall
          alias: RestmĂźll
          show: true
          icon: mdi:delete-empty
          picture: none
        - type: Bioabfall
          alias: Kompost
          show: true
          icon: mdi:compost
          picture: none
        - type: Papiertonne
          alias: Altpapier
          show: true
          icon: mdi:recycle
          picture: none  
        - type: "Papiertonne 1100" #The identity of the waste type as returned from the source
          show: false #Show (True) or hide collections of this specific waste type.
        - type: Gelbe Tonne
          alias: Wertstofftonne
          show: true
          icon: mdi:recycle-variant
          picture: none  
  fetch_time: "05:47"
  random_fetch_time_offset: 35
  day_switch_time: "13:30"
  separator: SEPARATOR    

hope this helps you.

3 Likes

Thanks for your reply. I did not use the calendar before. Created a new calendar but there are no entries. Will Look into this again tomorrow. Any hints welcome.

My uneducated guess is that nothing showed up because the calendar integration was not installed. I failed to unistall and reinstall but found another integration which does the work. Hence, this can be closed, it seemed that I messed the installation up. For me this is fixed but if it is of interest I can test to uninstall and reinstall. Would need someone to tell me how though. Otherwise my request can be closed. @Mampfes: Amazing project and thank you for the hint to the calendar.

@Paluty The HA calendar is available via the menu on the left side. You don’t have to install an integration for that.

This seems to be working great although I’m not sure if I’m doing something wrong it seems to be integrated fine. However Garden Waste appears twice for United Kingdom/Newcastle Under Lyme council calendar, I know this is just the date that is pulled but is there a simple waste of removing the duplicate entry?

Hi, i didn’t find my location austria 4563 Micheldorf for a ics file and so i configured multiple static source in waste_collection.yaml. The problem is, when i put up more then one start intervall the sensor and calender doesn’t work.

here is the waste_collection.yaml

sources:
  - name: static
    calendar_title: Altpapier
    args:
      type: Altpapier
      frequency: WEEKLY
      interval: 4
      start: "2023-01-11"
    customize:
      - type: Altpapier
        icon: mdi:trash-can
  - name: static
    calendar_title: Biomuell
    args:
      type: Biomuell
      frequency: WEEKLY
      interval: 1
      start: "2023-01-05"
    customize:
      - type: Biomuell
        icon: mdi:flower-outline
  - name: static
    calendar_title: GelberSack
    args:
      type: GelberSack
      frequency: WEEKLY
      interval: 6
      start: "2023-02-17"
      weekdays: FR
    customize:
      - type: GelberSack
        icon: mdi:recycle
  - name: static
    calendar_title: Restmuell
    args:
      type: Restmuell
      frequency: WEEKLY
      interval: 2
      start: "2023-01-05"
    customize:
      - type: Restmuell
        icon: mdi:trash-can

for the sensor, i have made a directory search and so it look’s like a bit diffrent to your original config
here i have made a global sensor:

platform: waste_collection_schedule
name: next_Muell
source_index: [0, 1, 2, 3]
details_format: "upcoming"
value_template: "{% if value.daysTo == 0 %}Heute{% elif value.daysTo == 1 %}Morgen{% else %}in {{value.daysTo}} Tagen{% endif %}"

and then the dedicated sensor’s

platform: waste_collection_schedule
name: Altpapier
source_index: 0
details_format: "upcoming"
value_template: "{% if value.daysTo == 0 %}Heute{% elif value.daysTo == 1 %}Morgen{% else %}in {{value.daysTo}} Tagen{% endif %}"
types:
  - Altpapier
platform: waste_collection_schedule
name: Biomuell
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:
  - Biomuell
platform: waste_collection_schedule
name: GelberSack
source_index: 2
details_format: "upcoming"
value_template: "{% if value.daysTo == 0 %}Heute{% elif value.daysTo == 1 %}Morgen{% else %}in {{value.daysTo}} Tagen{% endif %}"
types:
  - GelberSack
platform: waste_collection_schedule
name: Restmuell
source_index: 3
details_format: "upcoming"
value_template: "{% if value.daysTo == 0 %}Heute{% elif value.daysTo == 1 %}Morgen{% else %}in {{value.daysTo}} Tagen{% endif %}"
types:
  - Restmuell

i made a complete restart from the system for the status:
restmuell: calendar off sensor: unknown
gelbersack: calendar off sensor: in 7 tagen
biomuell: calendar off sensor: unknown
altpapier: calendar off sensor: in 11 tagen
next_Muell: sensor in 6 Tagen with the data of waste paper and yellow sack
2023-06-23: GelberSack
2023-06-28: Altpapier
2023-07-26: Altpapier
2023-08-04: GelberSack
2023-08-23: Altpapier
2023-09-15: GelberSack
2023-09-20: Altpapier
2023-10-27: GelberSack
2023-12-08: GelberSack
2024-01-19: GelberSack
2024-03-01: GelberSack
attribution: Last update: 06/16/23 23:44:45
icon: mdi:recycle
friendly_name: next_Muell

can you help me out with this config problem. i think it is a bug because i have also tryed the config from Bill Schatzow, this is working.

You may also want to ask @amaxims the code owner of the garbage-collection-card. Not sure if your issue is coming from the waste collection integration or the front end card or your code. Hopefully someone can help you figure it out. @amaxims spotted my error after I spent many weeks of struggling to get it working. Good luck!

amaximus

1 Like