Fix CCM messages (#26589)

This commit is contained in:
Gerard 2019-09-12 09:50:02 +02:00 committed by Pascal Vizeli
parent 63cf21296c
commit 41f96a315e
2 changed files with 15 additions and 14 deletions

View File

@ -9,7 +9,7 @@ from . import DOMAIN as BMW_DOMAIN
_LOGGER = logging.getLogger(__name__)
SENSOR_TYPES = {
"lids": ["Doors", "opening", "mdi:car-door"],
"lids": ["Doors", "opening", "mdi:car-door-lock"],
"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"],
@ -122,8 +122,9 @@ 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.has_check_control_messages
if check_control_messages:
check_control_messages = vehicle_state.check_control_messages
has_check_control_messages = vehicle_state.has_check_control_messages
if has_check_control_messages:
cbs_list = []
for message in check_control_messages:
cbs_list.append(message["ccmDescriptionShort"])
@ -184,9 +185,9 @@ class BMWConnectedDriveSensor(BinarySensorDevice):
distance = round(
self.hass.config.units.length(report.due_distance, LENGTH_KILOMETERS)
)
result[f"{service_type} distance"] = "{} {}".format(
distance, self.hass.config.units.length_unit
)
result[
f"{service_type} distance"
] = f"{distance} {self.hass.config.units.length_unit}"
return result
def update_callback(self):

View File

@ -17,10 +17,10 @@ _LOGGER = logging.getLogger(__name__)
ATTR_TO_HA_METRIC = {
"mileage": ["mdi:speedometer", LENGTH_KILOMETERS],
"remaining_range_total": ["mdi:ruler", LENGTH_KILOMETERS],
"remaining_range_electric": ["mdi:ruler", LENGTH_KILOMETERS],
"remaining_range_fuel": ["mdi:ruler", LENGTH_KILOMETERS],
"max_range_electric": ["mdi:ruler", LENGTH_KILOMETERS],
"remaining_range_total": ["mdi:map-marker-distance", LENGTH_KILOMETERS],
"remaining_range_electric": ["mdi:map-marker-distance", LENGTH_KILOMETERS],
"remaining_range_fuel": ["mdi:map-marker-distance", LENGTH_KILOMETERS],
"max_range_electric": ["mdi:map-marker-distance", LENGTH_KILOMETERS],
"remaining_fuel": ["mdi:gas-station", VOLUME_LITERS],
"charging_time_remaining": ["mdi:update", "h"],
"charging_status": ["mdi:battery-charging", None],
@ -28,10 +28,10 @@ ATTR_TO_HA_METRIC = {
ATTR_TO_HA_IMPERIAL = {
"mileage": ["mdi:speedometer", LENGTH_MILES],
"remaining_range_total": ["mdi:ruler", LENGTH_MILES],
"remaining_range_electric": ["mdi:ruler", LENGTH_MILES],
"remaining_range_fuel": ["mdi:ruler", LENGTH_MILES],
"max_range_electric": ["mdi:ruler", LENGTH_MILES],
"remaining_range_total": ["mdi:map-marker-distance", LENGTH_MILES],
"remaining_range_electric": ["mdi:map-marker-distance", LENGTH_MILES],
"remaining_range_fuel": ["mdi:map-marker-distance", LENGTH_MILES],
"max_range_electric": ["mdi:map-marker-distance", LENGTH_MILES],
"remaining_fuel": ["mdi:gas-station", VOLUME_GALLONS],
"charging_time_remaining": ["mdi:update", "h"],
"charging_status": ["mdi:battery-charging", None],