Bin / Waste Collection


#101

no the google calendar component makes a sensor based on every calendar that is added to your account.
so if you have the google calendar in HA and you add the ical from your wastecollection to your account, you automaticly get a sensor that has the name from the ical.(or the name you give it in your settings)

if you already use google calendar, that way is simpler then adding a custom component. (or at least in my eyes)

the advantage is that you just get every other ical you add automaticly as a new sensor. (you dont need to add any other custom components)

the only disadvantage is that you only get the next event.


#102

Thanks for sharing the iCal method. Unfortunately my council doesn’t share this info.

Bit of a shame because I thought making this info publicly consumable would be the right thing to do.

I came unstuck with my cURL and css selector method because they recently changed their site layout, quick rewrite of my selector meant I was back in business. I have time to rewrite this as long as they have budget to keep changing their website :rofl:


#104

That website is horrible - and the following solution is also:

  1. Have a weekly cronjob on a Wednesday night to pull the latest week to a flat file - so you don’t hammer the Dorset site
    curl https://mapping.dorsetforyou.gov.uk/mylocal/viewresults/10091017024 > dorset.html

  2. Setup 3 command line sensors (one for each waste type

cat dorset.html | pup '.resultListItem' | grep -A 3 "Your next recycling" | head -n 4 |sed -n '3p' | awk '{$1=$1};1'

cat dorset.html | pup '.resultListItem' | grep -A 3 "Your next food" | head -n 4 |sed -n '3p' | awk '{$1=$1};1'

cat dorset.html | pup '.resultListItem' | grep -A 3 "Your next rubbish" | head -n 4 |sed -n '3p' | awk '{$1=$1};1'

Change the sensor color to match the Bin type

You could build some logic into Linux to only pull dates from the future with a further grep if you wanted.


#105

Thanks so much for your help - will give it a go!


#106

save yourself the trouble of a changing website.
until recently i also got no ical from my area.

but like in your area there was a printable schedule for the whole year.
at the end of the year they provide that for the next year.

because of the repaet in it it isnt that hard to save all dates that the waste is collected in an google calendar.
i used an excel spreadsheet where i did put all dates in and that can be imported in google calendar.
next year all i had to do is change the dates, based on the new list.

its about 30 to 60 minutes at the end of every year, but you probably spend more time if you try to keep track of that website.


#107

I have done this exact thing for mines, it’s a very similar schedule to the OPs. I have it shown on a lovelace panel and alerts to notify me via txt and voice throughout the house to remind me that it’s the day for the bin to go out and what bin(s) need to go out.


#108

Have to say that looks lovely. Do you have the Lovelace code that you used for this?


#109

I’ll try and get my code cleaned up enough for github soon, but in the meantime, it’s just a take on this card ‘https://sharethelove.io/picture-elements-cards/temperature-glance’ with the image and sensor entities changed.

I’ve basically gone with the same kind of hacky way you have to end up with 2 sensors, one for each (potential) bin that is to be collected, so sometimes I end up with the ‘unknown’ 2nd sensor too and they aren’t centred in my lovelace card anymore so my OCD doesn’t like it lol.


#110

I’ve been trying to do something with my local authority (Bradford Council) but they seem to have there data is some kinda strange database backend (eb). This is the end point they use:

ufs/COLLECTION_DATES.eb?ebd=0&ebp=10&ebz=1_XXXXXXXXXXXXXXX

I’ve tried a couple of web scraping options but the data needs to be searched first (via postcode) and that doesn’t seem to be acheable which the sites I’ve used.

Does anybody have any pointers for this?


#111

like i said a few days ago, save yourselve the trouble from trying to find a way to scrape it.
collect the data once a year, put it in an ical file and use that for your automations.


#112

That sounds like a good solution, however there are a few limitations I can see:

My local authority only release their schedule for a few months ahead not an entire year. The above method also doesn’t take into account any changes/cancellations of the collection.


#113

i dont know how its at your place but if its anything like here they change very little.
we get a new schedule every year, but i now before the schedule is there which dates it will be.

does it happen regularly that they change or cancel?
we never had a cancelation in 13 years. (and even if they did noone would know in advance)


#114

After much searching I decided to take your advice and integrate the Google Calendar solution:

00%20pm

As you can see if works well but one issue I have is getting it to display the date suffix ‘rd’, ‘th’, ‘nd’

This is how I’ve created the date output:

  waste_collection_date:
    friendly_name: 'Collection Date'
    value_template: '{{ as_timestamp(states.calendar.waste_collection.attributes.start_time) | timestamp_custom("%A %d") }}'
    icon_template: mdi:calendar-star

Does anyone have any ideas how to calculate the correct suffix based on a date?

http://strftime.org for reference.


Custom Jinja2 filters?
#115

Struggling to download the pup extension onto my Ubuntu install. Could someone clarify what the command is for this?


#116

i think you can only do something like this (sorry cant do it completely because i am bad with template):

{{if (as_timestamp(states.calendar.waste_collection.attributes.start_time) | timestamp_custom("%d") == 1)}}
 as_timestamp(states.calendar.waste_collection.attributes.start_time) | timestamp_custom("%A %d")st
{{elif (as_timestamp(states.calendar.waste_collection.attributes.start_time) | timestamp_custom("%d") == 2)}}
 as_timestamp(states.calendar.waste_collection.attributes.start_time) | timestamp_custom("%A %d")nd
{{elif (as_timestamp(states.calendar.waste_collection.attributes.start_time) | timestamp_custom("%d") == 3)}}
 as_timestamp(states.calendar.waste_collection.attributes.start_time) | timestamp_custom("%A %d")th
{{ end if}}

#117

Mmm thanks for the suggestion but its giving me an error. I’ll have a play with the template console and see what I can do.


#118

I found this on Stackoverflow but can’t get my head around how it would translate into a HA template:


#119

like i gave it returns a string, so you need to convert that to an int.
its probably not the simplest or nicest way, but i tested this:

{% if (as_timestamp(states.calendar.waste_collection.attributes.start_time)|timestamp_custom("%d")|int)==1 -%}
  st
{% elif (as_timestamp(states.calendar.waste_collection.attributes.start_time)|timestamp_custom("%d")|int)==2 %}
  nd
{% elif (as_timestamp(states.calendar.waste_collection.attributes.start_time)|timestamp_custom("%d")|int)==3 %}
  rd
{% else %}
  th
{%- endif %}

in the editor and it works.


#120

Wouldn’t that run into problems with 11st, 12nd and 13rd?


#121

Ok I think I’ve found a Jinja2 specific answer but not 100% it can be implemented as I don’t know that much about the templating system.