Garbage pickup date (mijnafvalwijzer.nl) custom_component

Hi Thuurke, indeed, sensors are dependent of the zipcode as communities provide different names to the provider, which sucks! However you shoud see sensors starting with sensor.trash_

1 Like

Hello Xirixiz, I see gft,kca, and papier, so pmd is not available in my community.

Hi Marius,

Could you share also the sensors and automations? I found an old post from you with sensors but the sensor names are a bit different from the ones in this post or don’t exist, for example the sensor.trash_next_icon;
I have also doubts about the persistent_notification.trash_notification

Thanks

I wish this too! Cant make it work…

i must be missing something complete, installed this component but im new to this really and cant get it to show anything.

After installing, go to developer tools > entities > and start typing ‘trash’. This way you can see what sensors are available, and use them in your frontend or automations.

dont mind my ‘plastic’ sensor, i changed the friendly name of this sensor. Still got to change it back :wink:

Maybe some usefull info for others, I managed to sort the trash types dynamicaly by pickup date in Lovelace.
Unfortunatly, I can’t get it to work with formatted dates.

  - type: 'custom:auto-entities'
    card:
      type: glance
    filter:
      include:
        - entity_id: sensor.trash_gft
        - entity_id: sensor.trash_papier
        - entity_id: sensor.trash_pmd
        - entity_id: sensor.trash_restafval
    sort:
      method: state

Or

  - type: 'custom:auto-entities'
    card:
      type: glance
    filter:
      include:
        - entity_id: sensor.trash_gft
        - entity_id: sensor.trash_papier
        - entity_id: sensor.trash_pmd
        - entity_id: sensor.trash_restafval
    sort:
      method: attribute
      attribute: next_pickup_in_days
      numeric: true

Might be more reliable instead of a date sort

1 Like

thats probably my problem. i have no clue how to start in frontend with this.

You can try starting with this:

entity: sensor.trash_today
name: Vandaag
state_image:
  Geen: /local/images/afvalwijzer/kliko.png
  gft: /local/images/afvalwijzer/gft.png
  papier en karton: /local/images/afvalwijzer/papier.png
  'plastic, metalen en drankkartons': /local/images/afvalwijzer/plastic.png
  restafval: /local/images/afvalwijzer/restafval.png
type: picture-entity

Before trying this, you should have the images placed somewhere in the ‘www’ folder, and correct the paths in the code above.
This will show the trash that is picked up today, and when there is no trash picked up today, it shows “geen” with the kliko.png image.

The images used are posted somewhere in this topic.

You can do the same for the other sensors. you can also try the example from @xirixiz above this post!

Clone my old hass config, and browse through the folders and code to find out what has been configured, you should be able to find out that way.

But @sjorsjes created this nice view and I copied it from him in the past:

hi and all thanks for the support but i have another problem now i cant seem to solve.

This error is wht i am getting all the time and as far i see it is an array but i can be in my current noob mode again :slight_smile: Entities need to be an array

cards:

  • entity: sensor.trash_today
    name: Vandaag
    show_state: false
    state_image:
    Geen: /local/mijnafvalwijzer/kliko.png
    gft: /local/mijnafvalwijzer/gft.png
    papier: /local/mijnafvalwijzer/papier.png
    plastic: /local/mijnafvalwijzer/plastic.png
    restafval: /local/mijnafvalwijzer/rest.png
    type: picture-entity
  • entity: sensor.trash_tomorrow
    name: Morgen
    show_state: false
    state_image:
    Geen: /local/mijnafvalwijzer/kliko.png
    gft: /local/mijnafvalwijzer/gft.png
    papier: /local/mijnafvalwijzer/papier.png
    plastic: /local/mijnafvalwijzer/plastic.png
    restafval: /local/mijnafvalwijzer/rest.png
    type: picture-entity
  • entity: sensor.trash_day_after_tomorrow
    name: Overmorgen
    show_state: false
    state_image:
    Geen: /local/mijnafvalwijzer/kliko.png
    Gft: /local/mijnafvalwijzer/gft.png
    Papier: /local/mijnafvalwijzer/papier.png
    Plastic: /local/mijnafvalwijzer/plastic.png
    Restafval: /local/mijnafvalwijzer/rest.png
    type: picture-entity
    type: glance
cards:
  - entity: sensor.trash_today
    name: Vandaag
    show_state: false
    state_image:
      Geen: /local/mijnafvalwijzer/kliko.png
      gft: /local/mijnafvalwijzer/gft.png
      papier: /local/mijnafvalwijzer/papier.png
      plastic: /local/mijnafvalwijzer/plastic.png
      restafval: /local/mijnafvalwijzer/rest.png
    type: picture-entity
  - entity: sensor.trash_tomorrow
    name: Morgen
    show_state: false
    state_image:
      Geen: /local/mijnafvalwijzer/kliko.png
      gft: /local/mijnafvalwijzer/gft.png
      papier: /local/mijnafvalwijzer/papier.png
      plastic: /local/mijnafvalwijzer/plastic.png
      restafval: /local/mijnafvalwijzer/rest.png
    type: picture-entity
  - entity: sensor.trash_day_after_tomorrow
    name: Overmorgen
    show_state: false
    state_image:
      Geen: /local/mijnafvalwijzer/kliko.png
      Gft: /local/mijnafvalwijzer/gft.png
      Papier: /local/mijnafvalwijzer/papier.png
      Plastic: /local/mijnafvalwijzer/plastic.png
      Restafval: /local/mijnafvalwijzer/rest.png
    type: picture-entity
type: glance

Try horizontal-stack instead of glance.

1 Like

thanks that did the trick

1 Like

Could somebody help me? How can I change the name here for now pmd?


I’ve already had friendly name in my customize.yaml

Nobody?

Hi,

If I remember correctly (I don’t have access to my installation now), that value comes from a sensor called sensor.trash_firstwastetype, so you will need to format the state of that sensor

I just saw it in your code, the value you want to change comes from sensor.trash_first_next_item, but what you want to changes is the sensor state, not the name, you can try something like this

    trash_first_next_item_en:
      friendly_name: 'Next Garbage Item'
      value_template: >
        {% if states('sensor.trash_first_next_item') == 'Geen' %}
          Nothing
        {% elif states('sensor.trash_first_next_item') == 'gft' %}
          Organic
        {% elif states('sensor.trash_first_next_item') == 'papier' %}
          Paper
        {% elif states('sensor.trash_first_next_item') == 'pmd' %}
          Plastic
        {% elif states('sensor.trash_first_next_item') == 'restafval' %}
          Waste
        {% else %}
          Other	
        {% endif %}

And then use sensor.trash_first_next_item_en instead of sensor.trash_first_next_item in your card

Thanks. I will try that for changing the sensor state. Let you know if this is what I was looking for.

Hi @xirixiz

Glad you managed to add the new option for ‘count_today config option’ in 4.1.5
Thats a long desired option indeed, magic to finally see it appear.

just to be sure before upgrade to the new component, let me ask how this works out. Does this option only kick in on actual pickup days? because that’s when the sensor.first_date is confusing the setup. See:

using this markdown:

type: custom:vertical-stack-in-card
cards:
  - type: markdown
#    style: |
#      ha-card {
#      background: url("/local/mijnafvalwijzer/saver_logo.png");
#      }

    content: >
      # <font color = {{states('sensor.trash_color')}}>Afvalwijzer</font>

      <ha-icon icon= {{'mdi:delete-alert' if states('sensor.trash_firstdate') == 'vandaag' else 'mdi:delete-outline'}}> </ha-icon> Vandaag, {{states('sensor.vandaag')}}: <font color= {{states('sensor.trash_color')}}>**{{states('sensor.trash_today')}}</font>**

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

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

On non-pickup days, the first_date is always correct. So, I am not sure how to configure this, and am a bit afraid if I set it to tomorrows date it will stop functioning as desired on non pickup days…

let me rephrase:
on pickup day, first_date should be not todays trash but trash_next…
on non pickup days first-date should be as is.

of course, the same goes for sensor.trash_firstwastetype as you can see.
Hope this makes sense…

I’m trying to do something similar but struggling with scraping, can’t get anything to happen.
This is the page I’d like to scrape from, the four date values. Where do I start?
https://www.braintree.gov.uk/info/200198/recycling_information_and_advice/1158/route_4_collection_dates

this works, of course depending on the state you give your formatted sensors:


  - type: glance
    entities:
     - entity: sensor.gft_formatted
       name: GFT
     - entity: sensor.papier_formatted
       name: Papier
     - entity: sensor.plastic_verpakkingsafval_formatted
       name: Plastic
     - entity: sensor.restafval_formatted
       name: Restafval

  - type: divider

  - type: 'custom:auto-entities'
    card:
      type: glance
    filter:
      include:
        - entity_id: sensor.*_formatted
    sort:
      method: state

Top my current glance, below the auto-entities sorting glance.

first sorts on the alphabetical ‘Thu’, and following that sorts the number…

changing

      gft_formatted:
        friendly_name: 'Gft'
        value_template: >
          {{ as_timestamp(strptime(states('sensor.trash_gft'), '%d-%m-%Y')) | timestamp_custom('%a %d %b') }}

to

      gft_formatted:
        friendly_name: 'Gft'
        value_template: >
{{ as_timestamp(strptime(states('sensor.trash_gft'), '%d-%m-%Y')) | timestamp_custom('%d %b - %a') }}

would probably solve this. restarting now to test :wink:

Check:

Of course, this will run into issues when the dates cross the month. Only one solution for that: using the raw timestamps.

      restafval_trash_timestamp:
        friendly_name: 'Restafval'
        value_template: >
          {{ as_timestamp(strptime(states('sensor.trash_restafval'), '%d-%m-%Y'))}}

      plastic_verpakkingsafval_trash_timestamp:
        friendly_name: 'Plastic'
        value_template: >
          {{ as_timestamp(strptime(states('sensor.trash_plastic_verpakkingsafval'), '%d-%m-%Y'))}}

      gft_trash_timestamp:
        friendly_name: 'Gft'
        value_template: >
          {{ as_timestamp(strptime(states('sensor.trash_gft'), '%d-%m-%Y'))}}

      papier_trash_timestamp:
        friendly_name: 'Papier'
        value_template: >
          {{ as_timestamp(strptime(states('sensor.trash_papier'), '%d-%m-%Y'))}}

can probably be used in a auto_entities card sorted by state, and hopefully displaying the frontend name using the template-entity-row card.

something like this:

  - type: 'custom:auto-entities'
    card:
      type: glance
    filter:
      include:
        - entity_id: sensor.*_trash_timestamp
      options:
        type: custom:template-entity-row
        state: >
          {{ states(config.entity) | timestamp_custom('%a %d %b')}}
    sort:
      method: state

must experiment further…