Skip to content
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

fix: graceful handling of unavailable sites/vehicles. #365

Merged

Conversation

carleeno
Copy link
Contributor

This should fix a couple of related issues:

If get_vehicle_data failed for a TeslaException that wasn't a 408, it would try to return an unassigned variable. Now it will re-raise that "unexpected" exception to let the caller handle it.

Additionally the calls for get_vehicle_data in generate_car_objects did not handle a vehicle being offline gracefully, and would fail the entire integration setup. The same was for generate_energysite_objects for a very similar reason.

Now if the vehicle/site data is unavailable during setup, the device will still be added with the data dict empty. Each of the car/site classes are designed to handle an empty data dictionary, so this should be fine. From what I can tell, it's not really possible to NOT add a device that's in the vehicle list or site list without refactoring a lot of controller.py.

All of these cases are logged as warnings, as they don't break anything, but would be unusual/unexpected.

@alandtse alandtse merged commit 2daef7b into zabuldon:dev Nov 22, 2022
@alandtse
Copy link
Collaborator

Please note that we still need a verb after the fix:. I know it's weird, but it's consistent with other stuff like feat:

alandtse added a commit that referenced this pull request Nov 22, 2022
fix: handle unavailable sites/vehicles (#365)
@carleeno
Copy link
Contributor Author

Please note that we still need a verb after the fix:. I know it's weird, but it's consistent with other stuff like feat:

ahh thanks, that makes sense

@carleeno carleeno deleted the fix-variable-reference-before-assignment branch November 27, 2022 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants