fix: graceful handling of unavailable sites/vehicles. #365
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.
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
ingenerate_car_objects
did not handle a vehicle being offline gracefully, and would fail the entire integration setup. The same was forgenerate_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.