Garbage pickup date (mijnafvalwijzer.nl) custom_component

i use this for customizations (and yes, have custom-ui installed):

sensor.trash_next_in_days:
  friendly_name: Days to next pickup
  templates:
    icon: >
      if (state === '0') return 'mdi:numeric-0-box-multiple-outline';
      if (state === '1') return 'mdi:numeric-1-box-multiple-outline';
      if (state === '2') return 'mdi:numeric-2-box-multiple-outline';
      if (state === '3') return 'mdi:numeric-3-box-multiple-outline';
      if (state === '4') return 'mdi:numeric-4-box-multiple-outline';
      if (state === '5') return 'mdi:numeric-5-box-multiple-outline';
      if (state === '6') return 'mdi:numeric-6-box-multiple-outline';
      if (state === '7') return 'mdi:numeric-7-box-multiple-outline';
      if (state === '8') return 'mdi:numeric-8-box-multiple-outline';
      if (state === '9') return 'mdi:numeric-9-box-multiple-outline';
      if (state > '9') return 'mdi:nnumeric-9-plus-box-multiple-outline';
      return 'mdi:calendar-question';

sensor.trash_today:
  friendly_name: 'Trash today'
  templates:
    entity_picture: >
     if (state === 'papier') return '/local/mijnafvalwijzer/papier.png';
     if (state === 'gft' ) return '/local/mijnafvalwijzer/gft.png';
     if (state === 'plastic verpakkingsafval') return '/local/mijnafvalwijzer/plastic.png';
     if (state === 'restafval') return '/local/mijnafvalwijzer/restafval.png';
     return '/local/mijnafvalwijzer/kliko_geen.png';
    _stateDisplay: >
     if (state === 'papier') return 'Papier';
     if (state === 'gft' ) return 'Gft';
     if (state === 'plastic verpakkingsafval') return 'Plastic';
     if (state === 'restafval') return 'Restafval';
     return 'Geen';

sensor.trash_tomorrow:
  friendly_name: 'Trash tomorrow'
  templates:
    entity_picture: >
     if (state === 'papier') return '/local/mijnafvalwijzer/papier.png';
     if (state === 'gft' ) return '/local/mijnafvalwijzer/gft.png';
     if (state === 'plastic verpakkingsafval') return '/local/mijnafvalwijzer/plastic.png';
     if (state === 'restafval') return '/local/mijnafvalwijzer/restafval.png';
     return '/local/mijnafvalwijzer/kliko_geen.png';
    _stateDisplay: >
     if (state === 'papier') return 'Papier';
     if (state === 'gft' ) return 'Gft';
     if (state === 'plastic verpakkingsafval') return 'Plastic';
     if (state === 'restafval') return 'Restafval';
     return 'Geen';

do we set this up as usual or have to add _scraper in the sensor platform? I get a config error now…

EDIT_
nevermind, think I got it working, renamed the component to mijnafvalwijzer.py…

please let me ask this:

will the state for the plastic sensor be sensor.trash_plastic, or as it used to be plastic_verpakkingsmateriaal. And, related, will the trash_today and _tomorrow use plastic, or plastic_verpakkingsmateriaal.
I can’t find it in the inspector just yet, but your component seems to have changed that?

secondly, something is amiss with the dates, have a look. It seems to skip 2 dates and jumps to 14 februari for Papier:

29

while this is in the app:

Thanks!

seems the custom_ui thing did the trick!!
Sorry for the weird question :confused:

I’m gonna try my hand on making a telegram notification with inline keyboard… will post if it works :wink:

Have notifications for you if you want … just let me know.

Btw it is sensor.trash_next with the new CC version

Hi Marius, is the new cc version running fine now, or do you still have some issues? From now on I`ll make release notes with changes and breaking changes so there’s more info about what has actually changed.

Sensors are created based on the name of mijnafvalwijzer with the prefix “trash_”. For my region f.e. I have only “Papier, GFT, Restafval and Plastic”, so the sensors “trash_papier, trash_gft, trash_restafval and trash_plastic” are generated. trash_today, trash_tomorrow, trash_next will remain the same in upcoming releases.

I was thinking of creating one sensor with multiple attributes, but I`m not sure if that would be a better approach. Perhaps someone else at this topic knows :face_with_raised_eyebrow:?

running fine! except for the strange thing about missing out on 2 pickup dates in februari, as I showed you.

about the plastic sensor, I’ll be sure when it happens.

did you ever see my automation based on the trash sensors today and tomorrow. They’re much smaller than the big conditional templates:

  - alias: 'Afval morgen'
    id: 'Afval morgen'
    initial_state: on
    trigger:
      platform: time
      hours: 20 
      minutes: 0
      seconds: 0
    condition:
      - condition: template
        value_template: >
          {{ is_state('input_boolean.notify_utility', 'on')}}
      - condition: template
        value_template: >
          {{states('sensor.trash_tomorrow') != 'Geen'}}
    action:
      - service: notify.notify
        data_template:
          message: >
            Het is vandaag {{ now().strftime("%d %B") }}, 
              {{states('sensor.afval_soort')|replace('.','')}} wordt morgen opgehaald!
      - condition: template
        value_template: >
          {{ is_state('input_boolean.persistent_notification_create', 'on')}}
      - service: persistent_notification.create
        data_template:
          message : >
            Het is vandaag {{ now().strftime("%d %B") }},
                    {{states('sensor.afval_soort')|replace('.','')}} wordt morgen opgehaald!, 
                    Trash tomorrow: {{states('sensor.trash_tomorrow')}}'
          title: >
            Afvalmelding Morgen: {{states('sensor.afval_soort')|replace('.','')}} : {{states('sensor.trash_tomorrow')}}

and:

  - alias: 'Afval vandaag alt'
    id: 'Afval vandaag alt'
    initial_state: on
    trigger:
      platform: time
      hours: 7 
      minutes: 0
      seconds: 0
    condition:
      - condition: template
        value_template: >
          {{ is_state('input_boolean.notify_utility', 'on')}}
      - condition: template
        value_template: >
          {{states('sensor.trash_today') != 'Geen'}}
    action:
      - service: notify.notify
        data_template:
          message: >
            Het is vandaag {{ now().strftime("%d %B") }}.
              {{states('sensor.trash_today')|title}} wordt vandaag opgehaald!
      - condition: template
        value_template: >
          {{ is_state('input_boolean.persistent_notification_create', 'on')}}
      - service: persistent_notification.create
        data_template:
          message: >
            Het is vandaag {{ now().strftime("%d %B") }}.
                    {{states('sensor.trash_today')|title}} wordt vandaag opgehaald!'
          title: >
            'Trash today: '

Thanks for sharing, I agree the automation I use is a bit outdated :slight_smile:.

I don’t see what’s wrong actually. GFT is correct, plastic is correct, and restafval is correct, but I don’t see the next pickup date for papier in the app, is it really before 14 feb? The naming for plastic depends what you gemeente has provided to mijnafvalwijzer. It could be plastic_verpakkingsmateriaal in 2018, while in 2019 they changed it to just plastic.

well, the app says so, and this is what’s on the webpage:

I think I don’t understand what the problem is. The next pickup dates are matching on the website, app and mijnafvalwijzer component as far as I can see.

…or do you mean the list order on the lovelace card?

not the order, but the dates:
25

shouldn’t this show the next few pickups? it goes from jan 22 to 29 , which is correct, then jumps to feb 14, and misses out on feb 5 and 7…

No, this is correct. For every trash type the first next upcoming pickup date, nothing in between :smiley:.

a ok, if this is per design, all is well then :wink:

would you accept a feature request for an extra: to have the dates listed in order of next appearance? as on the website, maybe for the next month? If at all possible scraping the site of course.

I’m afraid that’s not possible with hass as a sensor has a single state, perhaps as an attribute…

Maybe, it is possible to create a weather-like component: 1 card where you can configure the trash types you want to show, and that orders them by date automatically. This is what my weather component looks like. I don’t have the time nor the photoshop skills to edit the image. But here’s a collection of sensors shown, and i guess it’s possible for the garbage component possible too, just showing trahs thypers ordered by date?

[Edit: started to develop this morning. I hope to post my progress today]

image

i like that thought!
since I use several of these weather cards, just let me know where I can help to develop and test, be glad to.

Do you have expereince with HTML and CSS?

Unfortunatly that’s not possible. As I stated before, the source/content isn’t static. Trash for different communties have different names.

plastic, platsic en flessen, plastic and other meuk, plastic and blah, etc, etc. As for the weather component, the only difference is the community, but the data returned is always named the same.

I have a config option where you have to provide the different sensors for the different trash types you want to show. Technically i’ve fixed the happy flow already…

There’s an other issue though, We have only one sensor per trash type. So, for every trash type, the next date is shown. But when there are two pickup dates for the same trash type before the next pickup date for an other trash type, you will not see the second date for the first type but you’ll see the next date for the second type.

This is what i have so far:

It uses the latest version of the mijnafvalwijzer component. As Bram stated, sensor names can be different for communities. My lovelace config:

resources:
  - url: /local/custom_ui/trash_card/trash-card.js
    type: js

and

cards:
      - type: "custom:trash-card"
        entities:          
          - sensor.trash_kca
          - sensor.trash_gft
          - sensor.trash_papier
          - sensor.trash_restafval
          - sensor.trash_takken

I have uploaded my test config in a public Git repo:

https://github.com/Sholofly/Trash-card

Feel free to join the development and submit som pull requests.

1 Like

though my original json CC stopped showing correct sensors, maybe it was a temporary system fluke…I tested the json.mijnafvalwijzer.nl just now and it returns a correct list of ophaaldagen. I haven’t received any mention of it being unsupported, or only for paying clients at all. Wouldn’t it be possible to transform this list into an ordered list of ophaaldagen in HA? :

[“ophaaldagen”:{“response”:“OK”,“data”:[{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-01-05”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-01-08”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-01-10”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-01-15”},{“nameType”:“papier”,“type”:“papier”,“date”:“2019-01-17”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-01-22”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-01-24”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-01-29”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-02-05”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-02-07”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-02-12”},{“nameType”:“papier”,“type”:“papier”,“date”:“2019-02-14”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-02-19”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-02-21”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-02-26”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-03-05”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-03-07”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-03-12”},{“nameType”:“papier”,“type”:“papier”,“date”:“2019-03-14”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-03-19”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-03-21”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-03-26”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-04-02”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-04-04”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-04-09”},{“nameType”:“papier”,“type”:“papier”,“date”:“2019-04-11”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-04-16”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-04-18”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-04-23”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-04-30”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-05-02”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-05-07”},{“nameType”:“papier”,“type”:“papier”,“date”:“2019-05-09”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-05-14”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-05-16”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-05-21”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-05-28”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-06-01”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-06-04”},{“nameType”:“papier”,“type”:“papier”,“date”:“2019-06-06”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-06-11”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-06-13”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-06-18”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-06-25”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-06-27”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-07-02”},{“nameType”:“papier”,“type”:“papier”,“date”:“2019-07-04”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-07-09”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-07-11”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-07-16”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-07-23”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-07-25”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-07-30”},{“nameType”:“papier”,“type”:“papier”,“date”:“2019-08-01”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-08-06”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-08-08”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-08-13”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-08-20”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-08-22”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-08-27”},{“nameType”:“papier”,“type”:“papier”,“date”:“2019-08-29”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-09-03”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-09-05”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-09-10”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-09-17”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-09-19”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-09-24”},{“nameType”:“papier”,“type”:“papier”,“date”:“2019-09-26”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-10-01”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-10-03”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-10-08”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-10-15”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-10-17”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-10-22”},{“nameType”:“papier”,“type”:“papier”,“date”:“2019-10-24”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-10-29”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-10-31”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-11-05”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-11-12”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-11-14”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-11-19”},{“nameType”:“papier”,“type”:“papier”,“date”:“2019-11-21”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-11-26”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-11-28”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-12-03”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-12-10”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-12-12”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-12-17”},{“nameType”:“papier”,“type”:“papier”,“date”:“2019-12-19”},{“nameType”:“gft”,“type”:“gft”,“date”:“2019-12-24”},{“nameType”:“plastic verpakkingsafval”,“type”:“plastic”,“date”:“2019-12-28”},{“nameType”:“restafval”,“type”:“restafval”,“date”:“2019-12-31”}]