Home Assistant Community

Garbage pickup date (mijnafvalwijzer.nl) custom_component

#119

cool.
doesn’t help though, updater still lists the same for your component…which is in fact not yet updated.

0 Likes

#120

image

Hi @xirixiz, thanks for implementing the multiple waste types. But… the feature request is giving me a UI problem. Is there a way to show two images in case there are two garbage types in one day? The other option is to create an image for every possible combination. But thats just not the way i want to go.

Besides that it would be nice to be able to ignore some waste types for the today and tomorrow sensor. i.e. grofvuil is only picked up after making an appointment. So i like that for my automations but not for the today and tomorrow sensor. Is that something for a feature request on Github?

0 Likes

#121

hey @xirixiz

would you please update the correct version info in your GitHub repo? Updater says 1.1.6 is available but isn’t successful in updating.
Checking your repo the files are still on 1.1.5?

15

0 Likes

#122

Hi Marius…fixed :smiley:

1 Like

#123

Hmm, that would be nice indeed…I`ll look into it.

1 Like

#124

hi @xirixiz

trying to find a way to count the days left for the next collection date (see Bin / Waste Collection)

the other component uses:

import datetime
import bin_collection_dates
from datetime import *

    today = date.today()
    future = bin_collection_dates.next_collection
    diff = future - today
    days_left = str(diff.days)
    print(days_left)

which is of no use (yet), but might be when adapted somehow?

maybe you can help? Right now im using the extra scrape sensor for afval_datum, but that doesn’t return a timestamp, but a string.

  - platform: scrape
    resource: !secret scrape_resource_date
    name: Afval Datum
    select: ".firstDate"
    scan_interval: 60

Would you know a way to get the timestamp for the next collect date?

0 Likes

#125

Hello,

Yesterday I installed this custom_component. :slight_smile:

The issue I have is the first pick up date showed up is in the new year, but today gft is picked up and next week pmd.

The days showed are right but I missed these 2.

0 Likes

#126

saw something related today: this day was GFT at first, but later this had disappeared…no more dates in 2018 left.

maybe Mijnafvalwijzer have edited their page to 2019, and 2018 dates are gone?

0 Likes

#127

Hi Marius,

Did you update to version 1.1.6 (15/12/2018)?
After I did the update, the problem you describe was solved…

Regards,
Henry

0 Likes

#128

Correct Henry. Version 1.1.6 also checks pickup dates for the upcoming year if no pickup dates are found in the current year.

0 Likes

#129

I`ll look into this after christmass…

I just did a simple test, and I already managed to add this functionality :+1:
I`ll publish the new release tomorrow.

0 Likes

#130

Yes, I am on 1.1.6

cool, Fijne Kerst natuurlijk!

if you have a chance, please do have a look how this is possible:

49

scrape sensor afval_datum sees the next date, but the component doesn’t apparently.

errors on the log:

Update for sensor.trash_tomorrow 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 114, in update
    self.data.update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 324, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/sensor/mijnafvalwijzer.py", line 181, in update
    trashType[name] = labelToday
TypeError: unhashable type: 'dict'

and

Update for sensor.trash_today 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 114, in update
    self.data.update()
  File "/usr/local/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 324, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/sensor/mijnafvalwijzer.py", line 181, in update
    trashType[name] = labelToday
TypeError: unhashable type: 'dict'
0 Likes

#131

Hi Marius,

I found out what the issue is causing the errors. When you browse to mijnafvalwijzer.nl with your postal code and housenumber, you probably can’t see pickup dates for 2019. When you for example browse this address:
https://www.mijnafvalwijzer.nl/nl/5146DG/16/, you’ll notice a tab with 2019 pickup dates. I`ll make a check if 2019 is available, if not then the pickup date will be set to none. I think I have some spare time Tonight.

0 Likes

#132

Cool, take it easy;-)

FYI today (afval_vandaag) works alright, which is a template sensor, made out of 2 scrape sensors:

  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.png' }}

  - platform: scrape
resource: !secret scrape_resource_date
name: Afval Datum
select: ".firstDate"
scan_interval: 60

  - platform: scrape
resource: !secret scrape_resource_type
name: Afval Soort
select: ".firstWasteType"
scan_interval: 60

which at least indicates the correct date is still in the 2018 database/page

but sensor.trash_today is unknown:

as is sensor.trash_tomorrow

0 Likes

#133

I just released a new version (1.1.7) with the following chages:

  • removed lables: labels wasn’t tested well enough and it broke some things (i`ll add labels later).
  • added the amount of days to the next pickup (feature request).
  • fixed a bug if json data for the upcoming year isn’t available (bug).
1 Like

#134

Hi

Updated, and new sensor is created. Value unknown though …

0 Likes

#135

That’s coorect since i don’t see any pickup dates in the future. I won’t add “0 days” until the next pick-up. I will make it Geen instead of Unknown if no future pickups are found. Somerhing for the next release…

0 Likes

#136

Maybe you can make te text for ‘unknown’, maintainable in the settings? Or is it an option already?

0 Likes

#137

cool.

I now see on the mijnafvalwijzer page (never go there since the component works so good…) there are no future dates listed in fact… which is silly of course.

maybe another error/bug: your component still list yesterdays date as pickup day for today: plastic. Even got a notification through my today pickup automation.

48

(that’s my own automation, you don’t use an automation for today, at 7 am? I don’t see it listed on the GitHub page for the component ?)

I’ve made 2 smaller and less complex automations you might want to try, evaluating either trash_today or trash_tomorrow for actioning:

  - alias: 'Afval morgen alt'
    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.trash_tomorrow')}} 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.trash_tomorrow')}} wordt morgen opgehaald!
          title: >
            Trash tomorrow:

  - alias: 'Afval vandaag alt'
    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.trash_today') != 'Geen'}}
    action:
      - service: notify.notify
        data_template:
          message: >
            Het is vandaag {{ now().strftime("%d %B") }}.
              {{states('sensor.trash_today')}} wordt vandaag 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.trash_today')}} wordt vandaag opgehaald!'
          title: >
            Trash today:

btw. here’s a small customization for the new sensor (using custom-ui):

sensor.trash_days_to_next_pickup:
  friendly_name: Days to next pickup
  templates:
    icon: >
      if (state === 0) return 'mdi:numeric-0-circle-outline';
      if (state === 1) return 'mdi:numeric-1-circle-outline';
      if (state === 2) return 'mdi:numeric-2-circle-outline';
      if (state === 3) return 'mdi:numeric-3-circle-outline';
      if (state === 4) return 'mdi:numeric-4-circle-outline';
      if (state === 5) return 'mdi:numeric-5-circle-outline';
      if (state === 6) return 'mdi:numeric-6-circle-outline';
      if (state === 7) return 'mdi:numeric-7-circle-outline';
      if (state === 8) return 'mdi:numeric-8-circle-outline';
      if (state === 9) return 'mdi:numeric-9-circle-outline';
      if (state > 9) return 'mdi:numeric-9-plus-circle-outline';
      return 'mdi:calendar-question';
0 Likes

#138

So, today the city of Oosterhout notified us that they will no longer provide paper Afvalkalenders and pushes us to mijnafvalwijzer.nl. I have got this component running on the frontpage in fully kiosk browser on a tablet on the ground floor. After explaining to #wife that the info in this component comes from afvalwijzer.nl she is fully reassured after a bit of panic :exploding_head:

I like to thank the authors and all those who contributed to this great component! It works great and does really add tot the WAF of HA :wink:

1 Like