Afvalwijzer, Image not working when two garbage types wil be collected on same day

Hi folks here I am again.

First of all my deep respect to @xirixiz the creator of “Afvalwijzer”. Thanks for this beautiful piece of work!

Occasionally it wil be the case that on the same day two garbage types will be collected. For example last week august 22 the types “Restafval” and “Papier” has bin collected. As you can see in the screenshot the integration does not handle this correctly. It would be nice if the image would be split into half to display both garbage types. I saw on the forum that some of you have this working but I cannot see how its done.

Again, I am not a coding specialist so please don’t be to harsh with me :wink:

Would appreciate very much if you guys have tips for me and push me in the right direction

This is the full code of the card I use. Please ask if you need more info.

Thanks in advance!
Regards, Herman F.

type: custom:mod-card
card_mod:
  style: |
    :host {
      --stack-card-margin: 0px;
    }
card:
  type: vertical-stack
  cards:
    - type: custom:button-card
      name: Afvalwijzer
      template: null
      hold_action:
        action: navigate
        navigation_path: |
          [[[ return window.location.pathname.split('/')[2] == 'calendar'
              ? '/ui-overview/home_summary' : null; ]]]
      styles:
        card:
          - background-color: var(--background-color-off)
          - color: Darkgreen
          - font-size: 20px
          - font-weight: Bold
          - padding: 12px
        name:
          - justify-self: left
    - type: custom:hui-element
      card_type: markdown
      card_mod:
        style: |
          ha-card.type-markdown {
          box-shadow: none;
          }
      content: >
        <ha-icon icon= {{'mdi:delete' if states('sensor.afvalwijzer_today') ==
        'Geen' else 'mdi:delete-outline'}}> </ha-icon> Vandaag,
        {{states('sensor.today')}}: **{{states('sensor.afvalwijzer_today') |
        capitalize}}**

        <ha-icon icon= {{states('sensor.afvalwijzer_next_icon')}}> </ha-icon>
        Volgende afval-ophaaldag over
        **{{states('sensor.afvalwijzer_next_in_days')}}** {{'dag' if
        states('sensor.afvalwijzer_next_in_days') == '1' else 'dagen'}} op:

        <ha-icon icon= 'mdi:delete'> </ha-icon>
        {{states('sensor.afvalwijzer_next_date')}}:
        **{{states('sensor.afvalwijzer_next_type') | capitalize}}**
    - type: horizontal-stack
      cards:
        - type: picture-entity
          card_mod:
            style: |
              ha-card {
                box-shadow: none;
                animation: {% if is_state('persistent_notification.trash_notification_today','notifying') and
                                   states('sensor.afvalwijzer_today') != 'Geen' %} blink 2s linear infinite;
                           {% else %} none
                           {% endif %}
              }
              @keyframes blink {
                100% {opacity: 0;}
              }
          entity: sensor.afvalwijzer_today
          name: Vandaag
          show_state: false
          state_image:
            gft: /local/afvalwijzer/gft.png
            papier: /local/afvalwijzer/papier.png
            restafval: /local/afvalwijzer/restafval.png
            pmd: /local/afvalwijzer/pmd.png
            Best-tas: /local/afvalwijzer/best-tas.png
            Snoeiafval: /local/afvalwijzer/snoeiafval.png
            Geen: /local/afvalwijzer/geen.png
        - type: picture-entity
          card_mod:
            style: |
              ha-card {
                box-shadow: none;
                animation: {% if is_state('persistent_notification.trash_notification_tomorrow','notifying') and
                                   states('sensor.afvalwijzer_tomorrow') != 'Geen' %} blink 2s linear infinite;
                           {% else %} none
                           {% endif %}
              }
              @keyframes blink {
                100% {opacity: 0;}
              }
          entity: sensor.afvalwijzer_tomorrow
          name: Morgen
          show_state: false
          state_image:
            gft: /local/afvalwijzer/gft.png
            papier: /local/afvalwijzer/papier.png
            restafval: /local/afvalwijzer/restafval.png
            pmd: /local/afvalwijzer/pmd.png
            Best-tas: /local/afvalwijzer/best-tas.png
            Snoeiafval: /local/afvalwijzer/snoeiafval.png
            Geen: /local/afvalwijzer/geen.png
        - type: picture-entity
          entity: sensor.afvalwijzer_day_after_tomorrow
          card_mod:
            style: |
              ha-card {
                box-shadow: none;
              }
          name: Overmorgen
          show_state: false
          state_image:
            restafval: /local/afvalwijzer/restafval.png
            gft: /local/afvalwijzer/gft.png
            papier: /local/afvalwijzer/papier.png
            pmd: /local/afvalwijzer/pmd.png
            Best-tas: /local/afvalwijzer/best-tas.png
            Snoeiafval: /local/afvalwijzer/snoeiafval.png
            Geen: /local/afvalwijzer/geen.png
    - type: custom:auto-entities
      card:
        type: entities
      filter:
        exclude:
          - entity_id: sensor.afvalwijzer*next*
          - entity_id: sensor.afvalwijzer*to*
          - entity_id: sensor.afvalwijzer*until*
        include:
          - entity_id: sensor.afvalwijzer_*
            options:
              type: custom:template-entity-row
              image: >
                {% set type = config.entity.split('afvalwijzer_')[1] %}
                /local/afvalwijzer/{{type}}.png
              state: >
                {% set trash = config.entity %} {% set today =
                state_attr(trash,'is_collection_date_today') %} {% set future =
                state_attr(trash,'days_until_collection_date') %} {% if future
                is none or
                   (is_state(trash,'Geen') and future == 0) %} Tba
                {% else %} {{as_timestamp(strptime(states(trash),'%d-%m-%Y'))
                                |timestamp_custom('%-d %b')}}
                {% endif %}
              secondary: >
                {% set trash = config.entity %} {% set today =
                state_attr(trash,'is_collection_date_today') %} {% set future =
                state_attr(trash,'days_until_collection_date') %} {% if future
                is none or
                   (is_state(trash,'Geen') and future == 0) %} Nog niet gepubliceerd
                {% else %}
                  {% set count = state_attr(trash,'days_until_collection_date')|int(default=0) %}
                  {% set day = as_timestamp(strptime(states(trash),'%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 >= 28 %} {% set phrase = dag + ' over 4 weken' %}
                  {% elif count >= 21 %} {% set phrase = dag + ' over 3 weken' %}
                  {% elif 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 %}
                {% endif %}
      sort:
        method: attribute
        attribute: days_until_collection_date
        numeric: true
      entities: null

Maybe you also need the “Templates.taml” code for reviewing. Here it is;

- sensor:
    ##### Afvalwijzer templates ##################################
    - name: afvalwijzer_first_next_item_formatted
      state: >
        {% if is_state('sensor.afvalwijzer_next_type', 'gft') %}gft
        {% elif is_state('sensor.afvalwijzer_next_type', 'papier') %}papier
        {% elif is_state('sensor.afvalwijzer_next_type', 'restafval') %}restafval
        {% elif is_state('sensor.afvalwijzer_next_type', 'pmd') %}pmd
        {% elif is_state('sensor.afvalwijzer_next_type', 'best_tas') %}best_tas
        {% elif is_state('sensor.afvalwijzer_next_type', 'snoeiafval') %}snoeiafval
        {% endif %}

    - name: Afvalwijzer Today Formatted
      state: >
        {% if is_state('sensor.afvalwijzer_today', 'gft') %}gft
        {% elif is_state('sensor.afvalwijzer_today', 'papier') %}papier
        {% elif is_state('sensor.afvalwijzer_today', 'restafval') %}restafval
        {% elif is_state('sensor.afvalwijzer_today', 'kerstbomen, restafval') %}restafval
        {% elif is_state('sensor.afvalwijzer_today', 'pmd') %}pmd
        {% elif is_state('sensor.afvalwijzer_today', 'best_tas') %}best_tas
        {% elif is_state('sensor.afvalwijzer_today', 'snoeiafval') %}snoeiafval
        {% else %}Geen
        {% endif %}

    - name: Afvalwijzer Tomorrow Formatted
      state: >
        {% if is_state('sensor.afvalwijzer_tomorrow', 'gft') %}gft
        {% elif is_state('sensor.afvalwijzer_tomorrow', 'papier') %}papier
        {% elif is_state('sensor.afvalwijzer_tomorrow', 'restafval') %}restafval
        {% elif is_state('sensor.afvalwijzer_tomorrow', 'kerstbomen, restafval') %}restafval
        {% elif is_state('sensor.afvalwijzer_tomorrow', 'pmd') %}pmd
        {% elif is_state('sensor.afvalwijzer_tomorrow', 'best_tas') %}best_tas
        {% elif is_state('sensor.afvalwijzer_tomorrow', 'snoeiafval') %}snoeiafval
        {% else %}Geen
        {% endif %}
      icon: >
        {% if is_state('sensor.afvalwijzer_tomorrow', 'gft') %}
        mdi:food-apple
        {% elif is_state('sensor.afvalwijzer_tomorrow', 'papier') %}papier
        mdi:newspaper-variant-multiple-outline
        {% elif is_state('sensor.afvalwijzer_tomorrow', 'restafval') %}restafval
          mdi:delete
        {% else %}
          mdi:delete-empty
        {% endif %}
      picture: >
        {% if is_state('sensor.afvalwijzer_tomorrow', 'gft') %}
          /local/afvalwijzer/gft.png
        {% elif is_state('sensor.afvalwijzer_tomorrow', 'papier') %}papier
          /local/afvalwijzer/papier.png 
        {% elif is_state('sensor.afvalwijzer_tomorrow', 'restafval') %}restafval
          /local/afvalwijzer/restafval.png
        {% elif is_state('sensor.afvalwijzer_tomorrow', 'pmd') %}pmd
          /local/afvalwijzer/plastic.png
        {% elif is_state('sensor.afvalwijzer_tomorrow', 'best_tas') %}best_tas
          /local/afvalwijzer/recycle.png
        {% elif is_state('sensor.afvalwijzer_tomorrow', 'snoeiafval') %}snoeiafval
          /local/afvalwijzer/snoeiafval.png
        {% else %}
          /local/afvalwijzer/geen.png
        {% endif %}

    - name: today
      state: >
        {% set months = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december"] %}
        {% set month = months[now().strftime('%m') | int -1] %}
        {{ now().strftime('%d') + ' ' + month + ' '+ now().strftime('%Y') }}

    - name: afvalwijzer_days_until_collection_date
      state: >
        {% set days_until_collection_date = 100 %}
        {% if (state_attr('sensor.afvalwijzer_restafval', 'days_until_collection_date') != None) %}
          {% if (state_attr('sensor.afvalwijzer_restafval', 'days_until_collection_date') < days_until_collection_date) %}
            {% set days_until_collection_date = state_attr('sensor.afvalwijzer_restafval', 'days_until_collection_date') %}
          {% endif %}
        {% endif %}
        {% if (state_attr('sensor.afvalwijzer_gft', 'days_until_collection_date') != None) %}
          {% if (state_attr('sensor.afvalwijzer_gft', 'days_until_collection_date') < days_until_collection_date) %}
            {% set days_until_collection_date = state_attr('sensor.afvalwijzer_gft', 'days_until_collection_date') %}
          {% endif %}
        {% endif %}
        {% if (state_attr('sensor.afvalwijzer_pmd', 'days_until_collection_date') != None) %}
          {% if (state_attr('sensor.afvalwijzer_pmd', 'days_until_collection_date') < days_until_collection_date) %}
            {% set days_until_collection_date = state_attr('sensor.afvalwijzer_pmd', 'days_until_collection_date') %}
          {% endif %}
        {% endif %}
        {% if (state_attr('sensor.afvalwijzer_papier', 'days_until_collection_date') != None) %}
          {% if (state_attr('sensor.afvalwijzer_papier', 'days_until_collection_date') < days_until_collection_date) %}
            {% set days_until_collection_date = state_attr('sensor.afvalwijzer_papier', 'days_until_collection_date') %}
          {% endif %}
        {% endif %}
        {% if (state_attr('sensor.afvalwijzer_best_tas', 'days_until_collection_date') != None) %}
          {% if (state_attr('sensor.afvalwijzer_best_tas', 'days_until_collection_date') < days_until_collection_date) %}
            {% set days_until_collection_date = state_attr('sensor.afvalwijzer_best_tas', 'days_until_collection_date') %}
          {% endif %}
        {% endif %}
        {% if (state_attr('sensor.afvalwijzer_snoeiafval', 'days_until_collection_date') != None) %}
          {% if (state_attr('sensor.afvalwijzer_snoeiafval', 'days_until_collection_date') < days_until_collection_date) %}
            {% set days_until_collection_date = state_attr('sensor.afvalwijzer_snoeiafval', 'days_until_collection_date') %}
          {% endif %}
        {% endif %}
        {{ days_until_collection_date }}

    - name: afvalwijzer_next_icon
      state: >
        {{ 'mdi:numeric-' + states('sensor.afvalwijzer_next_in_days') + '-box-multiple-outline' }}

Does the Limburg.Net location still work ?

He is from the Netherlands, therefor afvalwijzer.
Limburg.net => https://www.limburg.net/afvalkalender

Hallo everyone,

Still looking for some support here…

Thanks to @Mariusthvdb for the great package.

Hey everyone,

As you can see in the image, on October 24th, two types of waste will be collected: “GFT” and “Papier.”

image

My “Afvalwijzer” integration still doesn’t quite understand how to display this. As a result, it doesn’t show any images at all. In @crimby’s post, they asked for a specific image showing two types of waste. For example;

image

My question is, do you need to create custom images for these situations, or can this be solved through code as well?

I want to emphasize once again that I’m not a programming expert. Please be patient with me :slight_smile:

Does anyone has this working, and if so, how did you achieve it?

All tips are welcome. If some code from my side is required, please let me know.

Thanks, Herman.

BTW many thanks to the creators of “Mijnafvalwijzer”, @Mariusthvdb and @xirixiz

1 Like