Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'strptime() argument' Issue #1048

Closed
4 tasks done
andywaddy opened this issue Nov 24, 2024 · 4 comments · Fixed by #1056
Closed
4 tasks done

'strptime() argument' Issue #1048

andywaddy opened this issue Nov 24, 2024 · 4 comments · Fixed by #1056
Labels
bug Something isn't working

Comments

@andywaddy
Copy link

Name of Council

Blackburn Council

Issue Information

I've had this working previously for the past year (thank you for your efforts), but since 23rd Nov, it's been showing a 'TypeError: strptime() argument 1 must be str, not None' error and entities become unavailable. Integration constantly attempts to reload itself. Had a quick look on the council's website to see if anything has changed but couldn't see anything different. Double checked UPRN and made sure my Standalone Chrome (running inside Proxmox) is all good.

Provided error from Log below:

Logger: custom_components.uk_bin_collection
Source: custom_components/uk_bin_collection/init.py:250
integration: UK Bin Collection Data (documentation, issues)
First occurred: 00:01:16 (338 occurrences)
Last logged: 07:18:00

[UKBinCollection] Unexpected error: strptime() argument 1 must be str, not None
Traceback (most recent call last):
File "/config/custom_components/uk_bin_collection/init.py", line 250, in _async_update_data
data = await asyncio.wait_for(
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/asyncio/tasks.py", line 520, in wait_for
return await fut
^^^^^^^^^
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 101, in run
return self.client_code(
^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/uk_bin_collection/uk_bin_collection/collect_data.py", line 121, 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 61, in template_method
bin_data_dict = self.get_and_parse_data(this_url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/uk_bin_collection/uk_bin_collection/get_bin_data.py", line 82, in get_and_parse_data
bin_data_dict = self.parse_data(page, url=address_url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/uk_bin_collection/uk_bin_collection/councils/BlackburnCouncil.py", line 73, in parse_data
next_collection_date = datetime.strptime(
^^^^^^^^^^^^^^^^^^
TypeError: strptime() argument 1 must be str, not None

Verification

  • I searched for similar issues at https://github.com/robbrad/UKBinCollectionData/issues?q=is:issue and found no duplicates
  • I have checked my address/postcode/UPRN works on the council's website
  • I have provided a detailed explanation of the issue as well as steps to replicate the issue
  • I understand that this project is run by volunteer contributors therefore completion of this issue cannot be guaranteed
@andywaddy andywaddy added the bug Something isn't working label Nov 24, 2024
@m26dvd
Copy link
Contributor

m26dvd commented Nov 26, 2024

If you go to the the following URL and substitute your UPRN in, do you get a response with dates?

https://mybins.blackburn.gov.uk/api/mybins/getbincollectiondays?uprn=XXXXXXX&month=11&year=2024

@andywaddy
Copy link
Author

Hi, yes, the below is what is returned for my UPRN. Redacted my real address at the bottom for obvious reason.

{
"BinCollectionDays": [
null,
null,
null,
null,
null,
null,
[
{
"Id": 0,
"BinType": "Burgundy 140L (refuse bin)",
"IsCommunal": false,
"LastScheduledCollectionDate": null,
"NextScheduledCollectionDate": "2024-12-05",
"DisplayStyle": "#800020",
"CollectionDate": "2024-11-07"
}
],
null,
[
{
"Id": 0,
"BinType": "Brown 240L bin (greenwaste bin)",
"IsCommunal": false,
"LastScheduledCollectionDate": null,
"NextScheduledCollectionDate": null,
"DisplayStyle": "#b5651d",
"CollectionDate": "2024-11-09"
}
],
null,
null,
null,
null,
[
{
"Id": 0,
"BinType": "Blue 240L (paper and cardboard bin)",
"IsCommunal": false,
"LastScheduledCollectionDate": null,
"NextScheduledCollectionDate": "2024-12-12",
"DisplayStyle": "blue",
"CollectionDate": "2024-11-14"
}
],
null,
null,
null,
null,
null,
null,
[
{
"Id": 0,
"BinType": "Burgundy 140L (refuse bin)",
"IsCommunal": false,
"LastScheduledCollectionDate": null,
"NextScheduledCollectionDate": "2024-12-05",
"DisplayStyle": "#800020",
"CollectionDate": "2024-11-21"
}
],
null,
[
{
"Id": 0,
"BinType": "Brown 240L bin (greenwaste bin)",
"IsCommunal": false,
"LastScheduledCollectionDate": null,
"NextScheduledCollectionDate": null,
"DisplayStyle": "#b5651d",
"CollectionDate": "2024-11-23"
}
],
null,
null,
null,
null,
[
{
"Id": 0,
"BinType": "Grey 240L (glass, tins and plastics bin)",
"IsCommunal": false,
"LastScheduledCollectionDate": null,
"NextScheduledCollectionDate": "2024-11-28",
"DisplayStyle": "grey",
"CollectionDate": "2024-11-28"
}
],
null,
null
],
"FullAddress": "xx, xxxxx xxxx, xxxx, Blackburn, BB2 xxx"

Cheers for the help, always appreciated.
Andy

@m26dvd
Copy link
Contributor

m26dvd commented Nov 27, 2024

@andywaddy Thanks! I can see what the problem is - your brown bin has a null "NextScheduledCollectionDate"

I've added some error handling and will release a new version shortly!

@andywaddy
Copy link
Author

andywaddy commented Nov 27, 2024

@andywaddy Thanks! I can see what the problem is - your brown bin has a null "NextScheduledCollectionDate"

I've added some error handling and will release a new version shortly!

Wicked, thanks again. Top work! 🙂

I totally forgot the last brown bin (garden) collection was last week, so the error and your explanation makes sense now 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants