Garbage pickup date (mijnafvalwijzer.nl) custom_component

Any news on the error above? I have the same problem

Can you tell me what you did so the sensors where found?
I’m trying to install but get the same error as you before.

Same here, I have been trying to install it as well and keep getting the same error too. I will wait for an update on the integration.

since the template was posted here, this is for now a placeholder in migration to 2021.10 + given the templating changes that were made on the default values one templates. This:

{%- set tracker_timestamp = as_timestamp(strptime(states('sensor.afvalwijzer_next_date'),'%d-%m-%Y')) %}
          {%  set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'] %}
          {%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'] %}
          {%- set wday = tracker_timestamp|timestamp_custom('%w')|int %}
          {%- set month = tracker_timestamp |timestamp_custom('%m')|int %}
          {{tracker_timestamp|timestamp_custom(wdays[wday]  ~ ' ' '%-d' ' ' ~ months[month-1])}}

results in 3 errors (repeating)

2021-10-12 00:53:36 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'strptime' got invalid input 'Geen' when rendering template '{%- set tracker_timestamp = as_timestamp(strptime(states('sensor.afvalwijzer_next_date'),'%d-%m-%Y')) %} {%  set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'] %} {%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'] %} {%- set wday = tracker_timestamp|timestamp_custom('%w')|int %} {%- set month = tracker_timestamp |timestamp_custom('%m')|int %} {{tracker_timestamp|timestamp_custom(wdays[wday]  ~ ' ' '%-d' ' ' ~ months[month-1])}}' but no default was specified. Currently 'strptime' will return 'Geen', however this template will fail to render in Home Assistant core 2021.12
2021-10-12 00:53:36 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'as_timestamp' got invalid input 'Geen' when rendering template '{%- set tracker_timestamp = as_timestamp(strptime(states('sensor.afvalwijzer_next_date'),'%d-%m-%Y')) %} {%  set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'] %} {%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'] %} {%- set wday = tracker_timestamp|timestamp_custom('%w')|int %} {%- set month = tracker_timestamp |timestamp_custom('%m')|int %} {{tracker_timestamp|timestamp_custom(wdays[wday]  ~ ' ' '%-d' ' ' ~ months[month-1])}}' but no default was specified. Currently 'as_timestamp' will return 'None', however this template will fail to render in Home Assistant core 2021.12
2021-10-12 00:53:36 WARNING (MainThread) [homeassistant.helpers.template] Template warning: 'timestamp_custom' got invalid input 'None' when rendering template '{%- set tracker_timestamp = as_timestamp(strptime(states('sensor.afvalwijzer_next_date'),'%d-%m-%Y')) %} {%  set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'] %} {%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'] %} {%- set wday = tracker_timestamp|timestamp_custom('%w')|int %} {%- set month = tracker_timestamp |timestamp_custom('%m')|int %} {{tracker_timestamp|timestamp_custom(wdays[wday]  ~ ' ' '%-d' ' ' ~ months[month-1])}}' but no default was specified. Currently 'timestamp_custom' will return 'None', however this template will fail to render in Home Assistant core 2021.12

i have posted it also in a dedicated thread on the templating changes for some help, but thought a repost here might be a good idea.

Not sure if simply defaulting any of these should be the solution, maybe we need the entities which are used in this template, specifically the sensor.afvalwijzer_next_date to have another state than Geen…

to be continued

this should be it:

      - unique_id: volgende_afval_ophaal_dag
        name: Volgende afval-ophaal dag
        state: >
          {%- set tracker_timestamp = as_timestamp(strptime(states('sensor.afvalwijzer_next_date'),'%d-%m-%Y',none),none) %}
          {%  set months = ['Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'] %}
          {%- set wdays = ['Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'] %}
          {%- set wday = tracker_timestamp|timestamp_custom('%w',default=none)|int %}
          {%- set month = tracker_timestamp |timestamp_custom('%m',default=none)|int %}
          {{tracker_timestamp|timestamp_custom(wdays[wday]  ~ ' ' '%-d' ' ' ~ months[month-1],default=none)}}

Marius, I am using your card.
It’s looking great! :grinning:
Recently the HA templates have been changed and a default has to be added.
You mentioned in an example a “default=none”.

Where do I need to add the default’s in your card?

Other question:
The card shows the month in short format and in English i.e. Oct.
I would like to see the month in full format and in Dutch, so: oktober in stead of Oct.
This will look much better on the card because the text is in Dutch.
I know it’s a small detail.

It shows:
Restafval komende Dinsdag (3 dagen) 19 Oct
Preferred is:
Restafval komende dinsdag (3 dagen) 19 oktober

you can use this for the month in Dutch

      - unique_id: maand
        name: Maand
        state: >
          {% set maanden = ['Januari','Februari','Maart','April','Mei','Juni','Juli',
                            'Augustus','September','Oktober','November','December'] %}
          {% set maand = maanden[now().month -1] %}
          {{maand}}

as for the defaults, see 1 post above yours…
as far as my template entity row card goes, I haven’t received a warning yet in the logs… so will leave it as it is for now.
Petro has summed all necessary changes in a dedicated post, you should check that

2 Likes

can someone please explain what i have to do, to get the sensors shown?
thanks.

what i did is the following:
install the integration in HACS

You can follow the README at this repo: GitHub - xirixiz/homeassistant-afvalwijzer: Provides sensors for the Dutch waste collector mijnafvalwijzer.nl and/or afvalstoffendienstkalender.nl
You need to add some config manually in order to make it work.

Hi, is there anyone able to help me out creating a config flow for GitHub - xirixiz/homeassistant-afvalwijzer: Provides sensors for the Dutch waste collector mijnafvalwijzer.nl and/or afvalstoffendienstkalender.nl. I’ve tried but I wasn’t able to make it work properly. I hope someone can help here as I don’t have enough time to create the config flow on my own currently.

i tried before many times, give it a change again and it works.
thnx.

1 Like

since yesterday the sensor is not loaded anymore and the logs show this

Error while setting up afvalwijzer platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/afvalwijzer/sensor.py", line 67, in async_setup_platform
    afvalwijzer = await hass.async_add_executor_job(
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/afvalwijzer/provider/afvalwijzer.py", line 69, in __init__
    (
TypeError: cannot unpack non-iterable NoneType object

How must I config the pictures if I have two pickups in one day?

1 Like

Could the installation of this be easier? Can it be added in the Integration module of HA?

1 Like

Hi Marius,

I’m trying to get your layout in our theme. With code beneath, I have two problems : my lovelace ui stops working because of the config.entity (not recognized resulting in unknown error) and second of all, the calculation of my attributes to get to day month year in dutch. I need to use state_attr instead of states, because my sensors have Date_Until and Collection_date in attribute and not in state

- type: custom:dwains-flexbox-card
  items_classes: 'col-xs-12 col-sm-6 col-md-6 col-lg-6'
  padding: true
  cards:
    - type: horizontal-stack
      cards:
        - type: picture-entity
          style: |
            ha-card {
              padding: 5px;
              border-radius: 5px;
              background-color: var(--dwains-theme-primary);
            }
          entity: sensor.limburg_net_vandaag
          name: Vandaag
          image: /local/images/afval_geen_large.png
          state_image:
            'gft': /local/images/afval_gft_large.png
            'papier': /local/images/afval_papier_large.png
            'restafval': /local/images/afval_rest_large.png
            'pmd': /local/images/afval_pmd_large.png
            'pbd': /local/images/afval_pmd_large.png
            'papier, pmd': /local/images/afval_papier-pmd_large.png
            'kca': /local/images/afval_kca_large.png
        - type: picture-entity
          style: |
            ha-card {
              padding: 5px;
              border-radius: 5px;
              background-color: var(--dwains-theme-primary);
            }
          entity: sensor.limburg_net_morgen
          name: Morgen
          image: /local/images/afval_geen_large.png
          state_image:
            'gft': /local/images/afval_gft_large.png
            'papier': /local/images/afval_papier_large.png
            'restafval': /local/images/afval_rest_large.png
            'pmd': /local/images/afval_pmd_large.png
            'pbd': /local/images/afval_pmd_large.png
            'papier, pmd': /local/images/afval_papier-pmd_large.png
            'kca': /local/images/afval_kca_large.png
    - type: custom:auto-entities
      card:
          type: entities
          title: Volgende ophaaldata
      filter:
          exclude:
            - entity_id: sensor.afvalwijzer*next*
            - entity_id: sensor.afvalwijzer*to*
    
          include:
            - entity_id: sensor.limburg_net_*
              options:
                type: custom:template-entity-row
                state: >
                  {{as_timestamp(strptime(state_attr(config.entity,'Sort_date'),'%d-%m-%Y'))
                      |timestamp_custom('%-d %b')}}
                secondary: >
                  {% set count = state_attr(config.entity,'Days_until')|int %}
                  {% set day = as_timestamp(strptime(state_attr(config.entity,'Sort_date'),'%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' %}
                  {% elif count >= 7 %} {% set phrase = 'Volgende week ' + dag %}
                  {% elif count >= 3 %} {% set phrase = 'komende ' + dag %}
                  {% elif count == 2 %} {% set phrase = dag + ', overmorgen' %}
                  {% elif count == 1 %} {% set phrase = 'morgen, ' + dag %}
                  {% else %} {% set phrase = 'Vandaag, ' + dag %}
                  {% endif %}
                  {{phrase}} {% if count != 0%} ({{count}} {{unit}}) {% endif %}
      sort:
          method: state
          numeric: true

can’t figure it out, do you have a quick moment to have a look ?

Kr,

Bart

Can only say you use a custom card I don’t use. I wouldn’t know if that causes the issue.

What happens when you copy my config completely ?

btw, this is a bit odd:

      filter:
          exclude:
            - entity_id: sensor.afvalwijzer*next*
            - entity_id: sensor.afvalwijzer*to*
    
          include:
            - entity_id: sensor.limburg_net_*

Seems you dont use the same integration as I do, so I dont know what entities are created. You really have to go from 1 step to the next. first check the entities your integration creates, then check what attributes they have, next create the auto-entities filter based on that.

That’s not possible, because in you custom_component, Belgian locations & wastecollector Limburg.NET is not supported

Hi, perhaps it is something in my system, but on the latest HA and mijnafvalwijzer the AfvalWijzer.today sensor seems stuck on a day until I reboot. Going to the website mijnafvalwijzer lists 25 as next date (gft) but my cards in ha (several) show restafval as next (20-01). Are there any troubles know or is it my system? Config almost stock (using secrets)

this should be placed under / within de sensor condif ?

This is a template sensor and should be in your

template:

section in your yaml config files

Hi,

I’m getting it finally to work with Limburg.Net !! Nice work !

Unfortunately, I’m having issues with following warning:

* Template warning: 'as_timestamp' got invalid input '03 Feb' when rendering template '{{as_timestamp(strptime(states('sensor.limburg_net_pmd'),'%d-%m-%Y'))}}' but no default was specified. Currently 'as_timestamp' will return 'None', however this template will fail to render in Home Assistant core 2022.1

Could you maybe have a look ?

Thanks in advance !

Kr,

Bart