1. Introduction
Every Friday a specific type of our garbage is picked up, which always leads to the question which waste container should be put alongside the street. The answer can easily be provided via Home Assistant by making use of the integration AfvalWijzer to create a Home Assistant dashboard card similar to the one below showing the garbage pickup dates.
2. Requirements
The following is required to create a garbage scheduled collection date card on the Home Assistant dashboard:
- Your municipality must support providing waste collection schedules via the AfvalWijzer website. Enter your zipcode and home number to test if AfvalWijzer is supported.
- The Home Assistant integration AfvalWijzer;
- The Home Assistant integration lovelace template-entity-row;
- The Home Assistant File editor add-on to edit the Home Assistant configuration files;
- Images for the different types of waste to be used on the card
Download link available later in this article. - Access to the folders of your Home Assistant (for uploading the images)
I use the Home Assistant Samba share add-on to access the Home Assistant folders on my Raspberry Pi 4 via a Windows computer.
For the remainder of this article the starting point is that the requirements are met and that the integrations and add-on have been installed.
3. Configuration
The configuration is split into providing your address for the Afvalwijzer and copying the required waste type images to your Home Assistant folders.
3.1 Configure the address for AfvalWijzer
Execute the following steps to configure the Afvalwijzer integration to fetch the correct scheduled garbage collection dates from the MijnAfvalWijzer website:
- Open the sensor.yaml file via the File editor and add the following to the sensor configuration file:
12345678910# Afvalwijzer configuration- platform: afvalwijzerprovider: mijnafvalwijzer # (required, default = mijnafvalwijzer) either choose mijnafvalwijzer, afvalstoffendienstkalender or rovapostal_code: 1234AB # (required, default = '')street_number: 5 # (required, default = '')suffix: '' # (optional, default = '')exclude_pickup_today: false # (optional, default = true) to take or not to take Today into account in the next pickup.default_label: Geen # (optional, default = Geen) label if no date foundid: '' # (optional, default = '') use if you'd like to have multiple waste pickup locations in HASSexclude_list: '' # (optional, default = '') comma separated list of wast types (case ignored). F.e. "papier, gft" - Update the postal code and street number to resemble your home.
- Save the file.
3.2 Copy waste type image files to your Home Assistant installation
The images shown in the card for each waste type are fetched from the Home Assistant www folder. In my case:
\config\www\images\afvalwijzer
The images can be downloaded from the AfvalWijzer website. or from posts in the Home Assistant community forum w.r.t. the Afvalwijzer integration. I collected the images from both sites and for your convenience they can be downloaded here for your own use.
If you would like to use waste container images see Gemeente Geertruidenberg (but you need to extract them from the image).
Copy the images you want to use to the Home Assistant folder:
/local/images/afvalwijzer
4. Dashboard card setup (lovelace)
In first instance I created the card including the days till the garbage collection would occur as shown in the introduction, but later I decided to simplify the card as shown below.
The next 2 sections provide the required steps to make both cards.
4.1 Card showing also days till garbage collection
Execute the following steps:
- Go to the Home Assistant dashboard and add a new manual card
- Open the code editor for this new card
- Copy/paste the following code
12345678910111213141516171819202122232425262728293031323334353637383940414243444546type: custom:auto-entitiescard:type: entitiestitle: Afvalfilter:exclude:- entity_id: sensor.afvalwijzer*next*- entity_id: sensor.afvalwijzer*to*include:- entity_id: sensor.afvalwijzer_*options:type: custom:template-entity-rowimage: >{% set type = config.entity.split('afvalwijzer_')[1] %}/local/images/afvalwijzer/{{type}}.pngstate: |{{as_timestamp(strptime(states(config.entity),'%d-%m-%Y'))|timestamp_custom('%-d %b')}}secondary: >{% set count =state_attr(config.entity,'days_until_collection_date')|int %} {% setday = as_timestamp(strptime(states(config.entity),'%d-%m-%Y'))|timestamp_custom('%A') %}{% set dagen ={'Monday': 'Maandag','Tuesday': 'Dinsdag','Wednesday': 'Woensdag','Thursday': 'Donderdag','Friday': 'Vrijdag','Saturday': 'Zaterdag','Sunday': 'Zondag'} %}{% set dag = dagen[day] if day in dagen else day %} {% set unit ='Dag' if count == 1 else 'dagen' %}{% if count >= 14 %} {% set phrase = dag + ' over 2 weken' %} {% elifcount >= 7 %} {% set phrase = 'Volgende week ' + dag %} {% elif count>= 3 %} {% set phrase = 'komende ' + dag %} {% elif count == 2 %} {%set phrase = dag + ', overmorgen' %} {% elif count == 1 %} {% setphrase = 'morgen, ' + dag %} {% else %} {% set phrase = 'Vandaag, ' +dag %} {% endif %} {{phrase}} {% if count != 0%} ({{count}} {{unit}}){% endif %}sort:attribute: days_until_collection_datemethod: attributenumeric: trueshow_empty: true - Save the card and check it is working.
4.2 Minimalistic card
Execute the following steps:
- Go to the Home Assistant dashboard and add a new manual card
- Open the code editor for this new card
- Copy/paste the following code
1234567891011121314151617181920212223242526272829303132333435363738394041424344type: custom:auto-entitiescard:type: entitiestitle: Afvalfilter:exclude:- entity_id: sensor.afvalwijzer*next*- entity_id: sensor.afvalwijzer*to*include:- entity_id: sensor.afvalwijzer_*options:type: custom:template-entity-rowimage: >{% set type = config.entity.split('afvalwijzer_')[1] %}/local/images/afvalwijzer/{{type}}.pngstate: >{% set count = state_attr(config.entity,'days_until_collection_date')|int %}{% set day = as_timestamp(strptime(states(config.entity),'%d-%m-%Y'))|timestamp_custom('%A') %}{% set dagen ={'Monday': 'Maa','Tuesday': 'Din','Wednesday': 'Woe','Thursday': 'Don','Friday': 'Vrij','Saturday': 'Zat','Sunday': 'Zon'} %}{% set dag = dagen[day] if day in dagen else day %}{{dag}}{{as_timestamp(strptime(states(config.entity),'%d-%m-%Y'))|timestamp_custom('%-d %b')}}secondary: >{% set count = state_attr(config.entity,'days_until_collection_date')|int %}{% set day = as_timestamp(strptime(states(config.entity),'%d-%m-%Y'))|timestamp_custom('%A') %}{% set dag = dagen[day] if day in dagen else day %}{% set unit = 'dag' if count == 1 else 'dagen' %}Over {{count}} {{unit}}sort:attribute: days_until_collection_datemethod: attributenumeric: trueshow_empty: false - Save the card and check it is working.
5. Additional info
5.1 Image folder and names
If you want to use another path for the images the following line needs to be updated accordingly in the YAML code of the card:
1 |
/local/images/afvalwijzer/{{type}}.png |
The image names should be the same as the waste type name used by the Afvalwijzer integration (indicated by type). For using fixed names see the examples in the Home Assistant community forum.
6. Sources for ideas
I started with the lovelace card code used by Martijn Hoogenbosch as it seem to be less complex then the others available on the Home Assistant community forum. Other sources for ideas:
- The manual for the Afvalwijzer integration;
- Home Assistant community forum card designed by Marius;
- Example configuration from the developer
- Notification example code
- Card modifications via posts here and here.
If you are living in another country than The Netherlands the following sources might help you:
- Home assistant bin collection schedule – United Kingdom (South Tyneside Council)
Uses REST sensor / JSON to grab info from a site - Waste Collection Schedule custom component – Multiple countries
- Fetching info from calendar of collection dates – Australia (Sydney, Inner West Council)
Makes use of the Waste Collection Schedule component. - Garbage collection custom component – General
Works via configured waste frequencies
0 Comments