robbrad / UKBinCollectionData

UK Council Bin Collection Data Parser Outputting Bin Data as a JSON
MIT License
114 stars 75 forks source link

Broxtowe Borough Council Stopped Working #654

Closed bobbinz closed 4 months ago

bobbinz commented 4 months ago

Name of Council

Broxtowe Borough Council

Issue Information

There days ago the data stopped being collected for Broxtowe bins.

Unsure if it's just me at the moment or everyone!

Using Home Assistant as you can tell, I also have Selenium logs if need be.

All I have to do is try to load the integration or refresh it and the below error appears

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:350
integration: Sensor (documentation, issues)
First occurred: 18:09:53 (1 occurrences)
Last logged: 18:09:53

Error while setting up uk_bin_collection platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 318, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/uk_bin_collection/sensor.py", line 133, in _async_update_data
    data = await self.hass.async_add_executor_job(self.ukbcd.run)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/uk_bin_collection/uk_bin_collection/collect_data.py", line 96, in run
    return self.client_code(
           ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/uk_bin_collection/uk_bin_collection/collect_data.py", line 115, in client_code
    return get_bin_data_class.template_method(address_url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/uk_bin_collection/uk_bin_collection/get_bin_data.py", line 78, in template_method
    bin_data_dict = self.parse_data(
                    ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/uk_bin_collection/uk_bin_collection/councils/BroxtoweBoroughCouncil.py", line 81, in parse_data
    collection_date = datetime.strptime(
                      ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/_strptime.py", line 554, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/_strptime.py", line 333, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '' does not match format '%A, %d %B %Y'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 350, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/uk_bin_collection/sensor.py", line 75, in async_setup_entry
    await coordinator.async_config_entry_first_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in async_config_entry_first_refresh
    raise ex
homeassistant.exceptions.ConfigEntryNotReady: time data '' does not match format '%A, %d %B %Y''

Verification

Edit: fixed formatting!

bobbinz commented 4 months ago

Interestingly I think this might be a unique issue to me only as one of my bins has vanished and I requested a new one.

The next collection for one of them is currently blank so isn't in the right format as suggested by the error above.

I wonder if it could parse the error better and still do the remainder of the bins in the meantime?

bobbinz commented 4 months ago

Well something exciting happened today! My replacement bin arrived, the council updated the record and the script started working again!