Custom component Afvalbeheer - Support for multiple waste collectors

I’m so sorry for the spelling mistakes. I am dyslexic, so I’m prone to making those mistakes… Not very handy as a programmer :wink: Can you point me to some more mistakes I made? I tested the component, and it is working for me without any errors.

I made a few improvements to the script, so it will look like this now;
16
EDIT: code on Github now Github Cure Afvalbeheer

1 Like

Sure, why not put it on github?

You are right. In the beginning of next week I’ll put it on github.

I’ve created a github repo for both sensors.
They can also be used with the custom updater!

Github Cure Afvalbeheer

Github Groningen Afvalwijzer

Nice. I see you fixed that typo I initially indicated. I’ll do a walk-trough later :slight_smile:
Also going to check out the Custom Updater!

Hi Pippyn. First of all thanks for your contribution. I was wondering if you could also support Blink?

I just noticed the API is exactly the same as for Cure;
https://mijnblink.nl/rest/adressen/5711NK-12 (random address).

Didn’t try if the Cure url gives the same result by the way, but seems interesting to support multiple vendors.

On first look the API is somewhat different, but i’ll look into it this week!

Ah okay. I watched on my phone and saw the same endpoints, just didn’t compare the results. I can build something myself but I thought it was the same so that felt like overkill :wink:

Ohw yeah it’s very similar, just not the same! Probably an easy addition. Will let you know

I made a new sensor and it should work with the following wast collectors: Blink, Cure, Cyclus, DAR, HVC Groep, Meerlanden and RMN (Reinigingsbedrijf Midden Nederland).
This sensor is in beta right now. Once it’s stable it will replace the cure_afvalbeheer sensor. And that sensor will be deprecated from then on.
Please test the sensor and feel free to report any issues!

(this sensor can also be used with the custom updater)

2 Likes

Awesome! Will try it.
Will you submit it afterwards to HA or will it stay a custom component?

there is a bug in the groningen_afvalwijzer.py:

2019-01-16 23:22:28 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.afvalwijzer_groene_container fails

17-1-2019 00:22:28 Traceback (most recent call last):

17-1-2019 00:22:28 File “/usr/src/app/homeassistant/helpers/entity.py”, line 221, in async_update_ha_state

17-1-2019 00:22:28 await self.async_device_update()

17-1-2019 00:22:28 File “/usr/src/app/homeassistant/helpers/entity.py”, line 349, in async_device_update

17-1-2019 00:22:28 await self.hass.async_add_executor_job(self.update)

17-1-2019 00:22:28 File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run

17-1-2019 00:22:28 result = self.fn(*self.args, **self.kwargs)

17-1-2019 00:22:28 File “/config/custom_components/sensor/groningen_afvalwijzer.py”, line 185, in update

17-1-2019 00:22:28 self.data.update()

17-1-2019 00:22:28 File “/usr/src/app/homeassistant/util/init.py”, line 315, in wrapper

17-1-2019 00:22:28 result = method(*args, **kwargs)

17-1-2019 00:22:28 File “/config/custom_components/sensor/groningen_afvalwijzer.py”, line 138, in update

17-1-2019 00:22:28 (day.replace("*", “”) + " " + str(i) + " " + year), “%d %m %Y”))

17-1-2019 00:22:28 File “/usr/local/lib/python3.6/_strptime.py”, line 565, in _strptime_datetime

17-1-2019 00:22:28 tt, fraction = _strptime(data_string, format)

17-1-2019 00:22:28 File “/usr/local/lib/python3.6/_strptime.py”, line 362, in _strptime

17-1-2019 00:22:28 (data_string, format))

17-1-2019 00:22:28 ValueError: time data ’ 6 2019’ does not match format ‘%d %m %Y’

Pushed an update with a bug fix. Will you please check if it resolves the issue?

I can confirm it is fixed! :+1:

In the future i would like to make a pull request to make this a main sensor in HA. But I fear it will take a lot of work (never did that before). But first of all I need to be sure there’re no more bugs.

A custom component can become almost already completely a “real” component out of the box.
Anyways, looking good at my side. Just a couple of minor things:

  • In your example config on Github there is a typo (Bink vs Blink)
  • In your example config on Github there is a typo (wastcollector vs wastecollector)
  • In your example config within the code there is a typo (waste_collector vs wastecollector)

Will check in the upcoming time how it behaves in comparison with my current own calendar implementation.

(Personally I prefer to change the date format, since the “year” doesn’t matter for example).

Yes, i’ve read the docs and it seems straight forward. I just have to refractor the code and adhere to pylint.
Thank you so much for showing me those bugs!
I fixed the spelling mistakes and added a option to change the date format.

Did the update work for you?

Updated the afvalbeheer sensor to support 12 more waste collectors. The full list of supported collectors is:

  • Alphen Aan Den Rijn
  • Avalex
  • Berkelland
  • Blink
  • Circulus-Berkel
  • Cranendonck
  • Cure
  • Cyclus
  • DAR
  • Den Haag
  • GAD
  • HVC
  • Meerlanden
  • Montfoort
  • RMN
  • Spaarnelanden
  • Venray
  • Waalre
  • ZRD

Thanks for this. Just added. Works fine for GAD!

Question: How can use these easy in an automation. For instance sending a notification for what get’s picked up tomorrow. How do evaluate this? I’ve seen similar compenents that have also implemented sensor.trash_tomorrow or something similar