Garbage pickup date (mijnafvalwijzer.nl) custom_component

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” ??

Hi, maybe you can try something like:

{{ states.sensor.afvalinfo_gft.attributes["days_until_collection_date"] }}

But it seems you’re using a different component…

2 errors in your template: you’re not using the attributes, but state, and your using a string instead of a number 11:

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

btw, this would give you all available sensors:

{{ states.sensor
|selectattr('attributes.days_until_collection_date')
|selectattr('attributes.days_until_collection_date','!=',null)|map(attribute='name')|join(', ') }}

note that without the first selectattr, you get a list of all sensors :wink:

1 Like

Tnx, i Will try this later on.
I Have some trouble with my Rpi and the SD card. I have to fix this first.

Hi, the master branch has been updated so an exclude waste type option is available. For anyone who would like to give it a try, please do, so I’m sure everything works as exepected and I can release a new version.

Request: https://github.com/xirixiz/homeassistant-afvalwijzer/issues/131
Update: https://github.com/xirixiz/homeassistant-afvalwijzer

If you tested it, please share the outcome in the issue on GitHub. Thanks!

Hi there.
I’m new to Home Assistant and I can’t seem to get the information on my dashboard as is presented on your github page.
I think I have all the sensors and automations in the right place but I’m struggeling with the dashboard, is there a “tutorial” on how to set it up?
Thank you in advance.
Johan.

Hi All! Really happy with the afvakwijzer, but there is only one problem. “day after tomorrow” doesn’t work well. I’ts always the same as “tomorrow”. See screenshot below.

Is there anyone who can help me with this?

Hi @Bas81, this is an error in your config.

sensor.afvalwijzer_day_after_tomorrow is the actual data.
sensor.afvalwijzer_day_after_tomorrow_formatted is a sensor that should be created in HASS based on the data from sensor.afvalwijzer_day_after_tomorrow.

Most probably sensor.afvalwijzer_day_after_tomorrow_formatted is based on the data from sensor.afvalwijzer_tomorrow.

Example: https://github.com/xirixiz/my-hass-config/blob/654c576b2efc3f5f4b31bf1965ad1db97d721756/packages/waste.yaml#L99

Please verify.