Garbage pickup date (mijnafvalwijzer.nl) custom_component

HI @xirixiz
maybe I missed it, but is this https://github.com/home-assistant/home-assistant/pull/23163 in any way related to your CC?

Hope this won’t interfere with the fine results we get with the CC, when I see there’s only a few monitored conditions being tracked in that PR…?

Ive linked this thread in the PR

Hi everyone, just wanted to share how my setup looks. I just went down the route of scraping a Google Calendar I made myself and used code already provided here. If anyone wants the images I use for the wheelie bins, let me know and I’ll attach them.

garbagepickup

1 Like

Since the upgrade to 0.92.x this one stopped working on my side. Anyone else with this problem?

Same for me

@gijsje I fixed it on my side by adding a empty __init.py__ in the afvalwijzer folder.

@xirixiz perhaps you can add it in the repo?

Long thread so i might have missed it. How do you add you city to the site? It says contact your ‘City Hall’ but that is a rather simple reply. It is not like i can walk into the office and say ‘please add to’ and they will go “sure, we get it”. (send a mail to my city anyway, i doubt it will have an effect though)

I think you need some luck it’s added.
As far as I know you can use the following two sites:
afvalwijzer.nl
afvalstoffendienstkalender.nl

I use the second one and can’t find my postalcode on the first. So perhaps you could try both. Next to that see if your ‘gemeente’ supplies some info, that how I found out this component was working for afvalstoffendienstkalender.nl as well.

Tried to email them. It is online for me for Leiden but its always ‘even’ and ‘uneven’ weeks. I mean i can remember easilly by looking at the street on the day itself but it would be nice to automate :slight_smile:

That’s why I’ve created version 3.0.9. It has the init.py file included.

When you use custom update version > 4.2.11 it should be updating with the init file included.

As I’ve added it to the custom updater configuration file:
https://raw.githubusercontent.com/xirixiz/Home-Assistant-Sensor-Afvalwijzer/master/custom_updater.json

Hope this helps.

Leiden doesn’t seem to use mijnafvalwijzer.nl or afvalstoffendienstkalender.nl. It’s a pity there are so much differences between gemeenten for trash pickup schedules. I cannot just create a simple component to serve them all unfortunately.

Sorry, I’d missed that.
See if I can configure the auto updater as well.

Appreciate the effort, ofcourse you should not make everything. City’s should just use the same methods. Like i said, i mailed them… you never know. Not that i ever missed my garbage, but that doesn’t stop me from automating it.

Hi efleming,
just saw your post and was wondering if you are willing so share your setup/config to help me out. I also want to use a google calendar because there is nothing available from my city. I did link the google calendar to HA and got the calendar items set up. I now see in my casew three entities names “calendar.garbagetype” in my setup, however I dont really understand how to go from here. I know I need sensors. I want to be able to show the next pick up date like you have and I want to be able to have an automation to get an alexa and ios notificataion the day before.
Your help would be greaatly appreciated.

Berni

Okay, so for each calendar you have (you’ve probably alread done this, but just in case) create your ‘appointments’ for the garbage that is being collected, (mine are recycling, general and green). The script below scrapes for the name but it doesn’t have to be exact from my trials.

This is the code I used in my configuration.yaml for one of the bins - just change the details to reflect the name of the calendar you’re looking to for each sensor:

#Recyling Bin Collection
  - platform: template
    sensors:
       recycling_pickup_day:
          friendly_name: Recycling Pickup Day
          value_template: >
            {% set pickupday = strptime(states.calendar['recycling'].attributes.start_time, "%Y-%m-%d %H:%M:%S").strftime("%A") %}
            {% set pickupday2 = strptime(states.calendar['recycling'].attributes.start_time, "%Y-%m-%d %H:%M:%S").strftime("%b %d, %Y") %}
            {% if as_timestamp(states.calendar.recycling.attributes.start_time) / 86400 - as_timestamp(now()) / 86400 == 0.0 %}
              - TODAY -
            {% elif as_timestamp(states.calendar.recycling.attributes.start_time) / 86400 - as_timestamp(now()) / 86400 == 1.0 %}
              TOMORROW
            {% elif as_timestamp(states.calendar.recycling.attributes.start_time) / 86400 - as_timestamp(now()) / 86400 >= 7.0 %}
               {{ (as_timestamp(states.calendar.recycling.attributes.start_time) / 86400 - as_timestamp(now()) / 86400) | int  }} days
            {% elif as_timestamp(states.calendar.recycling.attributes.start_time) / 86400 - as_timestamp(now()) / 86400 >= 2.0 %}
              {{ pickupday }}
            {% else %}
              TODAY
            {% endif %}  

As for getting a notification, that I can’t help you with, sorry, haven’t tried that yet.

Thank you so much, I’ll see where I get with that tonight. So just to clarify that code queries all the calendara items for the word recycling. So you have not set up the calendar items for the three garbage typs and use those?
This is my code for the caldendar:

- cal_id: 6********@group.calendar.google.com
  entities:
  - device_id: Waste Bin
    ignore_availability: true
    name: Waste Bin
    track: true
    search: Waste Bin
  - device_id: Paper
    ignore_availability: true
    name: Paper
    track: true
    search: Paper
  - device_id: Recycling
    ignore_availability: true
    name: Recycling
    track: true
    search: Recycling

I have three calendars, one for each type of bin.

So in my recycling calendar, I have a recycling appointment. And then for the green waste calendar, green waste appointment, etc cetera. I think you’ve got all the appointments in the one calendar? That could work too, but I went this way.

My calendar code looks like this.

- cal_id: **@group.calendar.google.com
  entities:
  - device_id: general_waste
    ignore_availability: true
    name: General Waste
    track: true`
- cal_id: ***@group.calendar.google.com
  entities:
  - device_id: green_waste
    ignore_availability: true
    name: Green Waste
    track: true
- cal_id: ***@group.calendar.google.com
  entities:
  - device_id: recycling
    ignore_availability: true
    name: Recycling
    track: true

Have been playing around wqith it and got it to work, except the dates are always one day short and on the day of the pick up the value of the sensor is “unknown”.
Somehow its substracting one day too many I think?

Your appointments in your calendar, are they all day appointments?

UPDATE 30min after this post: I restarted HA after I eliminated the ü in the friendly name. Now I get a value again but now ALL three garbage values are 1 day short again. The paper one is now showing 11 instead of 12 like it did 30min ago.

Original Post:
yes they are. Strange thing: Today, one day later the value for two sensors is now correct. So I put the script/code into the template editor to test it and the result is not the same as shown as sensor value. Attached you find 3 pics. One shows my calendar (dont mind that its in german :slight_smile: ) and you see a paper pick up on the 16th, thats 12 days from today. The second pic shows the sensor as displayed in the frontend and now it also shows 12 days. and the third pic shows the result I get when I put it in the template editor and there it says 11 days.

sensor%20value%20in%20lovelace
The “Restmüll” sensor still says unknown now and next pick up would be in 27 days. Maybe the ü is the problem in the freindly name? And is the other thing with the days maybe a time zone problem?

If your city is using a schedule like yours, perhaps you could use this:

or another solution is to generate a json file and use: