Garbage pickup date (mijnafvalwijzer.nl) custom_component

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”}]

The source doesn’t matter, json or scraper. With the scraper I`m generating the same json output. It’s possible to collect everything, but the question is where to store the values in HASS.

Please do :slight_smile:
do you have them in node-red or just automations in home assistant?

just HA automation which has never let me down, and I couldn’t imagine NodeRed would make this any where near simpler…
Still interested? :wink: scroll up to Garbage pickup date (mijnafvalwijzer.nl) custom_component - #156 by Mariusthvdb

I hope hvc and others will be build-in. hvc uses the same methode as almost every other provider.

with zipcode and housenumber you can get the bagID:
https://apps.hvcgroep.nl/rest/adressen/" …zipcode…"-"…housenumber…"
example: https://apps.hvcgroep.nl/rest/adressen/3328DB-37

output looks like

[{"bagId":"0505200000092263","postcode":"3328LN","huisnummer":35,"huisletter":"","huisnummerToevoeging":"","openbareRuimteNaam":"Moestuin","woonplaatsNaam":"Dordrecht","latitude":51.7701971,"longitude":4.6597255,"woonplaatsId":2351,"gemeenteId":505}]
find bagid:0505200000092263

get data:
https://apps.hvcgroep.nl/rest/adressen/" …myBagId … “/kalender/” … myYear
url looks like:
https://apps.hvcgroep.nl/rest/adressen/0505200000092263/kalender/2019

Urls for other providers:

Cyclus NV: https://afvalkalender.cyclusnv.nl
HVC: https://apps.hvcgroep.nl
Dar: https://afvalkalender.dar.nl
Afvalvrij / Circulus-Berkel: https://afvalkalender.circulus-berkel.nl
Meerlanden: https://afvalkalender.meerlanden.nl
Cure: https://afvalkalender.cure-afvalbeheer.nl
Avalex: https://www.avalex.nl
RMN: https://inzamelschema.rmn.nl
Venray: https://afvalkalender.venray.nl
Den Haag: https://huisvuilkalender.denhaag.nl
Berkelland: https://afvalkalender.gemeenteberkelland.nl
Alphen aan den Rijn: https://afvalkalender.alphenaandenrijn.nlrest/adressen/0505200000061116/afvalstromen
Waalre: http://afvalkalender.waalre.nl
ZRD: https://afvalkalender.zrd.nl
Spaarnelanden: https://afvalwijzer.spaarnelanden.nl
Montfoort: https://afvalkalender.montfoort.nl
GAD: https://inzamelkalender.gad.nl
Cranendonck: https://afvalkalender.cranendonck.nl

source: https://www.gadget-freakz.com/domoticz-dzvents-getgarbagedates-script/

does this help?

My component will work for hvc (and some others mentioned in your list). Didn’t know there were so many. I’ll integrate the rest also asap.

1 Like

HI @xirixiz,

since we’ve now moved to a scrape sensor, I have a feature request:

would you consider adding these scrape sensors to the CC?

Having these polled only once could save system resources, and I hope to reduce errors I receive every once in a while when the url isn’t reachable, maybe because conflicting polling requests (not sure but it might very well be)

please have a look?

  - platform: scrape
    resource: !secret scrape_resource_date
    name: Afval Datum
    select: '.firstDate'
    scan_interval: 360

  - platform: scrape
    resource: !secret scrape_resource_type
    name: Afval Soort
    select: '.firstWasteType'
    scan_interval: 360

resource in the same format as your CC: http://www.mijnafvalwijzer.nl/nl/{postcode}/{huisnummer}/

it adds sensor.afval_datum (showing ‘vandaag’ ) and sensor.afval_soort (trash for that date)

enabling this kind of simple automation (which I use already, since I have the scrape sensors defined in my config)

- alias: 'Afval vandaag'
    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.afval_datum') == 'vandaag' }}
    action:
      - service: notify.notify
        data_template:
          message: >
            Het is vandaag {{ now().strftime("%d %B") }}.
            Zet het {{states('sensor.afval_soort')}} aan de straat!
      - condition: template
        value_template: >
          {{ is_state('input_boolean.persistent_notification_create', 'on')}}
      - service: persistent_notification.create
        data_template:
          title: >
            Afvalmelding Vandaag: {{states('sensor.afval_soort')}}
          message: >
            Het is vandaag {{ now().strftime("%d %B") }}.
            Zet het {{states('sensor.afval_soort')}} aan de straat!

btw note Im still on HA 84.3 so not yet using the new trigger: time format. which in this could would become:

trigger: time
at: '07:00:00'

see: https://www.home-assistant.io/docs/automation/trigger/#time-trigger

for customizing this sensor I use:

  afval_vandaag:
    friendly_name: 'Afval vandaag'
    value_template: >
       {% if is_state('sensor.afval_datum', 'vandaag') %}
        {{states('sensor.afval_soort')}}
        {% else %}
        Geen
        {% endif %}
    entity_picture_template: >
      {% set mapper = {'Papier': '/local/mijnafvalwijzer/papier.png',
                       'Groente, Fruit en Tuinafval': '/local/mijnafvalwijzer/gft.png',
                       'Plastic verpakkingsafval': '/local/mijnafvalwijzer/plastic.png',
                       'Restafval': '/local/mijnafvalwijzer/restafval.png'} %}
      {% set state = states('sensor.afval_vandaag') %}
      {{ mapper[state] if state in mapper else '/local/mijnafvalwijzer/kliko_geen.png' }}

Hi @Mariusthvdb,

What is it exactly you would like to see? At this moment the following sensors are already implemented:

  • sensor.trash_today - What trashtypes are going to be picked up Today
  • sensor.trash_tomorrow - What trashtypes are going to be picked up Tomorrow
  • sensor.trash_next - First upcoming trash pickup in days

Is it you would like to see a sensor which shows the first upcoming trash type?

HI!
have a look at the diffference:

having afval_vandaag allows for my automation, which is so much easier than the large automation condition set you use.

also trash_next counts the days, while afval_datum show the word vandaag (today (vandaag) is pickup day)

So Id love to have both these sensors in, and would even want to know if it is possible it we can check for ‘overmorgen’, as the website does (at least it does in my postal code)

Trash is picked up on Tue and Thursdays here, so on Tuesdays a ‘overmorgen’ should always be available…

Perhaps somthing like the automation I use is even easier. Look at:
https://github.com/xirixiz/home-assistant-config/blob/master/readme.md

I’ve shorten the automation back to a single line and removed all conditions.

hmm, not really;-)

you trigger on input_booleans or each 30 minutes… while I simply test at 7 o’clock whether sensor.afval_datum == vandaag, not to mention the complicated calculation for tomorrow/today in the notification.

unless I am missing a online automation of course, but I’ve checked your link.

do you have objections of some kind to add these 2 extra scrapers? (you’ve suggested them to me yourself in the beginning of the CC, and I’ve never stopped using them :+1: )

Sorry, yes, because there’s really no point adding those just because of some date calculation :slight_smile:

Perhaps if this feature is wanted by more people, or if someone would like to participate writing code to add this feature as a pull request.

Also you can check at 7 o’clock if “{{ states(‘sensor.trash_tomorrow’) != ‘Geen’ }}”.

thats not the main reason of course, maybe you’d give it a try with the separate scrape sensors and see how nice they are to have alongside the CC. They give you just the extra options to use.

that’s what I do at 20:00:00 :wink:

  - 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')}}

use both sensors in the notification to see the difference in output.

Btw; Nice this blue theme. Dan you pls share?

@Pippyn thanks for your component. Can you also add some extra sensors like garbage out today and garbage out tomorrow? Now I have a nice card but really a lot of work to create any automation around this. Thanks

getting back to this, I still see use for my 2 sensors your component doesn’t provide for:

.firstDate and .firstWasteType are simply what they are named. A sensor for the next pickup date (showing Vandaag, or the next date, no further calculation needed at all), and a sensor for the first waste type.

I don’t see these in your component, without having to further template the trash sensors it currently makes.

Of course having a list of all next waste types (we now have) shows this info too, but you have to have the full view of the list, before being able to deduct it.

  - type: vertical-stack
    cards:
      - type: custom:useful-markdown-card
        content: >
          Vandaag is het **<font color=green>[[ sensor.vandaag.state ]]</font>**.

          Volgende afval-ophaal over **<font color=var(--secondary-text-color)>[[ sensor.trash_next.state ]]</font>** dagen:

          **<font color=var(--secondary-text-color)>[[ sensor.afval_datum.state ]]</font>** : **[[ sensor.afval_soort.state ]]**

45

It’s very nice to have a sensor on the front page showing only which and when the first will be.
Hope you’d be willing to reconsider. I did have a look where this would fit in you CC, but didnt dare to edit here and there…My requested sensors being scrapers too, I have hopes this wouldn’t interfere with your CC?

cheers.

Hi Marius,

I just added firstdate and firstwastetype as sensors (release 2.0.6). Cheers.

1 Like