Garbage pickup date (mijnafvalwijzer.nl) custom_component

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

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

Thnx for the quick response. The missing date is fixed and didn’t couse the problem(I have removed the item compleetly while testing).

What I meant with “the sorting stops” is that everyting looks alright but the order of the items is not sorted.
Knipsel
This has worked before and I don’t know why it isn’t working anymore. I don’t get any error messages.

What happens if you take out the numeric sort option ?

Working perfectly here:

Am I right that the time is based on utc time? So the change is at 1:00 in the morning?