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
Allow older vehicles to sleep in Teslemetry #117229
base: dev
Are you sure you want to change the base?
Conversation
@@ -62,21 +65,42 @@ def __init__( | |||
) | |||
self.api = api | |||
self.data = flatten(product) | |||
self.pre2021 = product["vin"][9] <= "L" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense for the "age check" to live in the library instead?
Seems a bit weird to parse the VIN in the coordinator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I'll add this line as a prop in the library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still here?
@coderabbitai review |
WalkthroughThe update introduces enhancements to the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (1)
homeassistant/components/teslemetry/coordinator.py (1)
Line range hint
53-104
: Effectively handles sleep logic for pre-2021 vehicles. Consider moving VIN parsing to the library for cleaner separation of concerns.
|
||
async def _async_update_data(self) -> dict[str, Any]: | ||
"""Update vehicle data using Teslemetry API.""" | ||
|
||
self.update_interval = VEHICLE_INTERVAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're already setting this in __init__
?
@@ -4,7 +4,7 @@ | |||
"id": 1234, | |||
"user_id": 1234, | |||
"vehicle_id": 1234, | |||
"vin": "VINVINVIN", | |||
"vin": "LRWXF7EK4KC700000", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a new car instead of modifying the existing (so there's another set of tests specifically for "old" cars?
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Proposed change
Tesla vehicles manufactured before 2021 cannot sleep if they are polled by API constantly. This PR adds logic to the coordinator to introduce a 15 minute wait after 15 minutes in inactivity. This 15 minute break is enough time to let the vehicle sleep, and then the coordinator can revert back to frequent polling so it knows when the vehicle wakes up.
The age of the vehicle is determined the 10th character of the VIN, as this is a code for the year it was manufactured.
Library bump: Teslemetry/python-tesla-fleet-api@v0.4.9...v0.5.12
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: