As an effort to learn node.js I’ve written myself a little app that downloads the bin collection dates and types (black, green, brown) for about three months from data mill north.
If anyone’s interested I could make it a little more robust and post it, don’t know how many people there are here from Leeds.
It’s not so much a script as a small app that sits in docker, I’ve just added configuration options and error checking and swapped out some dependencies that were not robust. Then it’s configured as a rest sensor in ha.
It’s simply parsing a csv file but the file is really big. Another option would be to download the file with wget parse it locally with a shell script and get the data that way. But then I wouldn’t have learnt any JavaScript …
But i haven’t been able to figure out how to emulate it. I was thinking I could do a scrape from that using the scrape sensor.
Another route is to reach out to @thomasforth at imactive. I believe he’s also head of data at Open Data Institute Leeds. I wonder if there’s an API we can use rather than pull that big xxxmb file each time?
I’m interested in this to add my Leeds bin collection day / colour etc… to my home assistant. One that updates with bank holidays, Christmas changes etc…
Trigger-based template sensors defined in configuration.yaml take the data from the webhook and create a sensor for each bin type’s next collection date, and these dates are shown on my dashboard
template:
- trigger:
- platform: webhook
allowed_methods:
- POST
- PUT
local_only: false
webhook_id: "MY INTERNAL WEBHOOK IDENTIFIER"
sensor:
- name: "Bins Next Black Collection"
unique_id: "'sensor.bins_next_black_collection"
icon: "mdi:calendar"
state: "{{ as_timestamp(trigger.json.black) | timestamp_custom('%A %d/%m/%Y', true) }}"
- trigger:
- platform: webhook
allowed_methods:
- POST
- PUT
local_only: false
webhook_id: "MY INTERNAL WEBHOOK IDENTIFIER"
sensor:
- name: "Bins Next Brown Collection"
unique_id: "'sensor.bins_next_brown_collection"
icon: "mdi:calendar"
state: "{{ as_timestamp(trigger.json.brown) | timestamp_custom('%A %d/%m/%Y', true) }}"
- trigger:
- platform: webhook
allowed_methods:
- POST
- PUT
local_only: false
webhook_id: "MY INTERNAL WEBHOOK IDENTIFIER"
sensor:
- name: "Bins Next Green Collection"
unique_id: "'sensor.bins_next_green_collection"
icon: "mdi:calendar"
state: "{{ as_timestamp(trigger.json.green) | timestamp_custom('%A %d/%m/%Y', true) }}"
Automation runs daily and checks if the next collection dates stored in the sensors are tomorrow - if they are, it sends a notification in the evening to my phone to take the bin(s) out