Add unique_id for BMW ConnectedDrive (#13888)

* Add unique_id for BMW ConnectedDrive

* Changed some comments
This commit is contained in:
Gerard 2018-04-15 05:15:52 +02:00 committed by Martin Hjelmare
parent 1c4da0c4a6
commit 9014e26845
3 changed files with 19 additions and 1 deletions

View File

@ -46,6 +46,7 @@ class BMWConnectedDriveSensor(BinarySensorDevice):
self._vehicle = vehicle
self._attribute = attribute
self._name = '{} {}'.format(self._vehicle.name, self._attribute)
self._unique_id = '{}-{}'.format(self._vehicle.vin, self._attribute)
self._sensor_name = sensor_name
self._device_class = device_class
self._state = None
@ -55,6 +56,11 @@ class BMWConnectedDriveSensor(BinarySensorDevice):
"""Data update is triggered from BMWConnectedDriveEntity."""
return False
@property
def unique_id(self):
"""Return the unique ID of the binary sensor."""
return self._unique_id
@property
def name(self):
"""Return the name of the binary sensor."""

View File

@ -38,6 +38,7 @@ class BMWLock(LockDevice):
self._vehicle = vehicle
self._attribute = attribute
self._name = '{} {}'.format(self._vehicle.name, self._attribute)
self._unique_id = '{}-{}'.format(self._vehicle.vin, self._attribute)
self._sensor_name = sensor_name
self._state = None
@ -49,6 +50,11 @@ class BMWLock(LockDevice):
"""
return False
@property
def unique_id(self):
"""Return the unique ID of the lock."""
return self._unique_id
@property
def name(self):
"""Return the name of the lock."""

View File

@ -52,6 +52,7 @@ class BMWConnectedDriveSensor(Entity):
self._state = None
self._unit_of_measurement = None
self._name = '{} {}'.format(self._vehicle.name, self._attribute)
self._unique_id = '{}-{}'.format(self._vehicle.vin, self._attribute)
self._sensor_name = sensor_name
self._icon = icon
@ -60,6 +61,11 @@ class BMWConnectedDriveSensor(Entity):
"""Data update is triggered from BMWConnectedDriveEntity."""
return False
@property
def unique_id(self):
"""Return the unique ID of the sensor."""
return self._unique_id
@property
def name(self) -> str:
"""Return the name of the sensor."""
@ -86,7 +92,7 @@ class BMWConnectedDriveSensor(Entity):
@property
def device_state_attributes(self):
"""Return the state attributes of the binary sensor."""
"""Return the state attributes of the sensor."""
return {
'car': self._vehicle.name
}