Update to new "b2vapi" of BMW ConnectedDrive (#13305)
* updated to new "b2vapi" of bimmer_connected * updated requirements_all.txt * updated 2 more vehicle names after rebase * cleanup of import statements * found one more broken name... * removed unused constant * cleanup of import statements 2
This commit is contained in:
1 parent
8bd5f66c57
commit
4d52875229
6 files changed
+44
-37
No files matched your search
@@ -4,8 +4,8 @@ Reads vehicle status from BMW connected drive portal.
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/sensor.bmw_connected_drive/
|
||||
"""
|
||||
import logging
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
from homeassistant.components.bmw_connected_drive import DOMAIN as BMW_DOMAIN
|
||||
from homeassistant.helpers.entity import Entity
|
||||
@@ -51,7 +51,7 @@ class BMWConnectedDriveSensor(Entity):
|
||||
self._attribute = attribute
|
||||
self._state = None
|
||||
self._unit_of_measurement = None
|
||||
self._name = '{} {}'.format(self._vehicle.modelName, self._attribute)
|
||||
self._name = '{} {}'.format(self._vehicle.name, self._attribute)
|
||||
self._sensor_name = sensor_name
|
||||
self._icon = icon
|
||||
|
||||
@@ -88,19 +88,19 @@ class BMWConnectedDriveSensor(Entity):
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes of the binary sensor."""
|
||||
return {
|
||||
'car': self._vehicle.modelName
|
||||
'car': self._vehicle.name
|
||||
}
|
||||
|
||||
def update(self) -> None:
|
||||
"""Read new state data from the library."""
|
||||
_LOGGER.debug('Updating %s', self._vehicle.modelName)
|
||||
_LOGGER.debug('Updating %s', self._vehicle.name)
|
||||
vehicle_state = self._vehicle.state
|
||||
self._state = getattr(vehicle_state, self._attribute)
|
||||
|
||||
if self._attribute in LENGTH_ATTRIBUTES:
|
||||
self._unit_of_measurement = vehicle_state.unit_of_length
|
||||
self._unit_of_measurement = 'km'
|
||||
elif self._attribute == 'remaining_fuel':
|
||||
self._unit_of_measurement = vehicle_state.unit_of_volume
|
||||
self._unit_of_measurement = 'l'
|
||||
else:
|
||||
self._unit_of_measurement = None
|
||||
|
||||
|
||||
Reference in new issue
Block a user