Garbage pickup date (mijnafvalwijzer.nl) custom_component

May be my not knowing but how can I create an auto update of the card above. The number of days between ‘()’ should decrease every day but this only happens after completely reloading the page. This in contrast to other cards that update displayed values all the time.

Can’t say i recognize what you are saying. Don’t have this issue. Updates just fine.

Hi @Mariusthvdb …it’s been a while, but I’ve removed the solution mark from niekniek89 :slight_smile:

1 Like

As a newbie, I’m trying to add afvalwijzer to my sensors.yaml, but i keep getting errors. Could anybody help me?

- platform: template
  sensors:
    woonkamer_current_temperatuur:
      value_template: '{{ states.climate.woonkamer.attributes["current_temperature"] | replace(" c", "") | float }}'
      unit_of_measurement: '°C'
      friendly_name: "Woonkamer temperatuur"
    keuken_current_temperatuur:
      value_template: '{{ states.climate.eetkamer.attributes["current_temperature"] | replace(" c", "") | float }}'
      unit_of_measurement: '°C'
      friendly_name: "Keuken temperatuur"
    badkamer_current_temperatuur:
      value_template: '{{ states.climate.badkamer.attributes["current_temperature"] | replace(" c", "") | float }}'
      unit_of_measurement: '°C'
      friendly_name: "Badkamer temperatuur"
    slaapkamer_current_temperatuur:
      value_template: '{{ states.climate.slaapkamer.attributes["current_temperature"] | replace(" c", "") | float }}'
      unit_of_measurement: '°C'
      friendly_name: "Slaapkamer temperatuur"
    babykamer_current_temperatuur:
      value_template: '{{ states.climate.babykamer.attributes["current_temperature"] | replace(" c", "") | float }}'
      unit_of_measurement: '°C'
      friendly_name: "Babykamer temperatuur"
    werkkamer_current_temperatuur:
      value_template: '{{ states.climate.werkkamer.attributes["current_temperature"] | replace(" c", "") | float }}'
      unit_of_measurement: '°C'
      friendly_name: "Werkkamer temperatuur"
      
- platform: afvalwijzer
  sensor:
      provider: mijnafvalwijzer        # (required, default = mijnafvalwijzer) either choose mijnafvalwijzer, afvalstoffendienstkalender or rova
      postal_code: 1234AB              # (required, default = '')
      street_number:  5                # (required, default = '')
      suffix: ''                       # (optional, default = '')
      exclude_pickup_today: true       # (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 found
      id: ''                           # (optional, default = '') use if you'd like to have multiple waste pickup locations in HASS
      exclude_list: ''                 # (optional, default = '') comma separated list of wast types (case ignored). F.e. "papier, gft"

You need to add your wastecollector in the provider section.

Can you HA experts please help me to make a decent dashboard for mijnafvalwijzer.nl?

I would like to have something like this:

This is what I have now…

thats my card, which has been posted above, more than a few times.
I did adapt it somewhat, so here goes the last version Ive been using for quite some time now.

type: custom:mod-card
card_mod:
  style: |
    :host {
      --stack-card-margin: 0px;
    }
card:
  type: vertical-stack
  cards:

    - type: custom:button-card
      name: Volgende ophaaldata
      template: button_default_title
      hold_action:
        action: navigate
        navigation_path: >
          [[[ return window.location.pathname.split('/')[2] == 'calendar'
              ? '/ui-overview/home_summary' : null; ]]]

    - type: custom:hui-element
      card_type: markdown
      card_mod:
        style: |
           ha-card.type-markdown {
             box-shadow: none;
           }
      content: >
        <font color={{states('sensor.trash_color')}}><ha-icon icon= {{'mdi:delete-alert' if states('sensor.afvalwijzer_today') != 'Geen' else 'mdi:delete-outline'}}> </ha-icon></font> Vandaag, {{states('sensor.vandaag')}}: <font color= {{states('sensor.trash_color')}}>**{{states('sensor.afvalwijzer_today')|capitalize}}</font>**

        <font color={{states('sensor.trash_next_color')}}><ha-icon icon= {{states('sensor.trash_next_icon')}}> </ha-icon></font> Volgende afval-ophaal over **<font color={{states('sensor.trash_next_color')}}>{{states('sensor.afvalwijzer_next_in_days')}}</font>** {{'dag' if states('sensor.afvalwijzer_next_in_days') == '1' else 'dagen'}} op:

        <ha-icon icon= 'mdi:delete-alert'> </ha-icon> {{states('sensor.volgende_afval_ophaal_dag')}}: **<font color={{states('sensor.trash_next_color')}}>{{states('sensor.afvalwijzer_next_type')|capitalize}}</font>**


    - 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: &state_image
            gft: /local/afvalwijzer/gft.png
            papier: /local/afvalwijzer/papier.png
            restafval: /local/afvalwijzer/restafval.png
            plastic: /local/afvalwijzer/plastic.png
            Geen: /local/afvalwijzer/kliko_geen.png
            unknown: /local/afvalwijzer/kliko_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: *state_image

        - type: picture-entity
          entity: sensor.afvalwijzer_day_after_tomorrow
          card_mod:
            style: |
              ha-card {
                box-shadow: none;
              }
          name: Overmorgen
          show_state: false
          state_image: *state_image

    - type: custom:auto-entities
      card:
        type: entities
      filter:
        exclude:
          - entity_id: sensor.afvalwijzer*next*
          - entity_id: sensor.afvalwijzer*to*
        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:
        - type: custom:fold-entity-row
          head:
            type: section
            label: Automations
            card_mod:
              style: |
                .label {
                  margin-left: 0px;
                }
          group_config:
            state_color: true
          padding: 0
          entities:
            - entity: input_boolean.trash_reminder
              secondary_info: last-changed
            - entity: input_boolean.trash_outside
              secondary_info: last-changed
      #        - type: divider
            - entity: automation.afval_vandaag
              name: Notify vandaag
              secondary_info: last-triggered
            - entity: automation.afval_morgen
              name: Notify morgen
              secondary_info: last-triggered

any button_card_template used, you can find in my ‘Gists’ section

2 Likes

Dear Mariusthvdb, thanks for sharing, but I couldn’t figure out where I need to add these code… Are there any steps you could provide me?

as I hope you can see, this is a card config for your Dashboard. You can place it anywhere you like it to show up.
If you use YAML mode, just copy and paste it into any view of your liking. Of you use the UI editor, you frist need to open the Edit dashboard then Edit a card, or add a card, and on that card click Show code editor. Then Copy and paste and save

1 Like

I did! But I do get errors like button card is missing. Or hui element doesn’t exist or fold entity row doens’t exist.

Where do I need to copy your button_card_template code? I did this in my config.yaml, but I got all kind of errors.

Right, I see.

You need to install all of those custom cards first.

Also the button card templates need to be installed per dashboard, check the custom button-card repo for that.

If you check my Bio, there’s a link to my Gists and there you can see all of those templates I use

You need to install all of those custom cards first.
How can I install them?

Also the button card templates need to be installed per dashboard, check the custom button-card repo for that.
What do you mean exactly? Since I’m a “newbie” I don’t follow this.

If you check my Bio, there’s a link to my Gists and there you can see all of those templates I use
Yes, what I did is download your whole button-card-template folder and put all the code in config.yaml. But that doesn’t work.

tbh, you should maybe start a bit slower… my card is not that difficult, but you need to understand some HA basics first.

Installing a custom card is one of those basics. I use YAML mode, so write my own resources list, and include those in configuration.yaml like:

lovelace:
  mode: yaml
  resources: !include /config/dashboard/resources.yaml
  dashboards:

    ui-overview:
      mode: yaml
      filename: dashboard/dashboards/ui-overview.yaml
      title: Overzicht
      icon: mdi:view-dashboard

    ui-settings:
      mode: yaml
      filename: dashboard/dashboards/ui-settings.yaml
      title: Instellingen
      icon: mdi:tools

but if you use the UI mode, you can simply use HACS to install those cards for you. So, what ‘mode’ is your Dashboard in?

If you understand that, and got all those custom cards installed, next up are the button-card-templates. They belong to the custom card, and are documented in that repo. See: GitHub - custom-cards/button-card: ❇️ Lovelace button-card for home assistant

you have to install those for each dashboard like:

##############################################################################################################
# Main Dashboard configuration file, calling all Views via !include dashboard/view_***
# for ease of editing the separate Views, and prevent errors while doing so to the full setup
# @mariusthvdb
##############################################################################################################

title: Ha Main #Rpi4

button_card_templates: !include_dir_merge_named ../button_card_templates
decluttering_templates: !include_dir_named ../decluttering_templates
kiosk_mode: !include ../kiosk-mode/kiosk-mode.yaml

views:
  - !include ui-overview/view_overview_Home.yaml            #0
  - !include ui-overview/view_overview_Lights.yaml          #1
etc etc etc

again, this is in YAML mode.

there is no config.yaml. I suppose you refer to the configuration.yaml? That is not the correct file for this… configuration.yaml is for the Backend (server side) configuration.

the templates are for the Frontend Dashboard (previously called Lovelace) (client/browser/display side) and are referred to in ui-lovelace.yaml (or in more complex constructions if you have multiple dahsboards).
please read Multiple Dashboards - Home Assistant

back to nr1: first, install all custom resources :wink:

btw, this is getting rather Off-topic for this thread, and more of a crash course in basic understanding of HA. If you want to pursue, please open a separate thread (or search the community, there are many many posts about this)

I do use the UI mode yes. I have HACS installed and also the intergration button-card.

I created a new dashboard “Afvalwijzer test”. Added your code Garbage pickup date (mijnafvalwijzer.nl) custom_component - #722 by Mariusthvdb by adding a new card and putting that code in the manual yaml section (on the bottom). Now I do see dates but I do get the errors about missing cards. Hmm…

well, try to fix these errors. install the missing cards.

and just to get you on the right track from the beginning: custom card button-card is not an ‘integration’. It is a custom Dashboard/Frontend resource. Some call them plugin.

Hi all,

Hopefully someone can help me. I installed the afvalwijzer card using Marius’ code, however something strange happens.

The code (adapted for testing):

type: custom:auto-entities
card:
  type: entities
  title: Ophaaldata Spaarnelanden test
filter:
  exclude:
    - entity_id: sensor.afvalwijzer*next*
    - entity_id: sensor.afvalwijzer*to*
  include:
    - entity_id: sensor.afvalwijzer_gft*
    - entity_id: sensor.afvalwijzer_gft*
      options:
        type: custom:template-entity-row
        state: |
          {{as_timestamp(strptime(states(config.entity),'%d-%m-%Y'))
              |timestamp_custom('%d-%m-%Y')}}
    - entity_id: sensor.afvalwijzer_gft*
      options:
        type: custom:template-entity-row
        state: |
          {{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 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

And this results in the following:
afbeelding

The first one shows the date as given by the entity state (which is correct, GFT is always on Fridays), the second and third one show a wrong date.

Somehow the date has changed and I have no clue how or why. Can’t find anything on the forum related to it either.

Anyone got a clue?

4/11: SOLVED in the meantime.

I removed all the unnecessary spaces and re-typed all remaining spaces and linebreaks.

It seems that when copy pasting code into a card template some unseen characters may be included that screw up things.

I still don’t understand how things can turn weird so easily, but my dashboard works now as it should

This is really weird!

Just changing the year representation from ‘Y’ to ‘y’ changes the value …

And when removing the conversion to integer “|int” in the count statement nothing breaks and the calculation is correct

This is odd …

I have installed the Afvalwijzer from HACS and added the following to my config:

sensor:
- platform: afvalwijzer
provider: mijnafvalwijzer
postal_code: xxxxx
street_number: xx

however the only entitity what I see is:
update.afvalwijzer_update

Cannot see any more sensors. Somebody knows what I’m doing wrong?

First reaction: your yaml indentation does not seem right:

sensor:
  - platform: afvalwijzer
    provider: mijnafvalwijzer
    postal_code: xxxxx
    street_number: xx

Secondly: have you tried each one of the 3 providers: mijnafvalwijzer, afvalstoffendienstkalender, rova

Please let me know if this works for you

Because: I am using this configuration also, but I don’t get the sensor either at the moment.

My environment:

  • Afvalwijzer 2022.11.02
  • Home Assistant 2022.11.3
  • Supervisor 2022.10.2
  • Operating System 9.3
  • Frontend 20221108.0 - latest