Garbage pickup date (mijnafvalwijzer.nl) custom_component

Ill try this, I just edited my previous post, is this relevant information?
EDIT 2: I see that I can only ask for notification for restafval gft and papier, is this the reason why the plastic sensor wont show up maybe? In my gemeente they call it ‘plastic verpakkingsmateriaal en drankkartons’ but this one isnt able to be set up for notification. Thats why my thought is why I might not be able to configure the plastic sensor, am I right?

To have my calender right showing I turned off my plastic next already

yes, only restafval, papier en gft. which is odd really. you might have to ping @xirixiz and ask him if he can check with you address data. especially if you can see the trash type in your App, or in the api data in mijnafvalwijzer.nl

and yes, if the integration doesn’t create the sensor, you can’t create the template sensor based on that :wink:

Perfect, ill send him a message. Thanks so far again. :grinning:

Yes, I just send you a pm :slight_smile:

fwiw, here’s an auto-entities card, based solely on the sensors the integration makes, (and ditches with my previous custom made template sensors). All I did was move these templates into the template-entity-row option, and had to exclude some of the other sensors:

  - 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.afvalwijzer_*
          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
1 Like

just to notify here too the sensors for today, tomorrow, and day after tomorrow are broken, as an issue was posted here.

Hi have intergrade my sensor but now i will a day before a notify to my phone that the garbage pickup.
Does anyone have a example how i make that easy?

This automation will send a push notification every hour between 17:00 and 20:00 the day before pickup:

- alias: Afval notificatie
  trigger:
    platform: time_pattern
    minutes: '/59'
    seconds: 00
  condition:
    condition: and
    conditions:
      - condition: time
        after: '17:00:00'
        before: '20:00:00'
      - condition: template
        value_template: "{{ states('sensor.afvalwijzer_tomorrow') != 'Geen' }}"
  action:
    - service: notify.push
      data:
        title: "Afval"
        message: 'Morgen: {{ states.sensor.afvalwijzer_tomorrow.state }}'

thanks for the fast response! I think i need to make a template? I’m starting to understand it more and more but I don’t quite understand the templates yet.

You can use my automation as is, you only need to be sure that “notify.push” works in your configuration for pushing a notification.

but why would you want to trigger it each hour in the set interval?

  - alias: Afval morgen
    id: Afval morgen
    trigger:
      - platform: time
        at: '21:00:00'
      - platform: time
        at: '16:16:00'
    condition:
      - >
          {{states.sensor.afvalwijzer_tomorrow is not none}}
      - >
          {{states('sensor.afvalwijzer_tomorrow') != 'Geen'}}
    action:
      - service: script.intercom_message
        data:
          message_nl: >
              Het is {{now().strftime('%d %B')}}: Morgen wordt
              {{states('sensor.afvalwijzer_tomorrow')|title}} opgehaald!
          message_en: >
              It is {{now().strftime('%d %B')}}: Tomorrow
              {{states('sensor.afvalwijzer_tomorrow')|title}} will be picked up!
      - service: script.notify_trash_tomorrow
      - service: script.persistent_trash_tomorrow
      - service: script.trash_outside_tomorrow

the second 16:16 trigger is only there to show you can trigger at more than 1 time.

Please note you dont need to use the ‘and’ in the conditions, they are and’ed by default

lastly, use

message: "Morgen: {{states('sensor.afvalwijzer_tomorrow')}}"

or multi-line:

message: >
  Morgen: {{states('sensor.afvalwijzer_tomorrow')}}

instead of

message: 'Morgen: {{ states.sensor.afvalwijzer_tomorrow.state }}'

to prevent errors if the template isnt initialized correctly

Because i want a push notification every hour between 17:00 and 20:00 :nerd_face:

haha, sure, why not. cool.

The push notifications need to push me to take out the container :rofl:

haha, this was unexpected:

auto-entities sort method not the right one:

    sort:
      method: state
      numeric: true

yep:

using:

    sort:
      method: attribute
      attribute: days_until_collection_date

hope this wont error next December, when the dates aren’t set yet…

2 Likes

Maybee somebody can help me.

I’m new to HomeAssisent and I’m trying to add the garbagecalender. Everyting works as expected until a view dag ago the sorting stoped working. I think the the problem is that one of the componends is missing in the JSON files which comes from an API? If this is the problem, how can I prevent the sorting to stop?

type: vertical-stack
cards:
  - type: glance
    title: Afval
    entities:
      - entity: sensor.afvalinfo_afval_today
        name: Vandaag
      - entity: sensor.afvalinfo_afval_tomorrow
        name: Morgen
  - type: entities
    entities:
      - entity: sensor.afvalinfo_afval_gft
        type: 'custom:secondaryinfo-entity-row'
        secondary_info: >-
          <b style='color:[[ if(sensor.days_until_collection_gft > 3, "" ,  "orange") ]]' > 
          Over [[ sensor.days_until_collection_gft ]] >
          [[if(sensor.days_until_collection_gft > 1, "dagen" , "dag") ]] </b>
      - entity: sensor.afvalinfo_afval_restafval
        type: 'custom:secondaryinfo-entity-row'
        secondary_info: >-
          <b style='color:[[ if(sensor.days_until_collection_restafval > 3, "","orange") ]]'>
          Over [[ sensor.days_until_collection_restafval ]]>
          [[ if(sensor.days_until_collection_restafval > 1, "dagen" , "dag") ]] </b>
      - entity: sensor.afvalinfo_afval_papier
        type: 'custom:secondaryinfo-entity-row'
        secondary_info: >-
          <b style='color:[[ if(sensor.days_until_collection_paper > 3, "" ,"orange") ]]'>
          Over [[ sensor.days_until_collection_paper ]]>
          [[if(sensor.days_until_collection_paper > 1, "dagen" , "dag") ]] </b>
      - entity: sensor.afvalinfo_afval_pbd
        type: 'custom:secondaryinfo-entity-row'
        secondary_info: >-
          <b style='color:[[ if(sensor.days_until_collection_pbd > 3, "" , "orange") ]]'>
          Over [[ sensor.days_until_collection_pbd ]]>
          [[if(sensor.days_until_collection_pbd > 1, "dagen" , "dag") ]] </b>
    filter:
      include:
        - entity_id: sensor.afvalinfo_gft
        - entity_id: sensor.afvalinfo_afval_papier
        - entity_id: sensor.afvalinfo_restafval
        - entity_id: sensor.afvalinfo_afval_pbd
    sort:
      numeric: true
      method: attribute
      attribute: days_until_collection_date

check the post above yours. sorting works as expected.

where did you find these < > stylings? must admit, that’s new to me

For the html tags look at: https://github.com/custom-cards/secondaryinfo-entity-row
For this one I want to maken an function so that it can also show “Vandaag” and “Morgen” insteat of “dag” and “dagen”

For the filter I use:
numeric: true -> because 11 comes after 10 and not between 1 and 2
method: attribute -> I want to sort on an attribute
attribute: days_until_collection_date -> the attribute that I want to use.
(sensor.afvalinfo_*.days_until_collection_date )
sorting-entities

Where do I make an mistake?

I have read the content above and I don’t see it…

great, there’s exactly 1 line with obscure tags, and of course I missed that. nice to know, so thanks for posting!

when you say the sorting ‘stops’, exactly what are you experiencing. Do you get any errors in the inspector or logs? What result is showing in the frontend?

Maybe you have incorrect entities (should show in the inspector as None), and your templates should guard those.

How, please give us some more information so we can help

btw, Vandaag and Morgen are available in my earlier post (s), eg here