Skip to content

Conversation

@eskerda
Copy link
Contributor

@eskerda eskerda commented Aug 21, 2025

Proposed change

According to #96764 and #85279 the main blocker on updating the citybikes component was not relying on a third party library.

This PR updates the component to use python-citybikes to fetch data and adds an extra ebikes field.

Ideally I would like to overhaul the component to bring it up in quality, but I figured this would be a good start without breaking changes.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

radius, UnitOfLength.FEET, UnitOfLength.METERS
)

client = CitybikesClient(user_agent=HA_USER_AGENT, timeout=REQUEST_TIMEOUT)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to add the user agent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous code using the aio_httpclient helper included HomeAssistant/... on the user agent, which was certainly useful for myself to realize this component existed. I added it again with the intention of keeping track of usage and maybe failures.

LMK if we should go with the default UA on python-citybikes, which would be python-citybikes/<version>.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait you work on/for city bikes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do maintain the Citybikes project and the API that this component uses :) But it's a common name, so not to be confused with any other Citi Bike.


async def async_refresh(self, now=None):
"""Refresh the state of the network."""
try:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only have things in the try block that can raise

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved some of the logic outside of the try block now. That said, unfortunately I am missing most of the intent of the original code and I am not sure what now does in this context. Let me know if we should do a bigger refactor here with a coordinator.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. But not in this PR :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good! I am happy to bring the component out from legacy in other PRs.

@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@home-assistant home-assistant bot marked this pull request as draft September 11, 2025 16:19
@eskerda eskerda marked this pull request as ready for review September 12, 2025 22:23
@home-assistant home-assistant bot requested a review from joostlek September 12, 2025 22:23
@f3ndot
Copy link
Contributor

f3ndot commented Sep 28, 2025

@eskerda I'm also looking to hoist the CityBikes integration out of legacy status. I'm working on #153172 and will wait until this PR merges so I can utilize the 3rd party API library. Thank you for your contributions 😄

@eskerda
Copy link
Contributor Author

eskerda commented Oct 8, 2025

@joostlek Is there anything left on my side for approving this PR? I see there are failing codecov checks. Not sure if I need to add any test?

Thanks!

@joostlek joostlek merged commit 8152a9e into home-assistant:dev Oct 9, 2025
47 of 48 checks passed
@eskerda eskerda deleted the ref-citybikes branch October 9, 2025 18:31
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants