Garbage pickup date (mijnafvalwijzer.nl) custom_component

Great, but honestly also kind of confusing. One of the breaking changes is the removal of the sensor-platform. In my YAML (which I mostly copied from @xirixiz), there are quite a couple of sensor-declarations. Or is this something else entirely?

This is about a specific sensor that HACS used to provide, not your YAML sensors from other platforms.

1 Like

Ah, I see. Thanks!

Not getting good data from api.
I don’t think this is for all areas, but certainly in my area.
This also works on the mobile app, but not on the web version: browsing the actual web-site using Chrome also gives no data.

Example of API response:
,
“max_tips”: 10,
“period_timer”: 15,
“location”: {
“response”: “NOK”,
“data”: false,
“error”: “NOT ALLOWED”
},
“notifications”: {
“response”: “OK”,
“data”: true,
“error”: “”
},
“notificationsTimer”: {
“response”: “OK”,
“data”: [
“15:00”,
“09:00”
],
“error”: “”
},
“reportGarbage”: {
“response”: “NOK”,
“data”: false,
“error”: “NOT ALLOWED”
},
“reportGarbageList”: {
“response”: “NOK”,
“data”: ,
“error”: “Error. No exist a list of waste type for this customer”
},
“afvalshop”: {
“response”: “NOK”,
“data”: false,
“error”: “NOT ALLOWED”
},
“excludedList”: “”,
“excludedListPickups”: ,
“gripLocations”: ,
“gripTimes”: ,
“gripRoutes”:
},
“ophaaldagen”: {
“response”: “NOK”,
“data”: ,
“error”: “No dataa”
},
“ophaaldagenNext”: {
“response”: “NOK”,
“data”: ,
“error”: “No data”
},
“afroepData”: {
“response”: “NOK”,
“data”: {
“afroepEmail”: “”,
“afroepContainers”: ,
“afroep”:
},
“error”: “”
},
“mededelingen”: {
“response”: “NOK”,
“data”: ,
“error”: “Error. No mededelingen found in db”
},

Suspect there is something wrong on the host side - if someone perhaps knows some who has contact details to reach the developers - please help!

Thanks a lot for this custom_component. However, upon starting Home Assistant, I always get this error:

Template error: as_timestamp got invalid input ‘geen’ when rendering template ‘{{ as_timestamp(states(‘sensor.afvalwijzer_pmd’)) | timestamp_custom(’%A’) }}’ but no default was specified

Any suggestion on how to fix this?

yes, read the error and do as it suggests. add a default value

I understand, but I did not define the template. It is part of the custom_component and I don’t know where to look. Hence the question here.

how is the template part of a custom component? which is that, and where is the template defined?

btw try this format

{{states('sensor.afvalwijzer_gft')|as_timestamp | timestamp_custom('%A') }}

It is the custom component this thread belongs to in which a number of sensors are created and for some of them a template appears to be used without specified default.

yes but the templates are not made by the component. ha just provides data, and several sensors

the templates are made by the user, to the needs of the user.

which and where. please be specific so we can see your problem and help out

btw since these sensors are timestamps already you can do

{{(states('sensor.afvalwijzer_gft')|as_datetime).strftime('%A')}}

and

{{(states('sensor.afvalwijzer_gft')|as_datetime).day}}

or

{{states('sensor.afvalwijzer_gft')|as_timestamp | timestamp_custom('%A') }}
{{(states('sensor.afvalwijzer_gft')|as_datetime).strftime('%A')}}
{{(states('sensor.afvalwijzer_gft')|as_datetime).day}}
{{(states('sensor.afvalwijzer_gft')|as_datetime).second}}
{{(states('sensor.afvalwijzer_gft')|as_datetime).minute}}
{{(states('sensor.afvalwijzer_gft')|as_datetime).hour}}
{{(states('sensor.afvalwijzer_gft')|as_datetime).month}}
{{(states('sensor.afvalwijzer_gft')|as_datetime).weekday()}}
{{(states('sensor.afvalwijzer_gft')|as_datetime).isoweekday()}}
{{time_until(states('sensor.afvalwijzer_plastic')|as_datetime)}}

:wink:

Thanks a lot for your help @Mariusthvdb.

I understand the question and the location where these are defined is exactly what I have been looking for myself.

I checked my complete config and I am sure that I have not defined these templates myself and that they somehow are a native part of the custom component.

I’ve been trying to go through the code myself and it appears to be related to the default_label: that is used by the custom component to replace the sensor value in case of no trash pick-up required.

Hence my question here. I was hoping that the author of the custom component or someone else that use the custom component could point me in the right direction.

that is what I am trying to do…

the component does Not create templates.

you either have those in your backend, in yaml or via the UI templates helpers, or, in the Frontend using custom cards (well, or the core Markdown card)

there simply is no other option.

No they are not.

maybe copied them?

Thanks a lot @Mariusthvdb.

You were correct, my mistake and thanks for pointing me in the right direction. The errors originated from template helpers.

1 Like

Hey all, soon I will release a new version with some code improvements. Also I’ve added a config_flow to make things easier for you all. I expect to release it somewhere next week, I’m testing it myself currently. I’ll keep you informed.

2 Likes

it’s done, needed to delete the old sensors, a bit of renaming, but here we are :wink: Nice indeed, thanks for the work you did.
note the ‘next’ entities are Not translated?

but, to my shock, I learned that my provider Saver will no longer be using Afvalwijzer… (notice the TBA…)

Would be truly sorry to have to leave this integration after so many years, and be forced to go to the competition (copy)

And not only because it doesnt have the day after tomorrow sensor… the entities can not be edited, the time sensors are not timestamps, and a very silly image attribute. o dear coming from Afvalwijzer, the Afvalbeheer integration really is a let down that needs to do some catching up…

Bram, please have a look if you can keep the integration up for Saver too in 2025?

1 Like

Ofcourse I’ll try to keep the integration up for Saver for the biggest user/supporter/contributor for this component :+1:. I’ll do some research.

1 Like

let me know if I can help :wink:

So I’ve got this addon working for a while now, setting up was quite straightforward. Now I’ve noticed this in the templates: there are occasions when there are 2 types of garbage pickup on the same day. It’s always the regular one according to schedule and an occasional one like grof tuinafval or klein chemisch afval. In that case the formatted sensors don’t get any of them, due to their “if” conditions. I can / will change that, so at least one of them is displayed, but to catch every combination I fear the only thing I can do is to create more elifs. Then combined icons are the next step to display them…

original template (doesn’t work on multiple garbage types):

  - platform: template
    sensors:
      afvalwijzer_next_type_formatted:
        value_template: >-
          {% if is_state('sensor.afvalwijzer_next_type', 'gft groente-, fruit- en tuinafval') %}GFT
          {% elif is_state('sensor.afvalwijzer_next_type', 'muziekvereniging euphonia') %}Papier
          {% elif is_state('sensor.afvalwijzer_next_type', 'plastic, blik en drankenkartons') %}PMD
          {% elif is_state('sensor.afvalwijzer_next_type', 'restafval') %}Rest
          {% elif is_state('sensor.afvalwijzer_next_type', 'klein chemisch afval (kca)') %}KCA
          {% else %}Geen
          {% endif %}
        friendly_name: "Volgende type afval"

planned change (to catch at least one, preferrably the uncommon garbage type)

	{% if 'chemisch' in states('sensor.afvalwijzer_next_type') %}KCA
	{% elif 'plastic' in states('sensor.afvalwijzer_next_type') %}PMD

to catch both:

	{% if 'chemisch' in states('sensor.afvalwijzer_next_type') and 'plastic' in states('sensor.afvalwijzer_next_type') %}KCA_PMD

suppose you could write up a more automatic template, than that verbose if elif etc depending on the positioning of the separator in that string.

can you post exactly what that next_type string does in dev tools
(We never have dual trash types, so can not test here)

Also, combined icons wont exist in HA, but maybe you mean entity_picture and some of the dual type version of those?
they have been posted above, you need to look them up

this might be something by Frank Garbage pickup date (mijnafvalwijzer.nl) custom_component - #409 by fversteegen and Garbage pickup date (mijnafvalwijzer.nl) custom_component - #417 by fversteegen and Garbage pickup date (mijnafvalwijzer.nl) custom_component - #421 by fversteegen

:slight_smile:

Thanks for pointing me to the icons, I already have the original ones, creating combined icons is not a problem.

Regarding the separator: as you can see there’s a comma in the first string “plastic, blik en drankenkartons” and a second comma to seperate the first and second string. For now I’ll keep the multiple if / elifs and combined icons, as the municipality I live in changes the garbage collecting company starting from january. Might need to adapt the templates (string values) then, perhaps they use other formatting or descriptions.