Garbage pickup date (mijnafvalwijzer.nl) custom_component

Cool! thank you very much!
will implement immediately.
can report its working beautifully:

#    sensor.afval_datum:
    sensor.trash_firstdate:
      friendly_name: Afval datum
      icon: mdi:calendar-check

#    sensor.afval_soort:
#      hidden: true
    sensor.trash_firstwastetype:
      friendly_name: Afval soort
      templates:
        entity_picture: >
         if (state === 'Papier') return '/local/mijnafvalwijzer/papier.png';
         if (state === 'Groente, Fruit en Tuinafval' ) 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';

regular HA:

26

Lovelace:

  - 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.trash_firstdate.state ]]</font>** : **[[ sensor.trash_firstwastetype.state ]]**

21

HI @xirixiz

Please allow for one more suggestion, Ill illustrate with the below screenshot. AS you can see we have the 4 sensors for trash, and the trash_today/tomorrow. It today/tomorrow are Geen the next pickups for each trash type are shown. But, and that’s my point, when trash_today has a trash_type (and your new trash_firstdate = Today, the same 4 trash_types are displayed. Put in another way, Today is still among those 4.

Wouldn’t it be possible to have these shift their pickup. Eg, today is Got in my municipality, so trash_today shows GFT. It would be very nice it the trash_gft would then show its next pickup day being february 19th:

and calendar:

thanks for having a look!
btw, your new sensors are behaving very nicely! thanks again for adding those.

From a UI perspective I could maybe understand this, but I would really like to the behaviour to stay as-is. Otherwise in any of my trash-type specific automations I would always have to check the specific sensor, but also if the ‘today’ and/or ‘tomorrow’ sensor are of the desired type.

not sure what you’re saying here? what would be your problem? glad to help if needed. can’t see what trouble my suggestion would cause for any automation?
As an illustration, what automation would use the date of sensor gft, when you also have trash_today?

Currently I have some automations that check if the value of for example the “GFT” sensor equals todays or tomorrows date. If I understand your proposal correctly, I would have to modify these automations to check if the value of the “today” sensor matches the current date and then if the type is the one required for the automation. This is possible of course, but feels less clean to me because it adds an extra step in the automation. Could be a matter of preference of course :grinning:

1 Like

well, I think you shouldn’t worry, because my suggestion doesn’t touch the todays / tomorrows sensors.

to be 100% certain please post one of these automations ?

my suggestion was merely to have the trash_type sensor that is currently showing today’s date as the next pickup date, flip to the next date for that trash_type. No use having it show the whole day, what was picked up today isn’t there?

having 2 automations, (1 notification for tomorrow, 1 for today) suffices, or do you have more?

@juggles have you seen the automation I modified recently? https://github.com/xirixiz/home-assistant-config/blob/master/readme.md

But I understand what your point is.

As for for the sugestion, I think you mean that if the sensor today shows trash types for today, then the trash type sensor should show the next pickup date instead of the today date/value?

yes please. that would be very nice.

I’ll think about it. In the meantime, if you’d really like to have this feature…

You could modify line 257 from:
if value_date >= today_date:

to:
if value_date > today_date:

1 Like

nice, will test and report back if this is what I hope it is. Will see tomorrow :wink:
thanks!

would there also be a way to have a sensor.trash_day_after_tomorrow? I ask because the website shows these ‘overmorgen’ pickups.

in our municipality, there’s always pickup in pairs per week, and on the first day of that pickup, ‘overmorgen’ is available too. Don’t think it is a template made on the trash_next, like my handmade below but a true scrape for ‘overmorgen’.

      afval_overmorgen:
        friendly_name: Afval overmorgen
        value_template: >
          {% if states('sensor.trash_next') == '2' %}
            {{states('sensor.trash_firstwastetype')}}
          {% 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_overmorgen') %}
          {{ mapper[state] if state in mapper else '/local/mijnafvalwijzer/kliko_geen.png' }}

and customize:

    sensor.afval_overmorgen:
      templates:
        theme: >
         if (state === 'Papier') return 'blue';
         if (state === 'Groente, Fruit en Tuinafval' ) return 'green';
         if (state === 'Plastic verpakkingsafval') return 'orange';
         if (state === 'Restafval') return 'black';
         return 'grey';

This is great dude! I was planning to create this myself, but then I saw your component, awesome!

I hadn’t seen that yet, but it looks pretty nice. I think I’ll change my current (to-do list based) automation for this notification based setup.

the seems to have killed the trash_today, which doesn’t show correctly anymore, while sensor.trash_firstdate == ‘vandaag’.

changed it back to if value_date >= today_date: makes it popup immediately again, but unfortunately also give me back the reason I asked… Now how can we have the dates shift, and still have a valid sensor.trash_today?

Or just use glance card?
https://www.screencast.com/t/qxaIdDERbJj7

1 Like

I make it optional so you can choose. I`m on a holiday at the moment, but when I return I’ll draft a new release.

cool, have a good holiday ! make it a good one.

and, for when your back:

check this please, which is related. .firsttrashtype is seen as todays trash:

15

  afval_overmorgen:
    friendly_name: Afval overmorgen
    value_template: >
      {% if states('sensor.trash_next') == '2' %}
        {{states('sensor.trash_firstwastetype')}}
      {% 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_overmorgen') %}
      {{ mapper[state] if state in mapper else '/local/mijnafvalwijzer/kliko_geen.png' }}

might be the afvalwijzer doest update the nexttrashtype on a pickup day, but ultimately I am looking for a way to have todays trash, tomorrows trash and day after tomorrow…

which is all there:

03

maybe we have to combine things, like on a pickup day, compare the dates for day after tomorrow… still, I have hope you can find a way to find ‘overmorgen’ on the afvalwijzer.nl page and scare that somehow.

this still works:

{{ now().strftime("%d-%m-%Y") == 
          (as_timestamp(strptime(states('sensor.trash_papier'), "%d-%m-%Y")) - 
             (2 * 86400 )) | timestamp_custom("%d-%m-%Y") }}

Yesterday i installed everyting and it was working well.
Since today it’s showing ‘Geen’ and i think it’s getting no data.
The website afvalwijzer is working.

When i look at the logs it says for all the sensors:
update for sensor.trash_today fails

More people with this problem?

Wed Feb 20 2019 18:47:16 GMT+0100 (West-Europa (standaardtijd))
Update for sensor.trash_firstdate fails
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 221, in async_update_ha_state
await self.async_device_update()
File “/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity.py”, line 349, in async_device_update
await self.hass.async_add_executor_job(self.update)
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/sensor/mijnafvalwijzer.py”, line 135, in update
for item in self.data.data:
TypeError: ‘NoneType’ object is not iterable

Was doing the install just now, running in to the same issue.

Having the same problem now as well, worked flawlessly before, so I guess something changed on the mijnafvalwijzer.nl website.

I’m getting the same error, I`m looking into it…

Update: the output has changed from mijnafvalwijzer.nl. The output now contains a lot of spaces. As a workaround I`m stripping all spaces from the output so this error won’t occur again.

Update 2: Version 2.0.7 has been released…

2 Likes