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

Add is_vehicle_tracking_enabled on Vehicle #370

Merged
merged 2 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bimmer_connected/vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ def has_weekly_planner_service(self) -> bool:
"""Return True if charging control (weekly planner) is available."""
return self.attributes["capabilities"]["isChargingPlanSupported"]

@property
def is_vehicle_tracking_enabled(self) -> bool:
"""Return True if vehicle finder is enabled in vehicle."""
return self.attributes["capabilities"]["vehicleFinder"]["isEnabled"]

@property
def drive_train_attributes(self) -> List[str]:
"""Get list of attributes available for the drive train of the vehicle.
Expand Down
4 changes: 2 additions & 2 deletions bimmer_connected/vehicle_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def gps_position(self) -> Tuple[float, float]:
This only provides data, if the vehicle tracking is enabled!
"""
if self.is_vehicle_active:
_LOGGER.warning('Vehicle was moving at last update, no position available')
_LOGGER.info('Vehicle was moving at last update, no position available')
return None
if not self._remote_service_position and "vehicleLocation" not in self.properties:
_LOGGER.info("No vehicle location data available.")
Expand All @@ -224,7 +224,7 @@ def gps_heading(self) -> int:
This only provides data, if the vehicle tracking is enabled!
"""
if self.is_vehicle_active:
_LOGGER.warning('Vehicle was moving at last update, no position available')
_LOGGER.info('Vehicle was moving at last update, no position available')
return None

if not self._remote_service_position and "vehicleLocation" not in self.properties:
Expand Down
2 changes: 1 addition & 1 deletion test/responses/F11/vehicles_v2_bmw_0.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
},
"vehicleFinder": {
"executionMessage": "Find your vehicle now? Remote functions may take a few seconds.",
"isEnabled": true,
"isEnabled": false,
"isPinAuthenticationRequired": false
}
},
Expand Down
2 changes: 1 addition & 1 deletion test/responses/G21/json_export.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def test_drive_train(self):
"has_internal_combustion_engine",
"has_range_extender",
"has_weekly_planner_service",
"is_vehicle_tracking_enabled",
"lsc_type",
"name",
"to_json",
Expand Down
8 changes: 8 additions & 0 deletions test/test_vehicle.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,14 @@ def test_set_observer_position(self):
with self.assertRaises(ValueError):
vehicle.set_observer_position(12.1, None)

def test_get_is_tracking_enabled(self):
"""Test setting observer position"""
vehicle = get_mocked_account().get_vehicle(VIN_F11)
self.assertEqual(False, vehicle.is_vehicle_tracking_enabled)

vehicle = get_mocked_account().get_vehicle(VIN_F31)
self.assertEqual(True, vehicle.is_vehicle_tracking_enabled)

def test_available_attributes(self):
"""Check that available_attributes returns exactly the arguments we have in our test data."""
account = get_mocked_account()
Expand Down
9 changes: 5 additions & 4 deletions test/test_vehicle_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,12 @@ def test_parse_f31_no_position(self):

def test_parse_f11_no_position_vehicle_active(self):
"""Test parsing of F11 data with vehicle beeing active."""
status = get_mocked_account().get_vehicle(VIN_F48).status
vehicle = get_mocked_account().get_vehicle(VIN_F48)
status = vehicle.status

# self.assertTrue(status.is_vehicle_tracking_enabled)
with self.assertLogs(level=logging.WARNING):
self.assertTrue(status.is_vehicle_active)
self.assertTrue(vehicle.is_vehicle_tracking_enabled)
self.assertTrue(status.is_vehicle_active)
with self.assertLogs(level=logging.INFO):
self.assertIsNone(status.gps_position)
self.assertIsNone(status.gps_heading)

Expand Down