0Bin collections in Home Assistant

I’ve been devel­op­ing my Home Assist­ant based smarthome setup for around a year now (since leav­ing SmartTh­ings) and after an ini­tial steep learn­ing curve I’ve been veyr happy with home assist­ant so I have star­ted work­ing to expand the things it does as I am con­if­dent it offers a long term basis for my smarthome. One thing I wanted to add was bin col­lec­tion data to remind me which bin is due when. As I live in Shef­field I needed to pull this data from the loc­al author­it­ies out-sources pro­vider (veolia). The fol­low­ing details how I did this, build­ing very much on the work of oth­ers who have done it already for oth­er regions

Update 10-Aug-2022

I’ve tweaked the script to make it com­pat­ible with home assist­ant after the switch to Python 3

Update 20-Dec-2021

I’ve made a change to both ths bash script AND the tem­plate — the first to make sure required pack­ages are avail­able and the second to fix a break­ing change made by recent releases of home assistant

I used a script which i mod­i­fied from vari­ous examples on a HA sup­port thread by Rob­Brad. For this script to run I needed to install the beau­ti­ful­soup mod­ule on home-assistant.

Add a script

  • I use the ‘Samba Share’ super­visor addon to access my home assist­ant files dir­ectly from my win­dows PC — unless you already have a pre­ferred access meth­od I recom­mend doing the same
  • browse to \\ha-ip-address\config
  • cre­ate a python-scripts folder
  • Cre­ate a new python script in this folder — I called mine bin_collection.py
  • Insert the fol­low­ing script
  • You will need to replace the ############ with the unique num­ber for your prop­erty which I will explain how to get in the next step

Get your unique address

  • Browse to https://wasteservices.sheffield.gov.uk/property/
  • Enter your post code and select your address from the list
  • Make a note of the new url. Use it in the url line in the script above — the only part you will need to change is the 12 digit num­ber at the end

Call your script from configuration.yaml

  • A simple entry in configuration.yaml is all that is needed to make the script run
  • You may want to adjust the fre­quency of the run. Mine runs once per day.

Create entities for each type of bin using configuration.yaml

  • Imme­di­ately under the above sec­tion (so still under the sensor: sec­tion) add the following

Display the results on the front end

  • To show the res­ults on the front end simply add a card with the 3 sensors on it (spe­cific­ally sensor.black_bin, sensor.blue_bin, and sensor.brown_bin)
  • Note you may need to restart home assist­ant to load the new sensors you added to configuration.yaml

Found this useful? Please do let us know by dropping a comment below. If you would like to subscribe please use the subscribe link on the menu at the top right. You can also share this with your friends by using the social links below. Cheers.

Leave a Reply