Bin / Waste Collection

Jamie - I know this post is a bit old now, but are you aware of GitHub - TomBrien/cardiffwaste-ha: A Home Assistant integration to provide sensors for waste collections in Cardiff, UK ?

1 Like

Yes I am using this addon and it works perfectly thank you

Is there an integration that can take this data or are you all using it manually?

Hi Guys @dp247

Sent me to this integration, but i am yet to do any python related stuff in HA,
Is there a basic set-up / Install guide to get this implemented, I know at the start there is info on how to run the scripts, but non on how to install or do the basic set-up?

do I need to use any tools like AppDaemon or pyscript.
sorry if this has been covered above but I had a search thew and everyone seems to know how to implement.

Thanks :slight_smile:

PS id be using the Leeds Council Lookup David did.

1 Like

I second this. I want to get this setup with Wakefield.

Added some basic instructions for running in a terminal here. If someone has a guide for setting up in HomeAssistant, feel free to message me or Rob and we can add it to the wiki :slight_smile:

I’ve got an absolute monstrosity of a Python script that is able to pull data from my local council (Sedgemoor) which switched to using the itouchvision site about 18 months or so ago.

Python is very much not my programming language of choice so its far from efficient or concise but I can attempt to clean it up a bit and comment the code if anyone wants to try and take it any further or integrate it into an existing solution.

There are a few bits that I’ve hard-coded in at the moment which I can anonymise, but I believe the bare minimum you can feed into it is UPRN and a Post Code. It’s not particularly quick either, as I found I had to load load three pages one after another to generate a session, grab some variables and then build payloads that the next page required.

@canalla450 - Thanks I have something similar that has now been working for the last 6 months, in my script you also need to enter the UPRN and a Post Code.

Mine is done using Appdaemon and Selenium / Chromium & Chromium-driver and because Selenium needs chromium it means that it cant be easily converted into a integration or hacs app, and the only alternative that I have found is to create an addon and include chromium in the docker build.

I also have another one that pulls my data in from EDF energy, but that also uses Selenium as well.

If anyone knows of a way to create a session and navigate multiple pages including logon etc without using Selenium I would be very interested in that.

You may have a bit more joy with this then as it was built around beautifulsoup to avoid the need for any graphical environment as it was built on a headless webserver. I believe it should be possible with some tidying to use it directly within HA, I’ve just not had the time to make it happen.

@crankshaft Its taken me a little while to get around to it, but I’ve added the code as a new issue to @Robbrad’s UKBinCollectionData repo (Sedgemoor - Working code provided · Issue #171 · robbrad/UKBinCollectionData · GitHub). Hopefully someone a little more competent can do the necessary on it!

1 Like

As a complete noob to Home Assistant, can anybody point me in the direction on how to go about setting this up? I got my council (Glasgow City Council) added to the project but don’t for the life of me know where to even begin implementing it in my HA server…

2 Likes

Hi, Nice to see someone else from Sedgemoor on here! How did you integrate this into your HA?

It’s a bit long winded and unnecessarily overcomplicated, but at the moment the script sits on a separate webserver and is called by a PHP script. It just generates a page of JSON which HA pulls via a REST sensor.

It was purely for historical reasons as I used to use OpenHAB before discovering HA and I used to push the dates into it from a basic python script. When I switched over to HA I didn’t have a clue how to do the equivalent but stumbled upon the REST sensor so that was the quick fix. The council page then stopped being easy to scrape when it moved from my Sedgemoor over to the SWP website and so it evolved from there.

In theory it should be possible to just run the python script directly from HA as I think it has all the packages available. I’ve just not had the time or inclination to try it as it currently works and I’m too scared to break it given how much of a nightmare it was to get working in the first place!

I probably should just pull my finger out and make the move as it’s currently pretty slow to run and does fail every once in a while!

Thanks for the reply. I used your script and made a command line sensor and it worked like an absolute charm!

  command: 'python3 /config/scripts/bincollection.py'
  name: bins
  scan_interval: 86400
  json_attributes:
    - GARDEN
    - RECYCLING
    - REFUSE

Well that was even simpler than I was expecting!

I’ve just created a new sensor based on your example and pointed the existing template sensors that were making the dates more human readable at it. It all works perfectly and is so much quicker and gone are the REST timeout warnings! Wished I’d done it ages ago! :flushed:

Glad you got it working, however you done all the heavy lifting with your python code! So thanks to you!

To make it more human readable, I changed the python code to move the numbers around but works well!

I’ve just raised a PR for this :grinning_face_with_smiling_eyes:

Is there any walk through of how to get this setup?

I understand that is quite an old thread but I have found it very useful to get as far as I’ve gotten.

I have raised an issue on the git to get my council (and some others that also share the same waste removal provider)

However I’m not sure I’m formatting the output data correctly (you can see this in the example output on the github issue).

I am passing that data into my sensors.yaml as below:

  - platform: command_line
    command: '/root/parseBinCollection.sh'
    name: BinCollectionType

Which just results in this in my dashboard
image

I’m quite new to home assistant so I know I’m missing something obvious.

Would be nice if someone can do YouTube tutorial how to easily implement this script in to HA.