Garbage pickup date (mijnafvalwijzer.nl) custom_component

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?

Taking out the numeric sort doen’t have any effect,

Found it, you’re not using the auto-entities card power, but list the entities as regular entities card

  - type: entities
    entities:

which simply lists the entities in the order you set in the config. It amazes me you dont get a logged error on the

    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

section, because that isnt supported in an entities card at all.

please have another look at my config posted above (see link) and use that auto-entities card config.
This has never worked in that config, and it was a mere coincidence if they were ordered correctly at 1 moment…

I’f have tryed that already without any luck :expressionless:

Line 12…

Please read what I wrote. You are listing the entities. That way the auto entities card doesn’t have options to do it’s job.

Fixed! Thnx for the support.

Hi, I had a question.

I want to look at the value of a attribute. But how I do that?

When I look at the state, I get the right result.

{{ states.sensor|selectattr('state','eq','03-02-2021')|map(attribute='name')|join(', ') }}

But I want to look at the attribute value of “days_until_collection_date”. But I get now results.

{{ states.sensor|selectattr('state.days_until_collection_date)','eq','11')|map(attribute='name')|join(', ') }}

How can you look at the value of the attribute of “days_until_collection_date” ??