Garbage pickup date (mijnafvalwijzer.nl) custom_component

Hmm, maybe I`m not getting it :thinking:, why don’t you install the required modules using “pip install”?

True that, but there where maybe more dependencies missing. So i thought, after reviewing the dependencies of the JSON variant, that was the easy way :stuck_out_tongue:

cool. change the line 232 into:

        firstWasteType['value'] = scraper_data.find('p', attrs={'class':'firstWasteType'}).text.replace('.','')

so it doesn’t show the trailing .

08
instead of:

17

maybe there’s a better way to do so?
Before I had to setup all templates sensors and customizations the get rid of the full-stop. This is way nicer. Consider this a PR :wink:

did the same for 226:

        trashFirstDate['value'] = scraper_data.find('p', attrs={'class':'firstDate'}).text.capitalize()

but I could imagine that to be too much for a PR, though feel free to do so, looks way better in the frontend. (imho)

this way we don’t need the now defunct _stateDisplay to customize the display of the state in the frontend.

couldn’t find the right place for capitalize() in trashToday and trashTomorrow, so would like to ask you where to add that in the CC so we these values in capital also.

I have the following in my config

  track:
    - cards
    - components
  component_urls:
    - https://raw.githubusercontent.com/maykar/custom-lovelace/master/tracker.json
    - https://raw.githubusercontent.com/xirixiz/home-assistant-config/master/custom_updater.json
  card_urls:
    - https://raw.githubusercontent.com/kalkih/mini-media-player/master/tracker.json

But for some reason your component is not shown in the list, any idea’s?

I just had the same issue. I think you copied the previous version as well. Make sure the local location is as defined in: https://github.com/xirixiz/home-assistant-config/blob/master/custom_updater.json (seems this changed during the discussions above :slight_smile: )

1 Like

That’s correct indeed.

The location of sensors changed from:

  • /custom_components/sensors/mijnafvalwijzer.py

to:

  • /custom_components/mijnafvalwijzer/sensor.py

Soon this will be the default config for custom sensors in hass.

1 Like

since not everyone is on the latest HA version yet (0.84.3 here with still most of the custom-ui goodies that are deprecated upwards…), would it be possible for you to create a custom_updater_old.json so we can point the updater to that and make it backwards compatible?

No, sometimes breaking changes are just inevitable.
Making it comfortable for people only results in a lot of maintenance and people not upgrading to the latest version :slight_smile:

Hi @xirixiz ,

I just found out about your component and saw a lot of similarities between mijnafvalwijzer.nl and
afvalstoffendienstkalender.nl which is used for Den Bosch, Vught, Oisterwijk, Haaren and Heusden.

So I quick and dirty replaced mijnafvalwijzer.nl with afvalstoffendienstkalender.nl and it’s working for this site as well. Perhaps an idea to make the url configurable as well in the configuration.yaml?

Since I’m not very well known in the python language yet, I’m not able to make a pull request at this moment. But perhaps for the future.

Good job! I`ll make the url configurable and release it later Today.

…just drafted a new release…

- platform: afvalwijzer
  url: 'mijnafvalwijzer.nl or afvalstoffendienstkalender.nl'
  postcode: '1111AA'
  huisnummer: '1'
  toevoeging: 'A'
  label_geen: 'Geen'

Notice the breaking change everyone! The component has been renamed from mijnafvalwijzer to afvalwijzer.

Hmz, I now got an error on it. But not sure if it’s the component or the update to 0.89. Also my honeywell lyric custom component was broken.

edit: my bad, had a dummy value in my postalcode… doh! So it’s working. Great work, thanks!

Hmm, been away couple of weeks and updated everything today.
I think it’s broken over here again.
Used the new folder layout and config.

Error:
2019-03-08 13:31:35 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform afvalwijzer
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py”, line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/local/lib/python3.6/asyncio/tasks.py”, line 358, in wait_for
return fut.result()
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/home/homeassistant/.homeassistant/custom_components/afvalwijzer/sensor.py”, line 82, in setup_platform
json_obj = response.json()
File “/srv/homeassistant/lib/python3.6/site-packages/requests/models.py”, line 897, in json
return complexjson.loads(self.text, **kwargs)
File “/usr/local/lib/python3.6/json/init.py”, line 354, in loads
return _default_decoder.decode(s)
File “/usr/local/lib/python3.6/json/decoder.py”, line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/local/lib/python3.6/json/decoder.py”, line 357, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Yes, I had to rewrite it back to the json url as the scraper didn’t work anymore. Scraping is very sensitive and I didn’t want to rewrite a lot of code again. Also now more gemeentes can use this component. It’s to bad that the json url for your postal code and housenumber isn’t working, it’s a problem from mijnafvalwijzer as we know.

Maybe the scraping component version still works for you, you could try that ofcourse.

I can’t get the component to work after a reinstall

  File "/home/homeassistant/.homeassistant/custom_components/afvalwijzer/sensor.py", line 73
url = (f"https://json.{url}/?method=postcodecheck&postcode={postcode}&street=&huisnummer={huisnummer}&toevoeging={toevoeging}&platform=phone&langs=nl&")

Here is a modified version of the component. It works on Debian stable with the current python version 3.5.

I have the same issue.

  File "/home/homeassistant/.homeassistant/custom_components/afvalwijzer/sensor.py", line 73
url = (f"https://json.{url}/?method=postcodecheck&postcode={postcode}&street=&huisnummer={huisnummer}&toevoeging={toevoeging}&platform=phone&langs=nl&")
                                                                                                                                                      ^

Ill modify the component not to use f-strings. Ill draft a new release this week.

@jeweet Thanks! I used your version to draft version 3.0.6.

@xirixiz I love your component, my Google Home alerts me to take out the trash, haven’t missed a day yet. Thanks!

Could you perhaps provide installation instructions in the README on your Github? I’m just not sure what folders to create under custom_component etc. I think other users might benefit from a brief explanation as well :blush:

Thanks for the kind words Emphyrio!

On Github there’s a brief instruction available on how to configure the custom_component.

However, instructions for using custom_components is something for the HASS docu itself and can be found here:

I’ll add the link to the readme on Github.