Garbage pickup date (mijnafvalwijzer.nl) custom_component

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

Its working thanks!

so far, I have no issues whatsoever with version 206. Won’t it hurt to update…? Couldn’t it have been something else bugging the output?

Thanks :slight_smile: That fixed it for me

@xirixiz
HI,
minutes after posting my question above, my sensors where gone, apparently the change kicked in.
Updated to 2.07, and now get this for all sensors:

Update for sensor.trash_ 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 137, in update
    for item in self.data.data:
TypeError: 'NoneType' object is not iterable

anything else we need to change in the setup to get it back working again?

Hi, for me it’s working fine. However some people are still experiencing issues. What I need is a postcal code and housenumber in your region so I can debug what causes the problem. Can you provide me that (pm otherwise).

thanks for having a look, Pm sent!

Same here

Update for sensor.trash_gft fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 221, in async_update_ha_state
await self.async_device_update()
  File "/usr/local/lib/python3.7/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.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/mijnafvalwijzer/sensor.py", line 137, in update
for item in self.data.data:
TypeError: 'NoneType' object is not iterable

I think I`m going to switch back to json anyway, scraping mijnafvalwijzer is way to messy. Fingers crossed mijnafvalwijzer won’t complain again about this component. If so, I’ll discontinue this component. Tomorrow evening I have all night to fix this! :smile:

that would be way cool, thanks!

btw, if Saver or Afvalwijzer complain again this service is only for paying customers, there are 2 points to be made:

  • we all pay for this service, and rather directly, by means of the municipal contracts that have been agreed on. Not as a general tax, but as a direct, service contract paying for the services delivered.
  • based on European GDPR law, AVG Dutch, they might have a hard time denying customers access to their own data…

anyways, hope you can fix the component :wink:

2 Likes