tesla: add odometer#3684
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds odometer support to the Tesla vehicle SoC module by extending the Tesla API data fetch and wiring the new value into the shared CarState.
Changes:
- Switch Tesla SoC fetch to use a new API call that also returns odometer and stores it in
CarState. - Adjust Tesla configuration type hints to use
Optional[...]for nullable parameters. - Store Tesla token
created_atas aninttimestamp.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/modules/vehicles/tesla/soc.py | Fetches odometer alongside SoC/range and returns it via CarState. |
| packages/modules/vehicles/tesla/config.py | Tightens nullability typing for token/configuration parameters. |
| packages/modules/vehicles/tesla/api.py | Adds odometer extraction from vehicle_data response; normalizes created_at type. |
Comments suppressed due to low confidence (1)
packages/modules/vehicles/tesla/api.py:103
- This PR removed/renamed
api.request_soc_range, but there is still a unit test (packages/modules/vehicles/tesla/soc_test.py) monkeypatchingapi.request_soc_range. Sincesoc.fetch()now callsapi.request_data(), the test will hit the real network unless the test is updated. To keep backwards compatibility (and keep existing tests/mocks working), consider restoring arequest_soc_range()wrapper and implementingrequest_data()in terms of it, while tolerating legacy mocks that return only 3 values (soc/range/timestamp).
def request_data(vehicle: int, token: TeslaSocToken) -> Tuple[float, int, float, int]:
vehicle_id = __get_vehicle_id(vehicle, token)
data_part = f"vehicles/{vehicle_id}/vehicle_data"
response = __request_data(data_part, token)
response = json.loads(response)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.