Skip to content

Add free_ebikes attribute to citybikes provider sensor - #85279

Closed
mxr wants to merge 2 commits into
home-assistant:devfrom
mxr:patch-1
Closed

Add free_ebikes attribute to citybikes provider sensor#85279
mxr wants to merge 2 commits into
home-assistant:devfrom
mxr:patch-1

Conversation

@mxr

@mxr mxr commented Jan 6, 2023

Copy link
Copy Markdown
Contributor

Proposed change

This is a reimplementation of #82945. It adds the amount of free e-bikes to the sensor attributes. The reason it uses the attributes instead of creating a new sensor is to be consistent with where the other secondary values are stored (number of empty slots, etc).

The free ebikes value comes from the extras. For example:

$ curl -s http://api.citybik.es/v2/networks/citi-bike-nyc  | jq '[.network.stations[] | select(.extra.ebikes > 0)][0]'
{
  "empty_slots": 24,
  "extra": {
    "ebikes": 1,
    "has_ebikes": true,
    "last_updated": 1672975310,
    "payment": [
      "creditcard",
      "key"
    ],
    "payment-terminal": true,
    "renting": 1,
    "returning": 1,
    "slots": 39,
    "uid": "3328"
  },
  "free_bikes": 6,
  "id": "46a983722ee1f51813a6a3eb6534a6e4",
  "latitude": 40.795,
  "longitude": -73.9645,
  "name": "W 100 St & Manhattan Ave",
  "timestamp": "2023-01-06T03:38:14.678000Z"
}

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:

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
  • The code has been formatted using Black (black --fast 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.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant

home-assistant Bot commented Jan 6, 2023

Copy link
Copy Markdown
Contributor

Hi mxr

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

{vol.Optional(ATTR_UID): cv.string}, extra=vol.REMOVE_EXTRA
{
vol.Optional(ATTR_UID): cv.string,
vol.Optional(ATTR_FREE_EBIKES): cv.positive_int,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This integration is missing a library for the interface and data parsing code. We won't allow changes to this integration that involves that part of the code until it's been refactored to use a 3rd party library.

Please extract the device specific interface code and data parsing to a standalone library published on PyPI.

https://developers.home-assistant.io/docs/creating_component_code_review#4-communication-with-devicesservices

@MartinHjelmare

Copy link
Copy Markdown
Member

Since a different approach is needed, I'll close the PR now. Thanks for your willingness to contribute!

@mxr

mxr commented Jan 6, 2023

Copy link
Copy Markdown
Contributor Author

Understood, thanks for the quick review!

@github-actions github-actions Bot locked and limited conversation to collaborators Jan 7, 2023
@mxr
mxr deleted the patch-1 branch September 15, 2024 23:59
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.

2 participants