Use new DeviceClass enums in bmw (#61321)

Co-authored-by: epenet <epenet@users.noreply.github.com>
pull/61338/head
epenet 2021-12-09 08:28:08 +01:00 committed by GitHub
parent a63900a5a8
commit a8d0a54553
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 17 deletions

View File

@ -15,12 +15,7 @@ from bimmer_connected.vehicle_status import (
)
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_BATTERY_CHARGING,
DEVICE_CLASS_LIGHT,
DEVICE_CLASS_LOCK,
DEVICE_CLASS_OPENING,
DEVICE_CLASS_PLUG,
DEVICE_CLASS_PROBLEM,
BinarySensorDeviceClass,
BinarySensorEntity,
BinarySensorEntityDescription,
)
@ -158,42 +153,42 @@ SENSOR_TYPES: tuple[BMWBinarySensorEntityDescription, ...] = (
BMWBinarySensorEntityDescription(
key="lids",
name="Doors",
device_class=DEVICE_CLASS_OPENING,
device_class=BinarySensorDeviceClass.OPENING,
icon="mdi:car-door-lock",
value_fn=_are_doors_closed,
),
BMWBinarySensorEntityDescription(
key="windows",
name="Windows",
device_class=DEVICE_CLASS_OPENING,
device_class=BinarySensorDeviceClass.OPENING,
icon="mdi:car-door",
value_fn=_are_windows_closed,
),
BMWBinarySensorEntityDescription(
key="door_lock_state",
name="Door lock state",
device_class=DEVICE_CLASS_LOCK,
device_class=BinarySensorDeviceClass.LOCK,
icon="mdi:car-key",
value_fn=_are_doors_locked,
),
BMWBinarySensorEntityDescription(
key="lights_parking",
name="Parking lights",
device_class=DEVICE_CLASS_LIGHT,
device_class=BinarySensorDeviceClass.LIGHT,
icon="mdi:car-parking-lights",
value_fn=_are_parking_lights_on,
),
BMWBinarySensorEntityDescription(
key="condition_based_services",
name="Condition based services",
device_class=DEVICE_CLASS_PROBLEM,
device_class=BinarySensorDeviceClass.PROBLEM,
icon="mdi:wrench",
value_fn=_are_problems_detected,
),
BMWBinarySensorEntityDescription(
key="check_control_messages",
name="Control messages",
device_class=DEVICE_CLASS_PROBLEM,
device_class=BinarySensorDeviceClass.PROBLEM,
icon="mdi:car-tire-alert",
value_fn=_check_control_messages,
),
@ -201,14 +196,14 @@ SENSOR_TYPES: tuple[BMWBinarySensorEntityDescription, ...] = (
BMWBinarySensorEntityDescription(
key="charging_status",
name="Charging status",
device_class=DEVICE_CLASS_BATTERY_CHARGING,
device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
icon="mdi:ev-station",
value_fn=_is_vehicle_charging,
),
BMWBinarySensorEntityDescription(
key="connection_status",
name="Connection status",
device_class=DEVICE_CLASS_PLUG,
device_class=BinarySensorDeviceClass.PLUG,
icon="mdi:car-electric",
value_fn=_is_vehicle_plugged_in,
),

View File

@ -8,11 +8,14 @@ from typing import cast
from bimmer_connected.vehicle import ConnectedDriveVehicle
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_UNIT_SYSTEM_IMPERIAL,
DEVICE_CLASS_BATTERY,
LENGTH_KILOMETERS,
LENGTH_MILES,
PERCENTAGE,
@ -61,7 +64,7 @@ SENSOR_TYPES: dict[str, BMWSensorEntityDescription] = {
key="charging_level_hv",
unit_metric=PERCENTAGE,
unit_imperial=PERCENTAGE,
device_class=DEVICE_CLASS_BATTERY,
device_class=SensorDeviceClass.BATTERY,
),
# --- Specific ---
"mileage": BMWSensorEntityDescription(