Skip to content

Commit

Permalink
Add is_vehicle_tracking_enabled on Vehicle
Browse files Browse the repository at this point in the history
  • Loading branch information
rikroe committed Nov 29, 2021
1 parent 28fe969 commit 36b9755
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
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 charging control (weekly planner) is available."""
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

0 comments on commit 36b9755

Please sign in to comment.