mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix BMW device tracker toggling state if vehicle tracking is disabled (#12999)
* if tracking is disabled, the position is not set in the device tracker. This fixes an issue with a toggling vehicle state. * removed useless attributes
This commit is contained in:
parent
6314aabc6f
commit
979a8f8772
@ -36,16 +36,20 @@ class BMWDeviceTracker(object):
|
||||
self.vehicle = vehicle
|
||||
|
||||
def update(self) -> None:
|
||||
"""Update the device info."""
|
||||
"""Update the device info.
|
||||
|
||||
Only update the state in home assistant if tracking in
|
||||
the car is enabled.
|
||||
"""
|
||||
dev_id = slugify(self.vehicle.name)
|
||||
|
||||
if not self.vehicle.state.is_vehicle_tracking_enabled:
|
||||
_LOGGER.debug('Tracking is disabled for vehicle %s', dev_id)
|
||||
return
|
||||
|
||||
_LOGGER.debug('Updating %s', dev_id)
|
||||
attrs = {
|
||||
'trackr_id': dev_id,
|
||||
'id': dev_id,
|
||||
'name': self.vehicle.name
|
||||
}
|
||||
|
||||
self._see(
|
||||
dev_id=dev_id, host_name=self.vehicle.name,
|
||||
gps=self.vehicle.state.gps_position, attributes=attrs,
|
||||
icon='mdi:car'
|
||||
gps=self.vehicle.state.gps_position, icon='mdi:car'
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user