Waste Collection Schedule provides schedules from waste collection service providers to Home Assistant. Additionally, it supports schedules from generic ICS files which can be stored locally or fetched from a web site. There is a high flexibility in providing the information to be displayed.
For developers: This framework can be easily enhanced to support further waste collection service providers or other services which provide schedules.
If you like this component, please give it a star on github.
- Examples
- Supported Service Providers
- Installation
- Configuration
- FAQ
- For developers: How to add new sources
A complete example can be found here.
Per default (without further configuration), the time to the next collection will be shown in an entity card:
You can also setup dedicated entities per waste type and show the schedule in various formats:
The information in the more-info popup can be displayed in different formats:
Button Card can be used to create individual Lovelace cards:
The collection schedule will be automatically integrated into the Home Assistant calendar:
Currently the following service providers are supported:
- Banyule City Council
- Belmont City Council
- Brisbane City Council
- Campbelltown City Council
- Inner West Council (NSW)
- Ku-ring-gai Council
- Macedon Ranges Shire Council, Melbourne
- Melton City Council, Melbourne
- North Adelaide Waste Management Authority, South Australia
- Stonnington City Council, Melbourne
- The Hills Council, Sydney
- Wyndham City Council, Melbourne
- Abfall.IO / AbfallPlus.de
- AbfallNavi.de (RegioIT.de)
- Abfallkalender Würzburg
- Abfallwirtschaft Landkreis Harburg
- Abfallwirtschaft Landkreis Wolfenbüttel
- Abfallwirtschaft Neckar-Odenwald-Kreis
- Abfallwirtschaft Rendsburg
- Abfallwirtschaft Stuttgart
- Abfallwirtschaft Südholstein
- Abfallwirtschaft Zollernalbkreis
- AVL Ludwigsburg
- AWB Bad Kreuznach
- AWB Esslingen
- AWB Limburg-Weilburg
- AWB Oldenburg
- AWBKoeln.de
- AWIDO-online.de
- Berlin-Recycling.de
- BSR.de / Berliner Stadtreinigungsbetriebe
- C-Trace.de
- Cochem-Zell
- EGN-Abfallkalender.de
- Jumomind.de
- KAEV Niederlausitz
- KWB-Goslar.de
- Landkreis-Wittmund.de
- Landkreis Rhön Grabfeld
- Landkreis Schwäbisch Hall
- Muellmax.de
- MyMuell App
- Rhein-Hunsrück Entsorgung (RHE)
- Sector27.de
- Stadtreinigung Dresden
- Stadtreinigung.Hamburg
- Stadtreinigung-Leipzig.de
- Stadt-Willich.de
- Umweltbetrieb Stadt Bielefeld
- WAS Wolfsburg
- Bradford Metropolitan District Council - bradford.gov.uk
- Cambridge City Council - cambridge.gov.uk
- Canterbury City Council - canterbury.gov.uk
- Cheshire East Council - cheshireeast.gov.uk
- Chesterfield Borough Council - chesterfield.gov.uk
- Colchester Borough Council - colchester.gov.uk
- Cornwall Council - cornwall.gov.uk
- Derby City Council
- Eastbourne Borough Council - lewes-eastbourne.gov.uk
- Elmbridge Borough Council - elmbridge_gov_uk
- Guildford Borough Council - guildford.gov.uk
- Harborough District Council - www.harborough.gov.uk
- Huntingdonshire District Council - huntingdonshire.gov.uk
- Lewes District Council - lewes-eastbourne.gov.uk
- Manchester City Council - manchester.gov.uk
- Newcastle City Council - newcastle.gov.uk
- North Somerset Council - n-somerset.gov.uk
- Nottingham City Council - nottinghamcity.gov.uk
- Peterborough City Council - peterborough.gov.uk
- Richmondshire District Council - richmondshire.gov.uk
- Rushmoor Borough Council - rushmoor.gov.uk
- South Cambridgeshire District Council - scambs.gov.uk
- South Norfolk and Broadland Council - southnorfolkandbroadland.gov.uk
- Stevenage Borough Council - stevenage.gov.uk
- City of York Council - york.gov.uk
- West Berkshire Council - westberks.gov.uk
- Wiltshire Council - wiltshire.gov.uk
- Ensure that HACS is installed.
- Install the "Waste Collection Schedule" integration.
- Configure the integration.
- Restart Home Assistant.
In case you would like to install manually:
- Copy the folder
waste_collection_schedule
tocustom_components
in your Home Assistantconfig
folder. - Configure the integration.
- Restart Home Assistant.
The configuration consists of two entries in the file configuration.yaml
:
-
Source configuration
For each service provider, a source has to be added to the configuration. The source takes care of the arguments which are required to get the correct information from the service provider's web page, e.g. district, city, street, house number, etc.
If you have to fetch data from multiple service providers, you have to add multiple sources. You can also add the same service provider multiple times (which only makes sense if you use this with different arguments), e.g. if you are looking for displaying the waste collection schedules for multiple districts.
-
Sensor configuration
A sensor is used to visualize the retrieved information, e.g. waste type, next collection date or number of days to next collection. The sensor state (which is shown in a Lovelace card) can be customized using templates. As an example, you may display the collection type only or the next collection date or a combination of all available information.
You can also add multiple sensors per source if you are going to display the information in separate entities like the available collection types or the next collection date.
If you are looking for displaying one entity per collection type, you just have to add one sensor per collection type.
waste_collection_schedule:
sources:
- name: SOURCE
args:
SOURCE_SPECIFIC_ARGUMENTS
customize:
- type: TYPE
alias: ALIAS
show: SHOW
icon: ICON
picture: PICTURE
use_dedicated_calendar: USE_DEDICATED_CALENDAR
dedicated_calendar_title: DEDICATED_CALENDAR_TITLE
calendar_title: CALENDAR_TITLE
fetch_time: FETCH_TIME
random_fetch_time_offset: RANDOM_FETCH_TIME_OFFSET
day_switch_time: DAY_SWITCH_TIME
separator: SEPARATOR
sources
(list) (required)
List of service providers (waste collectors). See Source Configuration Variables for a list of available configuration variables.
fetch_time
(time) (optional, default: "01:00"
)
Time of day when to fetch new data from the source. Data will be fetched once per day.
random_fetch_time_offset
(int) (optional, default: 60
)
Random offset to the fetch_time
in minutes. Used to distribute the fetch commands of all Home Assistant instances over a larger period of time to avoid peak loads at the service providers.
day_switch_time
(time) (optional, default: "10:00"
)
Time of day when today's collection is going to expire and hence will not be displayed anymore.
How it works: If you set the day_switch_time
to 10:00 the sensor will display today's collections until 10:00. After 10:00, today's collections will not be displayed anymore.
separator
(string) (optional, default: ", "
)
Used to join entries if there are multiple entries for one day (n/a if value_templates are used).
name
(string) (required)
Name of the source (service provider). Equates to the file name (without .py
) of the source. See Supported Service Providers for a list of available sources.
args
(dict) (optional)
Source (service provider) specific arguments, e.g. district, city, street, waste type, etc. See Supported Service Providers for details.
customize
(dict) (optional)
Used to customize the retrieved data from a source (service provider). See Customize Source for a list of available configuration variables.
calendar_title
(string) (optional)
Alternative title for source in Home Assistant calendar.
Used to customize the retrieved data from a source (service provider).
type
(dict) (required)
Type of waste as it has been retrieved by the source (service provider).
alias
(string) (optional, default: None
)
Optional, usually better readable name for type of waste to be collected.
show
(boolean) (optional, default: True
)
Show or hide collections with the given waste type.
icon
(string) (optional, default: None
)
Alternative icon for waste type.
picture
(string) (optional, default: None
)
Optional picture for waste type.
use_dedicated_calendar
(boolean) (optional, default: False
)
Create a dedicated calendar for this type.
dedicated_calendar_title
(string) (optional, default: None
)
Optional title of the dedicated calendar. If not set, the default of the source will be used.
Add the following lines to your configuration.yaml
file:
sensor:
- platform: waste_collection_schedule
source_index: SOURCE_INDEX
name: NAME
details_format: DETAILS_FORMAT
count: COUNT
leadtime: LEADTIME
value_template: VALUE_TEMPLATE
date_template: DATE_TEMPLATE
add_days_to: ADD_DAYS_TO
types:
- Waste Type 1
- Waste Type 2
source_index
(integer) (optional, default: 0
)
Reference to source (service provider). Used to assign a sensor to a specific source. Only required if you defined more than one source. The first defined source has the source_index 0, the second source 1, ...
name
(string) (required)
Name of the sensor.
details_format
(string) (optional, default: "upcoming"
)
Used to specify the format of the information displayed in the more-info popup of a Lovelace card.
Possible choices:
-
upcoming
shows a list of upcoming collections. -
appointment_types
shows a list of waste types and their next collection date. -
generic
provides all attributes as generic Python data types. This can be used by a specialized Lovelace card (which doesn't exist so far).
count
(integer) (optional, default = infinite)
Used to limit the number of collections displayed in the more-info popup of a Lovelace card by count
.
leadtime
(integer) (optional, default = infinite)
Used to limit the number of collections displayed in the more-info popup of a Lovelace card. Only collections within the next leadtime
days will be displayed.
value_template
(string) (optional)
Template string used to format the state of an entity.
See Template Variables for a list of available variables.
date_template
(string) (optional)
Template string used to format collection dates within the more-info popup.
See Template Variables for a list of available variables.
add_days_to
(boolean) (optional, default: False
)
Adds an attribute with the label daysTo
and the number of days to the next collection to the entity state of the source.
types
(list of strings) (optional)
Used to filter waste types. The sensor will only display collections with these type(s).
The following variables can be used within value_template
and date_template
:
Variable | Description | Type | Comments |
---|---|---|---|
value.date |
Collection date | datetime.date | Use strftime to format the output. |
value.daysTo |
Days to collection | int | 0 = today, 1 = tomorrow, ... |
value.types |
Waste types | list of strings | Use join filter to join types. |
Use strftime in value_template
or date_template
:
# returns "20.03.2020"
value_template: '{{value.date.strftime("%d.%m.%Y")}}'
date_template: '{{value.date.strftime("%d.%m.%Y")}}'
# returns "03/20/2020"
value_template: '{{value.date.strftime("%m/%d/%Y")}}'
date_template: '{{value.date.strftime("%m/%d/%Y")}}'
# returns "Fri, 03/20/2020"
value_template: '{{value.date.strftime("%a, %m/%d/%Y")}}'
date_template: '{{value.date.strftime("%a, %m/%d/%Y")}}'
Set value_template
within the sensor configuration:
value_template: 'in {{value.daysTo}} days'
Set value_template
within the sensor configuration:
# returns "Today" if value.daysTo == 0
# returns "Tomorrow" if value.daysTo == 1
# returns "in X days" if value.daysTo > 1
value_template: '{% if value.daysTo == 0 %}Today{% elif value.daysTo == 1 %}Tomorrow{% else %}in {{value.daysTo}} days{% endif %}'
Use the join
filter:
# returns "Garbage, Recycle"
value_template: '{{value.types|join(", ")}}'
# returns "Garbage+Recycle"
value_template: '{{value.types|join("+")}}'
Note: If you don't specify a value_template
, waste types will be joined using the separator
configuration variable.
Set value_template
within the sensor configuration:
value_template: '{{value.daysTo}}'
Set value_template
within the sensor configuration:
value_template: '{{value.date.strftime("%m/%d/%Y")}}'
Set value_template
within the sensor configuration:
value_template: '{{value.types|join(", ")}}'
Set types
within the sensor configuration:
sensor:
- platform: waste_collection_schedule
name: next_garbage_collection
types:
- Garbage
- platform: waste_collection_schedule
name: next_recycle_collection
types:
- Recycle
Note: If you have set an alias for a waste type, you must use the alias name.
Set alias
in the customize section of a source:
waste_collection_schedule:
sources:
- name: NAME
customize:
- type: Very long garbage name
alias: Garbage
- type: Very long recycle name
alias: Recycle
Set show
configuration variable to false in the customize section of a source:
waste_collection_schedule:
sources:
- name: NAME
customize:
- type: Inappropriate Waste Type
show: false
You can use Button Card to create a colored Lovelace cards:
# configuration.yaml
sensor:
- platform: waste_collection_schedule
name: MyButtonCardSensor
value_template: '{{value.types|join(", ")}}|{{value.daysTo}}|{{value.date.strftime("%d.%m.%Y")}}|{{value.date.strftime("%a")}}'
# button-card configuration
type: 'custom:button-card'
entity: sensor.mybuttoncardsensor
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
Yes, the Garbage Collection Card can also be used with Waste Collection Schedule:
# configuration.yaml
sensor:
- platform: waste_collection_schedule
name: garbage_days
details_format: appointment_types
value_template: "{{ value.daysTo }}"
types:
- Garbage
- platform: template
sensors:
garbage:
value_template: >
{% if states('sensor.garbage_days')|int > 2 %}
2
{% else %}
{{ states('sensor.garbage_days')|int }}
{% endif %}
attribute_templates:
next_date: "{{ state_attr('sensor.garbage_days', 'Garbage') }}"
days: "{{ states('sensor.garbage_days')|int }}"
# garbage-collection-card configuration
entity: sensor.garbage
type: 'custom:garbage-collection-card'
Prerequisites: You already have dedicated sensors per waste type and want to show the sensor with the next collection in a Lovelace card.
Add add_days_to: True
to the configuration of all sensors you want to sort. This will add the attribute daysTo
which can be used by e.g. auto-entities to sort entities by day of next collection.
- Create a new source in folder
custom_components/waste_collection_schedule/waste_collection_schedule/source
with the lower case url of your service provider (e.g.abc_com.py
forhttp://www.abc.com
). - Don't forget to add test cases (= sample data to query the service api).
- Run
test_sources.py
script to ensure that your source works. - Add documentation in folder
docs/source
and add a link to your new source onREADME.md
andinfo.md
.
- A source shall return data for all available waste types. A source shall not provide a configuration option to limit the returned waste types.
- A source shall return data for the entire available period (including past). A source shall not provide a configuration option to limit the requested period.
Filtering of data for waste types or time periods is a functionality of the framework and shall not be done by a source.
Example for abc_com.py
:
import datetime
from waste_collection_schedule import Collection
DESCRIPTION = "Example source for abc.com" # Describe your source
URL = "abc.com" # Insert url to service homepage
TEST_CASES = { # Insert arguments for test cases using test_sources.py script
"TestName": {"arg1": 100, "arg2": "street"}
}
class Source:
def __init__(self, arg1, arg2): # argX correspond to the args dict in the source configuration
self._arg1 = arg1
self._arg2 = arg2
def fetch(self):
entries = []
entries.append(
Collection(
datetime.datetime(2020, 4, 11),
"Waste Type",
)
)
return entries
See also: custom_components/waste_collection_schedule/waste_collection_schedule/source/example.py
Debugging a source within Home Assistant is not recommended because startup of HA is far too slow for fast debugging cycles.
Instead, there is a test fixture which allows to run a source from the command line. The fixture is a Python script which is located here:
custom_components/waste_collection_schedule/waste_collection_schedule/test/test_sources.py
.
The script uses the test cases defined in the source file and runs the source with the arguments of every test case.
By default (without additional arguments), the script tests every source file in the source
folder and prints the number of found entries for every test case.
Example output for abfall_io
:
Testing source abfall_io ...
found 269 entries for Waldenbuch
found 55 entries for Landshut
found 101 entries for Schoenmackers
found 139 entries for Freudenstadt
found 190 entries for Ludwigshafen am Rhein
The script supports the following options:
Option | Argument | Description |
---|---|---|
-s |
SOURCE | Source name (source file name without ending .py ) |
-l |
- | List all found dates |
-i |
- | Add icon name to output. Only effective together with -l . |
For debugging purposes of a single source, it is recommended to use the -s SOURCE
option.
Example for abc_com.py
:
test_sources.py -s abc_com -l -i
There are some videos on YouTube:
- Bunte Mülltonnenerinnerung mit Home Assistant
- Abfall Kalender in Home Assistant mit Erinnerung in Home Assistant
Please note that all these videos are not created by the developer of this component and therefore may be outdated, point in the wrong direction or contain errors. If you have questions, please create an issue here on GitHub. Do not ask your question in the YouTube comments because you may get wrong answers there.