Add GPS direction to BMW ConnectedDrive device_tracker (#63744)

Co-authored-by: rikroe <rikroe@users.noreply.github.com>
This commit is contained in:
rikroe 2022-01-24 16:26:03 +01:00 committed by GitHub
parent 620991fef8
commit 2e25213101
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -8,6 +8,8 @@ from homeassistant.const import (
ATTRIBUTION = "Data provided by BMW Connected Drive"
ATTR_DIRECTION = "direction"
CONF_ALLOWED_REGIONS = ["china", "north_america", "rest_of_world"]
CONF_READ_ONLY = "read_only"
CONF_USE_LOCATION = "use_location"

View File

@ -17,7 +17,7 @@ from . import (
BMWConnectedDriveAccount,
BMWConnectedDriveBaseEntity,
)
from .const import CONF_ACCOUNT, DATA_ENTRIES
from .const import ATTR_DIRECTION, CONF_ACCOUNT, DATA_ENTRIES
_LOGGER = logging.getLogger(__name__)
@ -80,7 +80,9 @@ class BMWDeviceTracker(BMWConnectedDriveBaseEntity, TrackerEntity):
def update(self) -> None:
"""Update state of the device tracker."""
_LOGGER.debug("Updating device tracker of %s", self._vehicle.name)
self._attr_extra_state_attributes = self._attrs
state_attrs = self._attrs
state_attrs[ATTR_DIRECTION] = self._vehicle.status.gps_heading
self._attr_extra_state_attributes = state_attrs
self._location = (
self._vehicle.status.gps_position
if self._vehicle.is_vehicle_tracking_enabled