Fix: Update to use new API for BANES#5600
Conversation
e488fae to
3118308
Compare
There was a problem hiding this comment.
Pull request overview
Updates the Bath & North East Somerset (bathnes.gov.uk) waste collection source to use the council’s newer API endpoints after the previous API became unavailable.
Changes:
- Switched collection lookups to the new
api.bathnes.gov.ukBinsAPI v2 “CollectionSummary” endpoint. - Updated address search to use the new
api.bathnes.gov.ukAddressesAPI v2 endpoint and adjusted UPRN resolution logic. - Updated waste type mapping/test case data to align with the new API’s
featureTypevalues.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
custom_components/waste_collection_schedule/waste_collection_schedule/source/bathnes_gov_uk.py
Outdated
Show resolved
Hide resolved
custom_components/waste_collection_schedule/waste_collection_schedule/source/bathnes_gov_uk.py
Outdated
Show resolved
Hide resolved
custom_components/waste_collection_schedule/waste_collection_schedule/source/bathnes_gov_uk.py
Outdated
Show resolved
Hide resolved
custom_components/waste_collection_schedule/waste_collection_schedule/source/bathnes_gov_uk.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Updates the Bath & North East Somerset (bathnes.gov.uk) waste-collection source to use the council’s newer api.bathnes.gov.uk endpoints now that the legacy API is unavailable.
Changes:
- Switched bin schedule retrieval to the new
CollectionSummary/{uprn}API endpoint. - Added address search via the new Addresses API and updated UPRN resolution logic accordingly.
- Introduced basic argument sanitization/validation and updated waste-type mapping to match the new API’s
featureTypevalues.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
custom_components/waste_collection_schedule/waste_collection_schedule/source/bathnes_gov_uk.py
Show resolved
Hide resolved
custom_components/waste_collection_schedule/waste_collection_schedule/source/bathnes_gov_uk.py
Outdated
Show resolved
Hide resolved
custom_components/waste_collection_schedule/waste_collection_schedule/source/bathnes_gov_uk.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the Bath & North East Somerset Council source implementation to use the newer api.bathnes.gov.uk endpoints now that the previous bins API is no longer available.
Changes:
- Switched collection lookups to
BinsAPI/v2/BartecFeaturesandSchedules/CollectionSummary/{uprn}. - Added address search via
AddressesAPI/v2/search/{postcode}/150/trueand argument sanitization/validation. - Updated waste type mappings and refreshed example test cases.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| r = requests.get(url, timeout=REQUEST_TIMEOUT) | ||
| r.raise_for_status() | ||
| if r.text.strip() == "": | ||
| raise Exception(f"Empty response from API for url: {url}") |
There was a problem hiding this comment.
The other sources raise Exception more commonly than RuntimeError and including the url was actually a previous co-pilot suggestion which I agree with for parity with raise_for_status. Given the context of the log the data here is not sensitive.
custom_components/waste_collection_schedule/waste_collection_schedule/source/bathnes_gov_uk.py
Outdated
Show resolved
Hide resolved
| raise SourceArgumentNotFoundWithSuggestions( | ||
| "housenameornumber", | ||
| self._housenameornumber, | ||
| [a["payment_Address"] for a in addresses], | ||
| [a["payment_Address"].split("|")[1] for a in addresses], | ||
| ) |
There was a problem hiding this comment.
I think this is acceptable as-is. We cannot realistically account for fundamental changes to the API.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Updates the Bath & North East Somerset source to use a new API as the old one is no longer available.