Bin / Waste Collection

Thanks for the scan interval point.
ive gone with this which does the job:

  - platform: scrape 
    name: worthing_refuse_bin
    resource: https://www.adur-worthing.gov.uk/bin-day/?brlu-selected-address=100061882207&return-url=%2Fbin-day%2F
    select: 'tr:nth-child(1) td:nth-child(3)' 
    scan_interval: 86400
    value_template: "{{ value.split('2019')[0] + '2019' }}"
  
  - platform: scrape 
    name: worthing_refuse_bin_next
    resource: https://www.adur-worthing.gov.uk/bin-day/?brlu-selected-address=100061882207&return-url=%2Fbin-day%2F
    select: 'tr:nth-child(1) td:nth-child(3)' 
    scan_interval: 86400
    value_template: "{{ value.split('2019')[1] + '2019' }}"

  - platform: scrape 
    name: worthing_recycling_bin
    resource: https://www.adur-worthing.gov.uk/bin-day/?brlu-selected-address=100061882207&return-url=%2Fbin-day%2F
    select: 'tr:nth-child(2) td:nth-child(3)' 
    scan_interval: 86400
    value_template: "{{ value.split('2019')[0] + '2019' }}"

  - platform: scrape 
    name: worthing_recycling_bin_next
    resource: https://www.adur-worthing.gov.uk/bin-day/?brlu-selected-address=100061882207&return-url=%2Fbin-day%2F
    select: 'tr:nth-child(2) td:nth-child(3)' 
    scan_interval: 86400
    value_template: "{{ value.split('2019')[1] + '2019' }}"

  - platform: scrape 
    name: worthing_garden_bin
    resource: https://www.adur-worthing.gov.uk/bin-day/?brlu-selected-address=100061882207&return-url=%2Fbin-day%2F
    select: 'tr:nth-child(3) td:nth-child(3)' 
    scan_interval: 86400
    value_template: "{{ value.split('2019')[0] + '2019' }}"

  - platform: scrape 
    name: worthing_garden_bin_next
    resource: https://www.adur-worthing.gov.uk/bin-day/?brlu-selected-address=100061882207&return-url=%2Fbin-day%2F
    select: 'tr:nth-child(3) td:nth-child(3)' 
    scan_interval: 86400
    value_template: "{{ value.split('2019')[1] + '2019' }}"
1 Like

Maybe try a scrape that gets all the data in one hit and template splits it.

Save 3 hits to the council. -but I guess the interval should help if set to just less than a week say.

hey! this is great
my format is:
Monday 10 Jun 2019

any help doing as you have done please? to convert this to days?

got it

- platform: template
    sensors:
      refuse_bin_in_days:
        value_template: >-
          {% set date_in = states.sensor.worthing_refuse_bin.state %}
          {% set bin = strptime((date_in), "%A %d %b %Y") %}
          {% set diff = as_timestamp(bin) - as_timestamp(now()) %}
          {% set days = (diff /86400) | int %}
          {% if days == 0 %}
            Today
          {% elif days == 1 %}
          Tomorrow
          {% else %}
          {{ days }} days
          {% endif %}

Yes that’s what I did, mine were slightly different date format and I added weeks too:

  value_template: >-
    {% set date_in = states.sensor.eyrc_next_green_bin.state|replace('\n', '') %}
    {% set bin = strptime((date_in), "%a, %d %B %Y") %}
    {% set diff = as_timestamp(bin) - as_timestamp(now()) %}
    {% set days = ((diff / 86400)+1) | int %}
    {% if days == 0 %}
      Today
    {% elif days == 1 %}
      Tomorrow
    {% elif days == 7 %}
      1 Week
    {% elif days == 14 %}
      2 Weeks
    {% else %}
      {{ days }} days
    {% endif %}
1 Like

Thanks never though of that, I do similar to this and noticed I get a refused response sometimes so I have now scraped all the data I need in one go and parsed it it HA. I think once daily should be OK. My council have a habit of changing around a bit

how would the scrape look for that sorry?

No probs, might not work with yours as your data is different but I just went back in the tree and removed the last 2 branches, div:nth-of-type(3) > div:nth-of-type(1) this gave me all the bins and all the dates like this:

ADDRESS REMOVED

Tue, 11 June 2019 

Tue, 18 June 2019 

Thu, 13 June 2019 

Open Calendar

OLD - individual bin

- platform: scrape
  resource: https://binscollections.eastriding.gov.uk/Output/Results?searchString=XXXX+XXXt&ButtonSearchTrial=Search
  select: ".er-bin-item-row-wrapper > div:nth-of-type(77) > div:nth-of-type(1) > div:nth-of-type(3) > div:nth-of-type(1)"
  name: EYRC Next Green Bin
  scan_interval: 3600

New - All bins

- platform: scrape
  resource: https://binscollections.eastriding.gov.uk/Output/Results?searchString=xxxx+xxxx&ButtonSearchTrial=Search
  select: ".er-bin-item-row-wrapper > div:nth-of-type(77) > div:nth-of-type(1)"
  name: EYRC Next Bins
  scan_interval: 86400

Then use these sensors and split them into individual bins:

green_bin_next:
  friendly_name: "EYRC Next Green Bin"
  value_template: "{{ states.sensor.eyrc_next_bins.state.split('\n')[13] }}"

blue_bin_next:
  friendly_name: "EYRC Next Blue Bin"
  value_template: "{{ states.sensor.eyrc_next_bins.state.split('\n')[20] }}"

brown_bin_next:
  friendly_name: "EYRC Next Brown Bin"
  value_template: "{{ states.sensor.eyrc_next_bins.state.split('\n')[27] }}"
3 Likes

You are fast ! nice work

nice work! thanks a lot :slight_smile:

hey there waste managers :slight_smile: i’m struggling to get my local authoritys’ system to scrape. it doesn’t seem to work like any of the other examples in this thread. can anyone spot the right way?

http://applications.rochdale.gov.uk/RefuseCollectionCalendar/Home/Index/

example postcode: OL16 3HA

FWIW i’ve emailed the council on a number of occasions asking why they can’t / suggesting that they offer ical. never had a response…

I’ve had a look and it doesn’t show next bin, just the calendar. It is probably possible to scrape the whole month and then use HA to work out which is the next bins.

My council (Ealing, UK) offers no ical, REST API or even an easily scrapable website (it creates a PDF).
So I used the google calendar approach here:

I created a new calendar for refuse collection and added repeating events for refuse, recycling, garden and food waste collection (either weekly or every 2 weeks). I will manually alter the events for seasonal changes such as Xmas as/when my council publishes their schedule (normally a few weeks before).
Since I already use node-red I pretty much reused the flow that is shared in the reddit post.

It works perfectly!

image

2 Likes

What are you using to display that? And can I have your bin images please? :slight_smile:

Sure here you go:

black

blue

green

I also did food waste caddy, but since this is collected every week I dont bother to display it.

food

For the lovelace card I use two custom cards:

  • vertical-style-card
  • button-card

Plus horizontal-stack

e.g.

cards:
  - cards:
      - entity: sensor.refuse_collection
        entity_picture: /local/images/refuse/black.png
        show_entity_picture: true
        show_icon: false
        show_state: true
        style:
          - border: 0px
          - box-shadow: 0px
        styles:
          card:
            - border: 0px
            - box-shadow: 0px
          name:
            - font-size: 10px
        type: 'custom:button-card'
      - entity: sensor.recycling_collection
        entity_picture: /local/images/refuse/blue.png
        show_entity_picture: true
        show_icon: false
        show_state: true
        style:
          - border: 0px
          - box-shadow: 0px
        styles:
          card:
            - border: 0px
            - box-shadow: 0px
          name:
            - font-size: 10px
        type: 'custom:button-card'
      - entity: sensor.garden_waste_collection
        entity_picture: /local/images/refuse/green.png
        show_entity_picture: true
        show_icon: false
        show_state: true
        style:
          - border: 0px
          - box-shadow: 0px
        styles:
          card:
            - border: 0px
            - box-shadow: 0px
          name:
            - font-size: 10px
        type: 'custom:button-card'
    type: horizontal-stack
style:
  border: true
  font_size: 24px
title: Refuse Collection
type: 'custom:vertical-style-card'
4 Likes

Could someone help me with a scrap i am still learning this and getting a bit stuck.
I used node red and http request h3 and i get the following just not able to get the dates.

image

https://www.braintree.gov.uk/info/200198/recycling_information_and_advice/1164/route_10_collection_dates

any help anyone could give would be great

Hi

I live in wakefield too, I dont suppose you would share your work please ?

thanks

Martyn

I am on ubuntu 18.04 server and have Node Red running successfully.

Does anyone know how to install PUP as it wont let us install from sudo apt-get install pup ?

I live in Wakefield and seen 1 user on here also uses it from the council website too but if some one would give me guidance, that would be appreciated.

image

thanks in advance

martyn

Wow what a wealth of information here. Ive managed to get so far but not been able to extract any useful information yet on dates etc. Was wondering if someone could help point me in the right direction.

My cancel site is https://apps.castlepoint.gov.uk/cpapps/index.cfm?fa=wastecalendar

By using chrome F12 I’ve found out my road id as 2757 and this url takes us there but not got any further: https://apps.castlepoint.gov.uk/cpapps/index.cfm?roadID=2757&fa=wastecalendar.displayDetails

Would be grateful for some advice.

1 Like

That’s as far as I got. The scraping is the big bit.

What OS are you using and have you tried what the original poster did to install PUP ?