Skip to content

Commit

Permalink
Fix device tracker & vehicle finder service
Browse files Browse the repository at this point in the history
  • Loading branch information
rikroe committed Nov 26, 2021
1 parent cb5af69 commit 23d295a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
12 changes: 8 additions & 4 deletions custom_components/bmw_connected_drive/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,10 @@ def setup_account(
password: str = entry.data[CONF_PASSWORD]
region: str = entry.data[CONF_REGION]
read_only: bool = entry.options[CONF_READ_ONLY]
use_location: bool = entry.options[CONF_USE_LOCATION]

_LOGGER.debug("Adding new account %s", name)

pos = (
(hass.config.latitude, hass.config.longitude) if use_location else (None, None)
)
pos = (hass.config.latitude, hass.config.longitude)
cd_account = BMWConnectedDriveAccount(
username, password, region, name, read_only, *pos
)
Expand Down Expand Up @@ -251,6 +248,13 @@ def execute_service(call: ServiceCall) -> None:
function_call = getattr(vehicle.remote_services, function_name)
function_call()

if call.service in [
"find_vehicle",
"activate_air_conditioning",
"deactivate_air_conditioning",
]:
cd_account.update()

if not read_only:
# register the remote services
for service in _SERVICE_MAP:
Expand Down
12 changes: 1 addition & 11 deletions custom_components/bmw_connected_drive/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ async def async_setup_entry(

for vehicle in account.account.vehicles:
entities.append(BMWDeviceTracker(account, vehicle))
if not vehicle.status.is_vehicle_tracking_enabled:
_LOGGER.info(
"Tracking is (currently) disabled for vehicle %s (%s), defaulting to unknown",
vehicle.name,
vehicle.vin,
)
async_add_entities(entities, True)


Expand Down Expand Up @@ -81,8 +75,4 @@ def update(self) -> None:
"""Update state of the decvice tracker."""
_LOGGER.debug("Updating device tracker of %s", self._vehicle.name)
self._attr_extra_state_attributes = self._attrs
self._location = (
self._vehicle.status.gps_position
if self._vehicle.status.is_vehicle_tracking_enabled
else None
)
self._location = self._vehicle.status.gps_position
2 changes: 1 addition & 1 deletion custom_components/bmw_connected_drive/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "BMW Connected Drive",
"version": "20211117.3",
"documentation": "https://www.home-assistant.io/integrations/bmw_connected_drive",
"requirements": ["bimmer_connected==0.8.3.0b1"],
"requirements": ["bimmer_connected==0.8.3.0b4"],
"codeowners": ["@gerard33", "@rikroe"],
"config_flow": true,
"iot_class": "cloud_polling"
Expand Down

0 comments on commit 23d295a

Please sign in to comment.