- 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
- platform: scrape
resource: https://binscollections.eastriding.gov.uk/Output/Results?searchString=XXXX+XXX&ButtonSearchTrial=Search
select: ".er-bin-item-row-wrapper > div:nth-of-type(77) > div:nth-of-type(1) > div:nth-of-type(4) > div:nth-of-type(1)"
name: EYRC Next Blue Bin
scan_interval: 3600
- platform: scrape
resource: https://binscollections.eastriding.gov.uk/Output/Results?searchString=XXXX+XXX&ButtonSearchTrial=Search
select: ".er-bin-item-row-wrapper > div:nth-of-type(77) > div:nth-of-type(1) > div:nth-of-type(5) > div:nth-of-type(1)"
name: EYRC Next Brown Bin
scan_interval: 3600
Also used this to create a sensor to display number of days until each one is collected, one of these needed for each bin. Date comes from the scraper as “Mon, 19 April 2019” so had to do a bit of conversion (thanks again @lolouk44):
- platform: template
sensors:
green_bin_days:
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) | int %}
{% if days == 0 %}
Today
{% elif days == 1 %}
Tomorrow
{% else %}
{{ days }} days
{% endif %}
My bins just come every Monday for the general waste and then alternating weeks for green waste and recycling. Has anyone done anything simple like that just using dates? I hadn’t thought of it until I saw this thread so looking to piggy back off existing effort!
I did but then I was able to setup a scrape from my local council website
You can just use week numbers if you want something simple - then determine if week is odd or even
sorry all, been playing around for a while and cannot work out how to scrape info from my council (if thats the best thing here?)
note: they dont publish a calendar
If you right click on the web page and select view source, it will breakdown the page format for
Had a quick look and the title is held in object H3
So if you scrape “h3:nth-of-type(1)” is should return “Your next bin collections for BN14 9EL”
Then just work out what other fields you want after that, so your next scrape would be
“h3:nth-of-type(1) td:nth-of-type(3)” would give your grey bin collection date
Trouble with scrape is you can only scrape one field at a time
So to get 4 sensors, you would have to do 4 scrapes
thanks, the first one worked (h3:nth-of-type(1)), however the value for this is always “unknown”
select: “h3:nth-of-type(1) td:nth-of-type(4)”
mayker
(maykar (pronounced "maker" with a southern accent))
196
Thought I would share my setup for this. Fortunately a group from one of the tech schools in my city created an API for waste collection. I wanted to take it a bit further by making a readable version for my wife that displays Next Thursday's pickup is trash only. or Tomorrow's pickup includes recycling.. This template will include “next” if the day is 7 days away or greater and “today” or “tomorrow” when necessary.
The sensors used that I made from my city’s API:
states.sensor.trash.state returns trash pickup month-day-year. i.e. 1-6-2019
states.sensor.trash.state returns recycling pickup month-day-year. i.e. 1-6-2019
states.sensor.trash_day returns the pickup’s day of the week. i.e. Monday
- platform: template
sensors:
trash_day:
icon_template: >-
{% if states.sensor.trash.state == states.sensor.recycling.state %}
mdi:recycle
{% else %}
mdi:delete
{% endif %}
value_template: >-
{% set between = strptime(states.sensor.trash.state, '%m-%d-%Y') - strptime((''~now())[:10], '%Y-%m-%d') %}
{% set between = float((''~between)[:2]) %}
{% if between == '0:' %} # when less than a day difference between returns '0:'
{% set between = 0 %} # set to just '0' without the colon
{% endif %}
{% set day = states.sensor.trash_day %}
{% if between > 6 %}
{% set prefix = 'Next' %}
{% elif between < 1 %}
{% set day = 'Today' %}
{% elif between < 2 %}
{% set day = 'Tomorrow' %}
{% endif %}
{% if states.sensor.trash.state == states.sensor.recycling.state %}
{{prefix}} {{day}}'s pickup includes recycling.
{% else %}
{{prefix}} {{day}}'s pickup is trash only.
{% endif %}
I’m not sure if it’ll be useful to you folks or not, but inspired by the original post, I wrote a small HTTP server that scrapes the result of the Cheshire East bin collection site, caches and serves the result as an iCalendar file (.ics)
Using this, I can subscribe to the full year’s bin collection schedule using FastMail, Gmail, Outlook, or pretty much any other calendar application, but it will also play nicely with any existing Home Assistant calendar components.
Hi, I have tried and am unable to grab the data you require with my limited knowledge of scrape, not sure if its the way the web page is built or the fact that they are using a table within the web page, sorry