-
Notifications
You must be signed in to change notification settings - Fork 82
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
Separate getting full, selective and location data for vehicles #153
Conversation
Addresses changes in how vehicle location data is provided after late 2023 vehicle software updates. Retains get_vehicle_data() as the method to get all vehicle data to prevent breaking changes. Updates version to 2.10.0 as it the initial fix for the location changes didn't increment to 2.9.0 Adds two additional endpoints to teslapy/endpoints.json: VEHICLE_BASIC_DATA: gets only basic vehicle data. VEHICLE_LOCATION_DATA: basic vehicle_state and location_data. Updates VEHICLE_DATA to get all endpoints. Adds two methods to the Vehicle Class to use the new endpoints: get_vehicle_basic_data(): Get only basic vehicle data. get_vehicle_location_data(): Get basic vehicle data, and location data. Adds two new flags to CLI: -B --basic: Get only basic vehicle data -G --location: Get current location (GPS) data Updates readme.
Closing this as I didn't update the version in setup.cfg, so doing additional tests and making sure I didn't miss anything else. Will resubmit when I'm not sleepy. |
@robharman thanks for taking the time to create this pull request. You can use 2.9.0 for the new version, as I didn't took the time to do so. Like the initial fix, you can put the parameters in the Python code. The endpoint file can be left untouched. I try to keep this file consistant with the endpoints.json file found in the Android distribution. |
Implements feedback in original pull request: tdorssers#153 (comment) Reverts endpoints.json to previous version for Android consistency: remove VEHICLE_BASIC_DATA remove VEHICLE_LOCATION_DATA Update __init__ to include endpoints in Vehicle Class methods - get_vehicle_data(): all endpoints - location_data, charge_state; climate_state, vehicle_state, gui_settings, vehicle_config. - get_vehicle_basic_data(): no extra endpints. - get_vehicle_location_data(): only location_data and basic data. Set version number to 2.9.0.
Updates Vehicle Class: Removes get_vehicle_basic_data() Updates get_vehicle_data() to allow selection of individual endpoints, defaults to all endpoints. Updates get_vehicle_location_data(): - Adds optional location data max_age in seconds. Defaults to 300 (five minutes). - Updates and cleans up logic to prevent issues with missing data if it ages out in persistent connections. - Fix recursion error when vehicle was online but doesn't come back online for subsequent requests. Minor fixes: - Swaps most string formatting with fStrings, not panel ones since I can't test panel changes without a panel, and not the conversion ones since fStrings are less readable there. - Reflows lines over 80 chars, with same panel exception, most significantly in Vechicle.decode_vin() - Minor linting/spacing changes
Thanks for the feedback! I updated this to include your advice and cleaned up get_location_data() as I found that long-running sessions were having issues when the location data had been removed from the cache and the vehicle was unreachable. I also made some minor linting edits in the final version. |
Thanks Rob for these changes. Using format strings breaks Python 2.7 support and some Raspberry Pi users are probably still using that. So either we drop 2.7 or revert the fStrings. I tend to revert it. |
Makes sense for the backward compatibility, I can revert as well and resubmit later this week, but not sure if there's any point. Looking at the API change announcements, which I didn't realize had already been flagged in #150 when I made this PR, from Tesla make it look like the command functionality in TeslaPy is going to stop working soonish anyhow. Overhauling TeslaPy to work with the new Vehicle command API or through the http proxy is likely going to be a lot of work for you, so fiddling with this may not be worth your time here. Feel free to close this if it's not going to help in the long-run. If you don't close it, I'll update my PR this week and submit. Either way, thanks for making my life easier for the last two years with this project! :) edit: phrasing because I sounded ungrateful. |
This change adds the ability to query individual vehicle data endpoints, with all endpoints as default, and adds a new method to directly get location data, and ensure it's ~recent. Seeks to lessen vehicle location requests when they are not needed.
Updates Vehicle.get_vehicle_data():
- Selectively specify individual endpoints to query
- Defaults to all endpoints to prevent breaking changes
Adds Vehicle.get_vehicle_location_data(max_age=300):
- Queries location_data api endpoint to get location data if unavailable.
- Wakes vehicle and gets updated location information if the cached data is older than
max_age
secondsAdds two new flags to CLI:
-B --basic: Get only basic vehicle data
-G --location: Get current location (GPS) data
Minor changes:
- Swaps most string formatting with fStrings, not panel ones since I
can't test panel changes without a panel, and not the conversion
ones since fStrings are less readable there.
- Reflows lines over 80 chars, with same panel exception, most
significantly in Vechicle.decode_vin()
- Minor linting/spacing changes
- Updates version to 2.9.0
- Updates readme