UKBinCollectionData icon indicating copy to clipboard operation
UKBinCollectionData copied to clipboard

Calendar setup async_config_entry_first_refresh causing unavailable sensors

Open pwnflakes opened this issue 5 months ago • 1 comments

Home Assistant Version

2025.7.4

Installation Method

Using HACS

Name of Council (if relevant)

North Hertfordshire

Issue Information

I've been scratching my head at this issue for a few days but I have some kind of fix, unsure if others are encountering this. I have portainer running as a HA addon hosting the Selenium chromium instance, and the latest version of the UKBinCollectionData running. When I set up the integration, whatever value is set in the 'time in seconds for how long the sensor should wait for data' field -- is how long my integration will have data for all entities of each sensor after the initial setup, and the Calendar Devices are not created. So the initial pull of data from my council is working and populates all 6 entities on all bin sensors, however after a minute all but the 'Home ' entity has been changed to Unavailable, I believe the one that remains is set to report its last known state so stays despite the issue.

They start off looking normal like this first sensor on the left, then end up looking like the second one after 60 seconds (or whatever's set for the timeout)

Image

I repomix'd the repo and threw it at Gemini with some logs and it suggested commenting out line 131 in UKBinCollectionData/custom_components/uk_bin_collection/calendar.py. #await coordinator.async_config_entry_first_refresh()

I made that change and tested it, and now my bin sensors retain all their values past the timeout value set during setup, and the respective Calendar Device for each bin was created, which hadn't been created before. I'm not sure if there's any known cause to this that can be fixed without altering code here as I can only see a few issues about Unavailable entities but they seem potentially unrelated. Could there be something else in my setup causing this?

I tried a few things before this, like restarting the selenium container after the first sync but before 60s elapsed (immediately after stopping the container all values went to Unavailable), running the selenium container on my PC to see if it was just my Pi not keeping up in some way, that didn't help though. It also didn't help that my council has been doing some odd things with their bin lookup page.

When I found this project a few days ago, the script for my council wasn't working even standalone -- because they served the data on the page in a slightly different way. After entering postcode no dropdown was presented, and you just had to click search, then a table was shown of all addresses, with many rows showing each addresses dates. Now though, it seems they have returned to what the NorthHertfordshireDistrictCouncil.py script expects with a dropdown showing, and the page format is for one address and that's all working fine.

Last little quirk though a bit irrelevant, I noticed whilst messing with this yesterday that apparently my council's page for this can be a bit flaky -- many times that I was filling in the form manually, it was taking 90s+ to load and it wasn't showing all 4 bins, and sometimes showed none, seems they fixed that this morning though and now it's responsive and showing all bins.

Thanks for your work on this project, awesome that it's pretty much majority UK coverage, looking at the map!

Verification

  • [x] I searched for similar issues at https://github.com/robbrad/UKBinCollectionData/issues?q=is:issue and found no duplicates
  • [x] If trying to add a specific council, I've checked it is listed as working at https://robbrad.github.io/UKBinCollectionData/3.12/
  • [x] I have provided a detailed explanation of the issue as well as steps to replicate the issue
  • [x] I understand that this project is run by volunteer contributors therefore completion of this issue cannot be guaranteed

pwnflakes avatar Aug 05 '25 18:08 pwnflakes