This is a long requested feature and I`m working on it
I get the error below after a restart:
HTTP error occurred: 404 Client Error: Not Found for url: https://www.mijnafvalwijzer.nl/error
what could be the problem?
after installing the afvalwijzer in HACS, he created the folders himself in custom_components -> waste guide
after the restart of HA i added the following config:
sensor:
- platform: afvalwijzer
provider: mijnafvalwijzer
postal_code: 0000XX
street_number: X
suffix: A.
include_date_today: false
default_label: None
after this another reboot
ok, so today I noticed my afval_today (ā¦) sensor not getting the correct icon, which I had set with the customization as posted earlier above.
sensor.afvalwijzer_today:
friendly_name: Afval vandaag
templates: &trash_picture
entity_picture: >
if (state in ['papier','gft','plastic','restafval'])
return '/local/afvalwijzer/' + state + '.png';
return '/local/afvalwijzer/kliko_geen.png';
had to change it to:
sensor.afvalwijzer_today:
friendly_name: Afval vandaag
templates: &trash_picture
entity_picture: >
var items = ['papier','gft','plastic','restafval'];
if (items.includes(state))
return '/local/afvalwijzer/' + state + '.png';
return '/local/afvalwijzer/kliko_geen.png';
to have it appear correctly again.
A bit strange as it this type of template seems to work in all other places in my config. Still, maybe it was too much jinja package in a JS dip
@TheCosmicGate maybe this helps you too with your customizations.
update
same goes for:
sensor.afvalwijzer_first_next_in_days:
friendly_name: Days to next pickup
templates:
icon: >
if (state == 'Geen') return 'mdi:calendar-question';
var items = ['1','2','3','4','5','6','7','8','9'];
if (items.includes(state))
return 'mdi:numeric-' + state + '-box-multiple-outline';
return 'mdi:numeric-9-plus-box-multiple-outline';
Please PB me with your postal code and housenumber
Thnx for your help. you got a message
Remove the suffix as there is no suffix/toeviging at you street number.
that was the solution! stupid mistake of mine! thank you very much for your help!
just for informative purposes: why would you want that? Doesnt the integration only create sensors for trash types applicable in your community? In other words, only create necessary sensors? Or do you even want to be able to skip some of these maybe.
To be honest, I just noticed that you are right. I think that as of 5.0.x only applicable trash types are created!
This was not the case prior to 5.0.x, it created all trash types, such as āplasticā, āluiersā and ākerstbomenā for example. This annoyed me a bit as it creates all these entities which you will never use.
I guess I didnāt double check after the upgrade for some reasonā¦ Mea culpa
haha cool. was just being curious. never saw the ākerstbomenā or āluiersā appear here though. thatās why I asked.
Prior to version 5.x this was the exact same functionality actually (only not in the inbetween temporary 4.x scraper release). Only add items which have been added to the list by your township and provided bij mijnafvalwijzer will create a sensor for each item.
For me thatās only gft, papier, pmd, restafval and kerstbomen for example, so I donāt get luiers and stuff.
I was on the temporary 4x version. For about 2 hours- I just implemented it and went back to this thread for Mariusā great templates- and I saw the 5.0.0 release.
Which I implemented (changing everything again haha) and when I was done you had released 5.0.1
Hello xirixiz,
is it possible to use this component with belgian waste collector?
I do have this sensor sensor.afvalwijzer_dhm but what it dhm?
I do have sensor.afvalwijzer_restgft so i guess it is the plastic/paper container.
I used to be something else
the result of my integration give me entuty not availableā¦
my config:
āā
sensor:
- platform: afvalwijzer
provider: mijnafvalwijzer
postal_code: 1650
street_number: 55
include_date_today: false
default_label: Geen
āāā
But Iām in belgium , Iām not sure for the format of the postal code neither for the providerā¦
Anyone for helping me?
Gify: Droge Herbruikbare Materialen
Hi ,
I believe this is for Dutch residents only unfortunately. What happens if you type in your postal code and house number here: https://www.mijnafvalwijzer.nl/ ?
Maybe you have a similar service in Belgium?
When I try, it give me an errorā¦
Hi there!
I added my own functionality to this component. With this, itās possible to see the following:
Instead of images for only; today, tomorrow, day after tomorrow. So, with this change, iāll never see a ānoneā anymore.
On bug, sometimes the name sensor returns āunknownā After some time or restart it is fixed. Probably because the sensors are created before the afvalwijzer has grabbed the info? Donāt knowā¦
Hereās the āsensorā code:
- platform: template
sensors:
first_trash_date:
value_template: >-
{% set selected_item = 0 %}
{% set gftInDays = state_attr('sensor.afvalwijzer_gft', 'days_until_collection_date') | default(99) %}
{% set papierInDays = state_attr('sensor.afvalwijzer_papier', 'days_until_collection_date') | default(99) %}
{% set pmdInDays = state_attr('sensor.afvalwijzer_pmd', 'days_until_collection_date') | default(99) %}
{% set restAfvalInDays = state_attr('sensor.afvalwijzer_restafval', 'days_until_collection_date') | default(99) %}
{% set daysDutch = ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'] %}
{% set todayDateTime = as_timestamp(now())|int %}
{% set nextInDays = [gftInDays, papierInDays, pmdInDays, restAfvalInDays] %}
{% set sortedNextInDays = nextInDays|sort %}
{% if sortedNextInDays[ selected_item ] == gftInDays %}
{% if (gftInDays <= 2) %}
{{ 'Vandaag' if (gftInDays == 0) else ('Morgen' if (gftInDays == 1) else 'Overmorgen') }}
{% else %}
{% set dayNumber = ((todayDateTime + (gftInDays * 86400))|timestamp_custom('%w'))|int %}
{% if (gftInDays <= 7) %}
{{ daysDutch[dayNumber] }}
{% elif (gftInDays > 14) %}
{{ daysDutch[dayNumber] }} over twee week
{% else %}
Volgende week {{ daysDutch[dayNumber]|lower }}
{% endif %}
{% endif %}
{% endif %}
{% if sortedNextInDays[ selected_item ] == papierInDays %}
{% if (papierInDays <= 2) %}
{{ 'Vandaag' if (papierInDays == 0) else ('Morgen' if (papierInDays == 1) else 'Overmorgen') }}
{% else %}
{% set dayNumber = ((todayDateTime + (papierInDays * 86400))|timestamp_custom('%w'))|int %}
{% if (papierInDays <= 7) %}
{{ daysDutch[dayNumber] }}
{% elif (papierInDays > 14) %}
{{ daysDutch[dayNumber] }} over twee week
{% else %}
Volgende week {{ daysDutch[dayNumber]|lower }}
{% endif %}
{% endif %}
{% endif %}
{% if sortedNextInDays[ selected_item ] == pmdInDays %}
{% if (pmdInDays <= 2) %}
{{ 'Vandaag' if (pmdInDays == 0) else ('Morgen' if (pmdInDays == 1) else 'Overmorgen') }}
{% else %}
{% set dayNumber = ((todayDateTime + (pmdInDays * 86400))|timestamp_custom('%w'))|int %}
{% if (pmdInDays <= 7) %}
{{ daysDutch[dayNumber] }}
{% elif (pmdInDays > 14) %}
{{ daysDutch[dayNumber] }} over twee week
{% else %}
Volgende week {{ daysDutch[dayNumber]|lower }}
{% endif %}
{% endif %}
{% endif %}
{% if sortedNextInDays[ selected_item ] == restAfvalInDays %}
{% if (restAfvalInDays <= 2) %}
{{ 'Vandaag' if (restAfvalInDays == 0) else ('Morgen' if (restAfvalInDays == 1) else 'Overmorgen') }}
{% else %}
{% set dayNumber = ((todayDateTime + (restAfvalInDays * 86400))|timestamp_custom('%w'))|int %}
{% if (restAfvalInDays <= 7) %}
{{ daysDutch[dayNumber] }}
{% elif (restAfvalInDays > 14) %}
{{ daysDutch[dayNumber] }} over twee week
{% else %}
Volgende week {{ daysDutch[dayNumber]|lower }}
{% endif %}
{% endif %}
{% endif %}
first_trash_name:
value_template: >-
{% set selected_item = 0 %}
{% set trash_gft_date_ts = as_timestamp(strptime(states.sensor.afvalwijzer_gft.state, "%d-%m-%Y"))|int %}
{% set trash_papier_date_ts = as_timestamp(strptime(states.sensor.afvalwijzer_papier.state, "%d-%m-%Y"))|int %}
{% set trash_pmd_date_ts = as_timestamp(strptime(states.sensor.afvalwijzer_pmd.state, "%d-%m-%Y"))|int %}
{% set trash_restafval_date_ts = as_timestamp(strptime(states.sensor.afvalwijzer_restafval.state, "%d-%m-%Y"))|int %}
{% set trash_ts_array = [trash_gft_date_ts, trash_pmd_date_ts, trash_papier_date_ts, trash_restafval_date_ts] %}
{% set sorted_trash_ts_array = trash_ts_array|sort %}
{% set selected_timestamp = sorted_trash_ts_array[ selected_item ] %}
{% if (selected_timestamp == trash_papier_date_ts) %}
papier
{% elif (selected_timestamp == trash_pmd_date_ts) %}
pmd
{% elif (selected_timestamp == trash_gft_date_ts) %}
gft
{% elif (selected_timestamp == trash_restafval_date_ts) %}
restafval
{% else %}
geen
{% endif %}
second_trash_date:
value_template: >-
{% set selected_item = 1 %}
{% set gftInDays = state_attr('sensor.afvalwijzer_gft', 'days_until_collection_date') | default(99) %}
{% set papierInDays = state_attr('sensor.afvalwijzer_papier', 'days_until_collection_date') | default(99) %}
{% set pmdInDays = state_attr('sensor.afvalwijzer_pmd', 'days_until_collection_date') | default(99) %}
{% set restAfvalInDays = state_attr('sensor.afvalwijzer_restafval', 'days_until_collection_date') | default(99) %}
{% set daysDutch = ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'] %}
{% set todayDateTime = as_timestamp(now())|int %}
{% set nextInDays = [gftInDays, papierInDays, pmdInDays, restAfvalInDays] %}
{% set sortedNextInDays = nextInDays|sort %}
{% if sortedNextInDays[ selected_item ] == gftInDays %}
{% if (gftInDays <= 2) %}
{{ 'Vandaag' if (gftInDays == 0) else ('Morgen' if (gftInDays == 1) else 'Overmorgen') }}
{% else %}
{% set dayNumber = ((todayDateTime + (gftInDays * 86400))|timestamp_custom('%w'))|int %}
{% if (gftInDays <= 7) %}
{{ daysDutch[dayNumber] }}
{% elif (gftInDays > 14) %}
{{ daysDutch[dayNumber] }} over twee week
{% else %}
Volgende week {{ daysDutch[dayNumber]|lower }}
{% endif %}
{% endif %}
{% endif %}
{% if sortedNextInDays[ selected_item ] == papierInDays %}
{% if (papierInDays <= 2) %}
{{ 'Vandaag' if (papierInDays == 0) else ('Morgen' if (papierInDays == 1) else 'Overmorgen') }}
{% else %}
{% set dayNumber = ((todayDateTime + (papierInDays * 86400))|timestamp_custom('%w'))|int %}
{% if (papierInDays <= 7) %}
{{ daysDutch[dayNumber] }}
{% elif (papierInDays > 14) %}
{{ daysDutch[dayNumber] }} over twee week
{% else %}
Volgende week {{ daysDutch[dayNumber]|lower }}
{% endif %}
{% endif %}
{% endif %}
{% if sortedNextInDays[ selected_item ] == pmdInDays %}
{% if (pmdInDays <= 2) %}
{{ 'Vandaag' if (pmdInDays == 0) else ('Morgen' if (pmdInDays == 1) else 'Overmorgen') }}
{% else %}
{% set dayNumber = ((todayDateTime + (pmdInDays * 86400))|timestamp_custom('%w'))|int %}
{% if (pmdInDays <= 7) %}
{{ daysDutch[dayNumber] }}
{% elif (pmdInDays > 14) %}
{{ daysDutch[dayNumber] }} over twee week
{% else %}
Volgende week {{ daysDutch[dayNumber]|lower }}
{% endif %}
{% endif %}
{% endif %}
{% if sortedNextInDays[ selected_item ] == restAfvalInDays %}
{% if (restAfvalInDays <= 2) %}
{{ 'Vandaag' if (restAfvalInDays == 0) else ('Morgen' if (restAfvalInDays == 1) else 'Overmorgen') }}
{% else %}
{% set dayNumber = ((todayDateTime + (restAfvalInDays * 86400))|timestamp_custom('%w'))|int %}
{% if (restAfvalInDays <= 7) %}
{{ daysDutch[dayNumber] }}
{% elif (restAfvalInDays > 14) %}
{{ daysDutch[dayNumber] }} over twee week
{% else %}
Volgende week {{ daysDutch[dayNumber]|lower }}
{% endif %}
{% endif %}
{% endif %}
second_trash_name:
value_template: >-
{% set selected_item = 1 %}
{% set trash_gft_date_ts = as_timestamp(strptime(states.sensor.afvalwijzer_gft.state, "%d-%m-%Y"))|int %}
{% set trash_papier_date_ts = as_timestamp(strptime(states.sensor.afvalwijzer_papier.state, "%d-%m-%Y"))|int %}
{% set trash_pmd_date_ts = as_timestamp(strptime(states.sensor.afvalwijzer_pmd.state, "%d-%m-%Y"))|int %}
{% set trash_restafval_date_ts = as_timestamp(strptime(states.sensor.afvalwijzer_restafval.state, "%d-%m-%Y"))|int %}
{% set trash_ts_array = [trash_gft_date_ts, trash_pmd_date_ts, trash_papier_date_ts, trash_restafval_date_ts] %}
{% set sorted_trash_ts_array = trash_ts_array|sort %}
{% set selected_timestamp = sorted_trash_ts_array[ selected_item ] %}
{% if (selected_timestamp == trash_papier_date_ts) %}
papier
{% elif (selected_timestamp == trash_pmd_date_ts) %}
pmd
{% elif (selected_timestamp == trash_gft_date_ts) %}
gft
{% elif (selected_timestamp == trash_restafval_date_ts) %}
restafval
{% else %}
geen
{% endif %}
third_trash_date:
value_template: >-
{% set selected_item = 2 %}
{% set gftInDays = state_attr('sensor.afvalwijzer_gft', 'days_until_collection_date') | default(99) %}
{% set papierInDays = state_attr('sensor.afvalwijzer_papier', 'days_until_collection_date') | default(99) %}
{% set pmdInDays = state_attr('sensor.afvalwijzer_pmd', 'days_until_collection_date') | default(99) %}
{% set restAfvalInDays = state_attr('sensor.afvalwijzer_restafval', 'days_until_collection_date') | default(99) %}
{% set daysDutch = ['Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'] %}
{% set todayDateTime = as_timestamp(now())|int %}
{% set nextInDays = [gftInDays, papierInDays, pmdInDays, restAfvalInDays] %}
{% set sortedNextInDays = nextInDays|sort %}
{% if sortedNextInDays[ selected_item ] == gftInDays %}
{% if (gftInDays <= 2) %}
{{ 'Vandaag' if (gftInDays == 0) else ('Morgen' if (gftInDays == 1) else 'Overmorgen') }}
{% else %}
{% set dayNumber = ((todayDateTime + (gftInDays * 86400))|timestamp_custom('%w'))|int %}
{% if (gftInDays <= 7) %}
{{ daysDutch[dayNumber] }}
{% elif (gftInDays > 14) %}
{{ daysDutch[dayNumber] }} over twee week
{% else %}
Volgende week {{ daysDutch[dayNumber]|lower }}
{% endif %}
{% endif %}
{% endif %}
{% if sortedNextInDays[ selected_item ] == papierInDays %}
{% if (papierInDays <= 2) %}
{{ 'Vandaag' if (papierInDays == 0) else ('Morgen' if (papierInDays == 1) else 'Overmorgen') }}
{% else %}
{% set dayNumber = ((todayDateTime + (papierInDays * 86400))|timestamp_custom('%w'))|int %}
{% if (papierInDays <= 7) %}
{{ daysDutch[dayNumber] }}
{% elif (papierInDays > 14) %}
{{ daysDutch[dayNumber] }} over twee week
{% else %}
Volgende week {{ daysDutch[dayNumber]|lower }}
{% endif %}
{% endif %}
{% endif %}
{% if sortedNextInDays[ selected_item ] == pmdInDays %}
{% if (pmdInDays <= 2) %}
{{ 'Vandaag' if (pmdInDays == 0) else ('Morgen' if (pmdInDays == 1) else 'Overmorgen') }}
{% else %}
{% set dayNumber = ((todayDateTime + (pmdInDays * 86400))|timestamp_custom('%w'))|int %}
{% if (pmdInDays <= 7) %}
{{ daysDutch[dayNumber] }}
{% elif (pmdInDays > 14) %}
{{ daysDutch[dayNumber] }} over twee week
{% else %}
Volgende week {{ daysDutch[dayNumber]|lower }}
{% endif %}
{% endif %}
{% endif %}
{% if sortedNextInDays[ selected_item ] == restAfvalInDays %}
{% if (restAfvalInDays <= 2) %}
{{ 'Vandaag' if (restAfvalInDays == 0) else ('Morgen' if (restAfvalInDays == 1) else 'Overmorgen') }}
{% else %}
{% set dayNumber = ((todayDateTime + (restAfvalInDays * 86400))|timestamp_custom('%w'))|int %}
{% if (restAfvalInDays <= 7) %}
{{ daysDutch[dayNumber] }}
{% elif (restAfvalInDays > 14) %}
{{ daysDutch[dayNumber] }} over twee week
{% else %}
Volgende week {{ daysDutch[dayNumber]|lower }}
{% endif %}
{% endif %}
{% endif %}
third_trash_name:
value_template: >-
{% set selected_item = 2 %}
{% set trash_gft_date_ts = as_timestamp(strptime(states.sensor.afvalwijzer_gft.state, "%d-%m-%Y"))|int %}
{% set trash_papier_date_ts = as_timestamp(strptime(states.sensor.afvalwijzer_papier.state, "%d-%m-%Y"))|int %}
{% set trash_pmd_date_ts = as_timestamp(strptime(states.sensor.afvalwijzer_pmd.state, "%d-%m-%Y"))|int %}
{% set trash_restafval_date_ts = as_timestamp(strptime(states.sensor.afvalwijzer_restafval.state, "%d-%m-%Y"))|int %}
{% set trash_ts_array = [trash_gft_date_ts, trash_pmd_date_ts, trash_papier_date_ts, trash_restafval_date_ts] %}
{% set sorted_trash_ts_array = trash_ts_array|sort %}
{% set selected_timestamp = sorted_trash_ts_array[ selected_item ] %}
{% if (selected_timestamp == trash_papier_date_ts) %}
papier
{% elif (selected_timestamp == trash_pmd_date_ts) %}
pmd
{% elif (selected_timestamp == trash_gft_date_ts) %}
gft
{% elif (selected_timestamp == trash_restafval_date_ts) %}
restafval
{% else %}
geen
{% endif %}
And the lovelace yaml:
- cards:
- entity: sensor.first_trash_name
show_name: false
show_state: false
state_image:
Geen: /local/mijnafvalwijzer/kliko_geen.png
gft: /local/mijnafvalwijzer/gft3.png
papier: /local/mijnafvalwijzer/papier3.png
pmd: /local/mijnafvalwijzer/plastic3.png
restafval: /local/mijnafvalwijzer/restafval3.png
type: picture-entity
- entity: sensor.second_trash_name
show_name: false
show_state: false
state_image:
Geen: /local/mijnafvalwijzer/kliko_geen.png
gft: /local/mijnafvalwijzer/gft3.png
papier: /local/mijnafvalwijzer/papier3.png
pmd: /local/mijnafvalwijzer/plastic3.png
restafval: /local/mijnafvalwijzer/restafval3.png
type: picture-entity
- entity: sensor.third_trash_name
show_name: false
show_state: false
state_image:
Geen: /local/mijnafvalwijzer/kliko_geen.png
gft: /local/mijnafvalwijzer/gft3.png
papier: /local/mijnafvalwijzer/papier3.png
pmd: /local/mijnafvalwijzer/plastic3.png
restafval: /local/mijnafvalwijzer/restafval3.png
type: picture-entity
type: horizontal-stack
- cards:
- content: >
<center>{{
states('sensor.first_trash_date')}}</center>
type: markdown
- content: >
<center>{{
states('sensor.second_trash_date')}}</center>
style:
text-align: center
type: markdown
- content: >
<center>{{
states('sensor.third_trash_date')}}</center>
style:
text-align: center
type: markdown
type: horizontal-stack```
as said in the repo: no need to overcomplicate your template sensors: https://github.com/xirixiz/homeassistant-afvalwijzer/issues/99#issuecomment-709289206
have the auto-entities and template-entity-row cards do the work for you
- type: custom:auto-entities
card:
type: entities
title: Volgende ophaaldata
filter:
include:
- entity_id: sensor.afvalwijzer_*_next
options:
type: custom:template-entity-row
state: >
{{state_attr(config.entity,'date')}}
secondary: >
{% set count = states(config.entity)|int %}
{% set day = state_attr(config.entity,'day') %}
{% set unit = 'Dag' if count == 1 else 'Dagen' %}
{% if count >= 14 %} {% set phrase = day + ' over 2 weken' %}
{% elif count >= 7 %} {% set phrase = 'Volgende week ' + day %}
{% elif count >= 3 %} {% set phrase = 'komende ' + day %}
{% elif count == 2 %} {% set phrase = day + ', overmorgen' %}
{% elif count == 1 %} {% set phrase = 'morgen, ' + day %}
{% else %} {% set phrase = 'Vandaag, ' + day %}
{% endif %}
{{phrase}} {% if count != 0 %} ({{count}} {{unit}}) {% endif %}
sort:
method: state
numeric: true