Garbage pickup date (mijnafvalwijzer.nl) custom_component

It’s pretty straightforward.

  • Remove the exisiting configuration first (settings, devices & services, afvalwijzer, click on the 3 vertical aligned dots, delete(
  • Add your new configuration (same page, but at the bottom hit add entry).

I’ve tried to make the config editable, there are some issues currently. Maybe in a future release I`ll introduce this option again.

1 Like

Ouch, this is important for me to know. I once decided to lowercase all waste types. If this is not the case now, we’re dealing with a bug. The sensor waste types should always be lowecase like:

  • pmd
  • papier
  • plastic

Etc. Let me know if this isn’t the case now. Then I need to look into it. For mijnafvalwijzer it’s working fine at least, I checked it after seeing this post.

Most of the issues were in the dashboard. Not the sensors themselves. The sensors themselves are all lowercas as they should be. But in the dashboard the results that the sensors show, are different to the results before the big overhaul of the integration.

I still had a test dashboard that was not working so here is an example:

How it was:

type: picture-entity
entity: sensor.afvalwijzer_today
name: Vandaag
state_image:
  gft: /local/mijnafvalwijzer/gft3.png
  papier: /local/mijnafvalwijzer/papier3.png
  pmd: /local/mijnafvalwijzer/plastic3.png
  Geen: /local/mijnafvalwijzer/kliko3.png

How the code is now:

type: picture-entity
entity: sensor.afvalwijzer_today
name: Vandaag
state_image:
  Gft: /local/mijnafvalwijzer/gft3.png
  Papier: /local/mijnafvalwijzer/papier3.png
  Pmd: /local/mijnafvalwijzer/plastic3.png
  geen: /local/mijnafvalwijzer/kliko3.png

I don’t know if all is correct yet, that is something I will know next week when all different types of waste have been collected :wink:

So this was the view before the changes (with the new integration installed)

Here you can see gft was in lowercase and in the screenshot of the result you can see that it is now written as Gft. Geen has changed to all lowercase and Pmd is now with a capital P instead of fully lowercase (same as Gft). Also the papier sensor changed to sensor.afvalwijzer_oud_papier_en_karton instead of sensor.afvalwijzer_papier.

And here after the changes. Only thing in this view that also changed for me, is the sensors don’t respond with a Date but report only “Next week” or “In x weeks”. I’m still figguring out how to change that back. (ROVA, Amersfoort)

I hope this helps :slight_smile:

Oke, if the sensors show it lowercase then the component is working fine :slight_smile:. You probably have a template somewhere to change the case, it could be you need to update some things. I have this at least

  - platform: template
    sensors:
      afvalwijzer_next_item_formatted:
        value_template: >-
          {% if is_state('sensor.afvalwijzer_next_item', 'gft') %}GFT
          {% elif is_state('sensor.afvalwijzer_next_item', 'papier') %}Papier
          {% elif is_state('sensor.afvalwijzer_next_item', 'pmd') %}PMD
          {% elif is_state('sensor.afvalwijzer_next_item', 'restafval') %}Restafval
          {% else %}Geen
          {% endif %}
        friendly_name: "Next pickup item"

      afvalwijzer_today_formatted:
        value_template: >-
          {% if is_state('sensor.afvalwijzer_today', 'gft') %}GFT
          {% elif is_state('sensor.afvalwijzer_today', 'papier') %}Papier
          {% elif is_state('sensor.afvalwijzer_today', 'pmd') %}PMD
          {% elif is_state('sensor.afvalwijzer_today', 'restafval') %}Restafval
          {% else %}Geen
          {% endif %}
        friendly_name: "Vandaag"

      afvalwijzer_tomorrow_formatted:
        value_template: >-
          {% if is_state('sensor.afvalwijzer_tomorrow', 'gft') %}GFT
          {% elif is_state('sensor.afvalwijzer_tomorrow', 'papier') %}Papier
          {% elif is_state('sensor.afvalwijzer_tomorrow', 'pmd') %}PMD
          {% elif is_state('sensor.afvalwijzer_tomorrow', 'restafval') %}Restafval
          {% else %}Geen
          {% endif %}
        friendly_name: "Morgen"

      afvalwijzer_day_after_tomorrow_formatted:
        value_template: >-
          {% if is_state('sensor.afvalwijzer_day_after_tomorrow', 'gft') %}GFT
          {% elif is_state('sensor.afvalwijzer_day_after_tomorrow', 'papier') %}Papier
          {% elif is_state('sensor.afvalwijzer_day_after_tomorrow', 'pmd') %}PMD
          {% elif is_state('sensor.afvalwijzer_day_after_tomorrow', 'restafval') %}Restafval
          {% else %}Geen
          {% endif %}
        friendly_name: "Overmorgen"

For the showing of “Next week” etcetera instead of a date, look at this piece of code (mainly, the format: date option) :

cards:
  - cards:
      - entity: sensor.afvalwijzer_today_formatted
        show_name: true
        show_state: false
        state_image:
          GFT: /local/afvalwijzer/GFT.png
          Geen: /local/afvalwijzer/Geen.png
          PMD: /local/afvalwijzer/PMD.png
          Papier: /local/afvalwijzer/Papier.png
          Restafval: /local/afvalwijzer/Restafval.png
        type: picture-entity
      - entity: sensor.afvalwijzer_tomorrow_formatted
        show_name: true
        show_state: false
        state_image:
          GFT: /local/afvalwijzer/GFT.png
          Geen: /local/afvalwijzer/Geen.png
          PMD: /local/afvalwijzer/PMD.png
          Papier: /local/afvalwijzer/Papier.png
          Restafval: /local/afvalwijzer/Restafval.png
        type: picture-entity
      - entity: sensor.afvalwijzer_day_after_tomorrow_formatted
        show_name: true
        show_state: false
        state_image:
          GFT: /local/afvalwijzer/GFT.png
          Geen: /local/afvalwijzer/Geen.png
          PMD: /local/afvalwijzer/PMD.png
          Papier: /local/afvalwijzer/Papier.png
          Restafval: /local/afvalwijzer/Restafval.png
        type: picture-entity
    type: horizontal-stack
  - type: custom:auto-entities
    card:
      type: glance
    filter:
      exclude:
        - entity_id: sensor.afvalwijzer_*next*
        - entity_id: sensor.afvalwijzer_day_after_tomorrow*
        - entity_id: sensor.afvalwijzer_today*
        - entity_id: sensor.afvalwijzer_tomorrow*
        - entity_id: sensor.afvalwijzer_kerstbomen*
        - entity_id: sensor.afvalwijzer_*orgen
        - entity_id: sensor.afvalwijzer_van*
      include:
        - entity_id: sensor.afvalwijzer_*
          options:
            format: date
    sort:
      method: state
  - entities:
      - style:
          background: "#62717b"
          height: 1px
          margin-left: auto
          margin-right: auto
        type: divider
    type: entities
  - type: markdown
    content: >-
      <center>De volgende leging is {{ states('sensor.afvalwijzer_next_type')
      }}. Dat is over {{ states('sensor.afvalwijzer_next_in_days') }} {% if
      is_state('sensor.afvalwijzer_next_in_days', '1') %}dag{% else %}dagen{%
      endif %}.</center>
  - entities:
      - style:
          background: "#62717b"
          height: 1px
          margin-left: auto
          margin-right: auto
        type: divider
      - entity: input_boolean.waste_moved
      - entity: input_boolean.waste_reminder
    show_header_toggle: false
    type: entities
    state_color: false
type: custom:stack-in-card

Finaly, the middle one is missing as the papier sensor changed to “oud_papier_en_karton”. This is not due to the component, but due to the fact mijnafvalwijzer has changed the name for it in your environment. This happens more often. If you would like to see it as papier again, you can create a PR here:

Or ofcourse you can request it in an issue on Github. Easy to do.

1 Like

For the date formatting in Dutch you also need to do something like this:

  - platform: template
    sensors:
      afvalwijzer_gft_formatted:
        friendly_name: "GFT"
        value_template: "{{ as_timestamp(states['sensor.afvalwijzer_gft'].state) | timestamp_custom('%d-%m-%Y') }}"
        entity_picture_template: /local/afvalwijzer/GFT.png

      afvalwijzer_papier_formatted:
        friendly_name: "Papier"
        value_template: "{{ as_timestamp(states['sensor.afvalwijzer_papier'].state) | timestamp_custom('%d-%m-%Y') }}"
        entity_picture_template: /local/afvalwijzer/Papier.png

      afvalwijzer_pmd_formatted:
        friendly_name: "PMD"
        value_template: "{{ as_timestamp(states['sensor.afvalwijzer_pmd'].state) | timestamp_custom('%d-%m-%Y') }}"
        entity_picture_template: /local/afvalwijzer/PMD.png

      afvalwijzer_restafval_formatted:
        friendly_name: "Restafval"
        value_template: "{{ as_timestamp(states['sensor.afvalwijzer_restafval'].state) | timestamp_custom('%d-%m-%Y') }}"
        entity_picture_template: /local/afvalwijzer/Restafval.png

Then you can use those with something like this in lovelace:

type: custom:auto-entities
card:
  type: glance
filter:
  include:
    - entity_id: sensor.afvalwijzer_*_formatted

Result:

Just as an example…

2 Likes

Tnx! I will play arround with all this!

Another observation, I’m missing sensor.afvalwijzer_next_item in my envrionment. Is that expected (it was there before the big change to the integration).

That doens’t exist for quiet some time anymore:

afvalwijzer_next_type

Is the new name

please see this:

      - unique_id: volgende_afval_ophaal_dag
        state: >
          {% set next = states('sensor.afvalwijzer_next_date') %}
          {% set dt = next|as_datetime %}
          {% from 'easy_time.jinja' import month, weekday %}
          {% set dag = weekday(dt.isoweekday()) %}
          {% set datum = dt.day %}
          {% set maand = month(dt.month) %}
          {{dag}} {{datum}} {{maand}}

given the fact jinja templates cant be translated directly, we now use the custom_templates easy_time by Petro.

this allows you to set a default language, and all subsequent entities you use the easy_time in will be in your set language perfectly. Highly recommended!

1 Like

I was triggered by your example :wink:

This is one awesome card. But I’m having a bit of difficulty with all the code, templating cards etc etc. :wink: Could you paste the yaml code for this card?

If I ever completely figure out how to get here I’ll write a step by step afvalwijzer integration for dummies installation :rofl: :joy:

Why when i past this in to my dashboard i get No type specified

  • type: custom:auto-entities
    card:
    type: glance
    filter:
    exclude:
    - entity_id: sensor.afvalwijzer_next
    - entity_id: sensor.afvalwijzer_day_after_tomorrow*
    - entity_id: sensor.afvalwijzer_today*
    - entity_id: sensor.afvalwijzer_tomorrow*
    - entity_id: sensor.afvalwijzer_kerstbomen*
    - entity_id: sensor.afvalwijzer_orgen
    - entity_id: sensor.afvalwijzer_van

    include:
    - entity_id: sensor.afvalwijzer_*
    options:
    format: date
    sort:
    method: state
  • entities:
    • style:
      background: ‘#62717b
      height: 1px
      margin-left: auto
      margin-right: auto
      type: divider
      type: entities
  • type: markdown
    content: >- De volgende leging is {{ states('sensor.afvalwijzer_next_type') }}. Dat is over {{ states('sensor.afvalwijzer_next_in_days') }} {% if is_state('sensor.afvalwijzer_next_in_days', '1') %}dag{% else %}dagen{% endif %}.

there is no ‘this card’, except if you mean this Garbage pickup date (mijnafvalwijzer.nl) custom_component - #1023 by xirixiz, which was posted only a few posts above yours…

everyone can create the card they like to show things in the Dashboard

all of the examples above have been shared numerous times, so maybe first check the posts above, and then return with any questions left?

we can Not see what you do if you dont format the yaml correctly, please format it using the </> button in the editor, or using 3 so called backticks before and after your yaml, like this one:

`

see: How to help us help you - or How to ask a good question

This is the on on his github page but to walk true a topic with 1k of messages is not easy, so i found on a few message above that work half, i see dates but i also found out that with what i had, and what i see now that text change in scripts like bolean.trash is now bolean.waste and that make things also not work. So it would be fine if i know were to find these files compiled if this is possible. that we use no today, because i found old ones and new ones. I have a clean install of home assistant just for testing.

From noting to this

afval

if you check the integration panel config/integrations/integration/afvalwijzer you can click the entities, and see the exact names/entity_id’s in your system

with those, you can make the Dashboard cards.

Now of course, you might also need to change things in the yaml configuration of automations and maybe template sensors.

I toke the scripts from message 1004 and thing some from message 1002 the have different map for pictures, also some entrities were wrong so afther some changes in that and place of yaml files it got to live, only strange part i can’t figure out yet is why on the sencond row i had 3 items and now 4 but the 4th does not work. We only have 3 different kinds of waist we dont have PMD

you probably didnt filter out the other sensor entities the integration also creates.

check, it’s not a waste type sensor, but the count of the days sensor.

It’s what @Mariusthvdb says indeed. You need to update your exclusion or inclusion filter. For example.

  - type: custom:auto-entities
    card:
      type: glance
    filter:
      exclude:
        - entity_id: sensor.afvalwijzer_day*

Full example of code I`m using for this specific part:

  - type: custom:auto-entities
    card:
      type: glance
    filter:
      exclude:
        - entity_id: sensor.afvalwijzer_*next*
        - entity_id: sensor.afvalwijzer_day_after_tomorrow*
        - entity_id: sensor.afvalwijzer_today*
        - entity_id: sensor.afvalwijzer_tomorrow*
        - entity_id: sensor.afvalwijzer_kerstbomen*
        - entity_id: sensor.afvalwijzer_*orgen
        - entity_id: sensor.afvalwijzer_van*
      include:
        - entity_id: sensor.afvalwijzer_*_formatted
          options:
            format: date
    sort:
      method: state

yeah, and if the yaml for the exclusion is going to be so much more than the inclusion, you might be beter of by simply manually including those 3 entity_id’s in the include section verbosely :wink:

the new heading and badges were playing ground for some experiments:

  - type: heading
    heading: Ophaaldata
    heading_style: title
    card_mod:
      class: class-section-heading
      style:
        .badges hui-heading-badge:nth-child(1) hui-entity-heading-badge $: |
            ha-state-icon {
              --mdc-icon-size: 24px;
            }
            state-display {
              color: {{states('sensor.volgende_afval_kleur')}};
              text-transform: capitalize;
            }
        .badges hui-heading-badge:nth-child(2) hui-entity-heading-badge $: |
            state-display {
              color: var(--text-color-on);
            }
        .: |
          .badges hui-heading-badge:nth-child(1) hui-entity-heading-badge {
            --card-mod-icon: {{states('sensor.volgende_afval_icon')}};
            --card-mod-icon-color: {{states('sensor.volgende_afval_kleur')}};
          }
          .badges {
            background: var(--background-color-on);
            padding: 4px;
            border: 2px solid {{states('sensor.volgende_afval_kleur')}}
          }
    tap_action:
      action: navigate
      navigation_path: /calendar
    badges:
      - type: entity
        show_state: true
        show_icon: true
        entity: sensor.afvalwijzer_next_type
      - type: entity
        show_state: true
        show_icon: false
        entity: sensor.afvalwijzer_next_date