Update bimmer_connected to 0.6.0 (#26098)
* Update bimmer_connected to 0.6.0 * Correct file propertiespull/26106/head
parent
2fbe01fb33
commit
38ce4039c3
|
@ -40,6 +40,7 @@ homeassistant/components/azure_event_hub/* @eavanvalkenburg
|
|||
homeassistant/components/bitcoin/* @fabaff
|
||||
homeassistant/components/bizkaibus/* @UgaitzEtxebarria
|
||||
homeassistant/components/blink/* @fronzbot
|
||||
homeassistant/components/bmw_connected_drive/* @gerard33
|
||||
homeassistant/components/braviatv/* @robbiet480
|
||||
homeassistant/components/broadlink/* @danielhiversen
|
||||
homeassistant/components/brunt/* @eavanvalkenburg
|
||||
|
|
|
@ -143,7 +143,10 @@ class BMWConnectedDriveAccount:
|
|||
for listener in self._update_listeners:
|
||||
listener()
|
||||
except IOError as exception:
|
||||
_LOGGER.error("Error updating the vehicle state")
|
||||
_LOGGER.error(
|
||||
"Could not connect to the BMW Connected Drive portal. "
|
||||
"The vehicle state could not be updated."
|
||||
)
|
||||
_LOGGER.exception(exception)
|
||||
|
||||
def add_update_listener(self, listener):
|
||||
|
|
|
@ -9,17 +9,17 @@ from . import DOMAIN as BMW_DOMAIN
|
|||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
SENSOR_TYPES = {
|
||||
"lids": ["Doors", "opening"],
|
||||
"windows": ["Windows", "opening"],
|
||||
"door_lock_state": ["Door lock state", "safety"],
|
||||
"lights_parking": ["Parking lights", "light"],
|
||||
"condition_based_services": ["Condition based services", "problem"],
|
||||
"check_control_messages": ["Control messages", "problem"],
|
||||
"lids": ["Doors", "opening", "mdi:car-door"],
|
||||
"windows": ["Windows", "opening", "mdi:car-door"],
|
||||
"door_lock_state": ["Door lock state", "safety", "mdi:car-key"],
|
||||
"lights_parking": ["Parking lights", "light", "mdi:car-parking-lights"],
|
||||
"condition_based_services": ["Condition based services", "problem", "mdi:wrench"],
|
||||
"check_control_messages": ["Control messages", "problem", "mdi:car-tire-alert"],
|
||||
}
|
||||
|
||||
SENSOR_TYPES_ELEC = {
|
||||
"charging_status": ["Charging status", "power"],
|
||||
"connection_status": ["Connection status", "plug"],
|
||||
"charging_status": ["Charging status", "power", "mdi:ev-station"],
|
||||
"connection_status": ["Connection status", "plug", "mdi:car-electric"],
|
||||
}
|
||||
|
||||
SENSOR_TYPES_ELEC.update(SENSOR_TYPES)
|
||||
|
@ -35,24 +35,28 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
if vehicle.has_hv_battery:
|
||||
_LOGGER.debug("BMW with a high voltage battery")
|
||||
for key, value in sorted(SENSOR_TYPES_ELEC.items()):
|
||||
device = BMWConnectedDriveSensor(
|
||||
account, vehicle, key, value[0], value[1]
|
||||
)
|
||||
devices.append(device)
|
||||
if key in vehicle.available_attributes:
|
||||
device = BMWConnectedDriveSensor(
|
||||
account, vehicle, key, value[0], value[1], value[2]
|
||||
)
|
||||
devices.append(device)
|
||||
elif vehicle.has_internal_combustion_engine:
|
||||
_LOGGER.debug("BMW with an internal combustion engine")
|
||||
for key, value in sorted(SENSOR_TYPES.items()):
|
||||
device = BMWConnectedDriveSensor(
|
||||
account, vehicle, key, value[0], value[1]
|
||||
)
|
||||
devices.append(device)
|
||||
if key in vehicle.available_attributes:
|
||||
device = BMWConnectedDriveSensor(
|
||||
account, vehicle, key, value[0], value[1], value[2]
|
||||
)
|
||||
devices.append(device)
|
||||
add_entities(devices, True)
|
||||
|
||||
|
||||
class BMWConnectedDriveSensor(BinarySensorDevice):
|
||||
"""Representation of a BMW vehicle binary sensor."""
|
||||
|
||||
def __init__(self, account, vehicle, attribute: str, sensor_name, device_class):
|
||||
def __init__(
|
||||
self, account, vehicle, attribute: str, sensor_name, device_class, icon
|
||||
):
|
||||
"""Constructor."""
|
||||
self._account = account
|
||||
self._vehicle = vehicle
|
||||
|
@ -61,6 +65,7 @@ class BMWConnectedDriveSensor(BinarySensorDevice):
|
|||
self._unique_id = "{}-{}".format(self._vehicle.vin, self._attribute)
|
||||
self._sensor_name = sensor_name
|
||||
self._device_class = device_class
|
||||
self._icon = icon
|
||||
self._state = None
|
||||
|
||||
@property
|
||||
|
@ -81,6 +86,11 @@ class BMWConnectedDriveSensor(BinarySensorDevice):
|
|||
"""Return the name of the binary sensor."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Icon to use in the frontend, if any."""
|
||||
return self._icon
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the class of the binary sensor."""
|
||||
|
@ -112,23 +122,19 @@ class BMWConnectedDriveSensor(BinarySensorDevice):
|
|||
for report in vehicle_state.condition_based_services:
|
||||
result.update(self._format_cbs_report(report))
|
||||
elif self._attribute == "check_control_messages":
|
||||
check_control_messages = vehicle_state.check_control_messages
|
||||
if not check_control_messages:
|
||||
result["check_control_messages"] = "OK"
|
||||
else:
|
||||
check_control_messages = vehicle_state.has_check_control_messages
|
||||
if check_control_messages:
|
||||
cbs_list = []
|
||||
for message in check_control_messages:
|
||||
cbs_list.append(message["ccmDescriptionShort"])
|
||||
result["check_control_messages"] = cbs_list
|
||||
else:
|
||||
result["check_control_messages"] = "OK"
|
||||
elif self._attribute == "charging_status":
|
||||
result["charging_status"] = vehicle_state.charging_status.value
|
||||
# pylint: disable=protected-access
|
||||
result["last_charging_end_result"] = vehicle_state._attributes[
|
||||
"lastChargingEndResult"
|
||||
]
|
||||
if self._attribute == "connection_status":
|
||||
# pylint: disable=protected-access
|
||||
result["connection_status"] = vehicle_state._attributes["connectionStatus"]
|
||||
result["last_charging_end_result"] = vehicle_state.last_charging_end_result
|
||||
elif self._attribute == "connection_status":
|
||||
result["connection_status"] = vehicle_state.connection_status
|
||||
|
||||
return sorted(result.items())
|
||||
|
||||
|
@ -166,8 +172,7 @@ class BMWConnectedDriveSensor(BinarySensorDevice):
|
|||
# device class plug: On means device is plugged in,
|
||||
# Off means device is unplugged
|
||||
if self._attribute == "connection_status":
|
||||
# pylint: disable=protected-access
|
||||
self._state = vehicle_state._attributes["connectionStatus"] == "CONNECTED"
|
||||
self._state = vehicle_state.connection_status == "CONNECTED"
|
||||
|
||||
def _format_cbs_report(self, report):
|
||||
result = {}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
{
|
||||
"domain": "bmw_connected_drive",
|
||||
"name": "Bmw connected drive",
|
||||
"name": "BMW Connected Drive",
|
||||
"documentation": "https://www.home-assistant.io/components/bmw_connected_drive",
|
||||
"requirements": [
|
||||
"bimmer_connected==0.5.3"
|
||||
"bimmer_connected==0.6.0"
|
||||
],
|
||||
"dependencies": [],
|
||||
"codeowners": [
|
||||
"@gerard33"
|
||||
]
|
||||
}
|
||||
}
|
|
@ -51,14 +51,11 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
|
|||
for account in accounts:
|
||||
for vehicle in account.account.vehicles:
|
||||
for attribute_name in vehicle.drive_train_attributes:
|
||||
device = BMWConnectedDriveSensor(
|
||||
account, vehicle, attribute_name, attribute_info
|
||||
)
|
||||
devices.append(device)
|
||||
device = BMWConnectedDriveSensor(
|
||||
account, vehicle, "mileage", attribute_info
|
||||
)
|
||||
devices.append(device)
|
||||
if attribute_name in vehicle.available_attributes:
|
||||
device = BMWConnectedDriveSensor(
|
||||
account, vehicle, attribute_name, attribute_info
|
||||
)
|
||||
devices.append(device)
|
||||
add_entities(devices, True)
|
||||
|
||||
|
||||
|
|
|
@ -266,7 +266,7 @@ beautifulsoup4==4.8.0
|
|||
bellows-homeassistant==0.9.1
|
||||
|
||||
# homeassistant.components.bmw_connected_drive
|
||||
bimmer_connected==0.5.3
|
||||
bimmer_connected==0.6.0
|
||||
|
||||
# homeassistant.components.bizkaibus
|
||||
bizkaibus==0.1.1
|
||||
|
|
Loading…
Reference in New Issue