mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Use new DeviceClass enums in bmw (#61321)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
a63900a5a8
commit
a8d0a54553
@ -15,12 +15,7 @@ from bimmer_connected.vehicle_status import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
DEVICE_CLASS_BATTERY_CHARGING,
|
BinarySensorDeviceClass,
|
||||||
DEVICE_CLASS_LIGHT,
|
|
||||||
DEVICE_CLASS_LOCK,
|
|
||||||
DEVICE_CLASS_OPENING,
|
|
||||||
DEVICE_CLASS_PLUG,
|
|
||||||
DEVICE_CLASS_PROBLEM,
|
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
BinarySensorEntityDescription,
|
BinarySensorEntityDescription,
|
||||||
)
|
)
|
||||||
@ -158,42 +153,42 @@ SENSOR_TYPES: tuple[BMWBinarySensorEntityDescription, ...] = (
|
|||||||
BMWBinarySensorEntityDescription(
|
BMWBinarySensorEntityDescription(
|
||||||
key="lids",
|
key="lids",
|
||||||
name="Doors",
|
name="Doors",
|
||||||
device_class=DEVICE_CLASS_OPENING,
|
device_class=BinarySensorDeviceClass.OPENING,
|
||||||
icon="mdi:car-door-lock",
|
icon="mdi:car-door-lock",
|
||||||
value_fn=_are_doors_closed,
|
value_fn=_are_doors_closed,
|
||||||
),
|
),
|
||||||
BMWBinarySensorEntityDescription(
|
BMWBinarySensorEntityDescription(
|
||||||
key="windows",
|
key="windows",
|
||||||
name="Windows",
|
name="Windows",
|
||||||
device_class=DEVICE_CLASS_OPENING,
|
device_class=BinarySensorDeviceClass.OPENING,
|
||||||
icon="mdi:car-door",
|
icon="mdi:car-door",
|
||||||
value_fn=_are_windows_closed,
|
value_fn=_are_windows_closed,
|
||||||
),
|
),
|
||||||
BMWBinarySensorEntityDescription(
|
BMWBinarySensorEntityDescription(
|
||||||
key="door_lock_state",
|
key="door_lock_state",
|
||||||
name="Door lock state",
|
name="Door lock state",
|
||||||
device_class=DEVICE_CLASS_LOCK,
|
device_class=BinarySensorDeviceClass.LOCK,
|
||||||
icon="mdi:car-key",
|
icon="mdi:car-key",
|
||||||
value_fn=_are_doors_locked,
|
value_fn=_are_doors_locked,
|
||||||
),
|
),
|
||||||
BMWBinarySensorEntityDescription(
|
BMWBinarySensorEntityDescription(
|
||||||
key="lights_parking",
|
key="lights_parking",
|
||||||
name="Parking lights",
|
name="Parking lights",
|
||||||
device_class=DEVICE_CLASS_LIGHT,
|
device_class=BinarySensorDeviceClass.LIGHT,
|
||||||
icon="mdi:car-parking-lights",
|
icon="mdi:car-parking-lights",
|
||||||
value_fn=_are_parking_lights_on,
|
value_fn=_are_parking_lights_on,
|
||||||
),
|
),
|
||||||
BMWBinarySensorEntityDescription(
|
BMWBinarySensorEntityDescription(
|
||||||
key="condition_based_services",
|
key="condition_based_services",
|
||||||
name="Condition based services",
|
name="Condition based services",
|
||||||
device_class=DEVICE_CLASS_PROBLEM,
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||||
icon="mdi:wrench",
|
icon="mdi:wrench",
|
||||||
value_fn=_are_problems_detected,
|
value_fn=_are_problems_detected,
|
||||||
),
|
),
|
||||||
BMWBinarySensorEntityDescription(
|
BMWBinarySensorEntityDescription(
|
||||||
key="check_control_messages",
|
key="check_control_messages",
|
||||||
name="Control messages",
|
name="Control messages",
|
||||||
device_class=DEVICE_CLASS_PROBLEM,
|
device_class=BinarySensorDeviceClass.PROBLEM,
|
||||||
icon="mdi:car-tire-alert",
|
icon="mdi:car-tire-alert",
|
||||||
value_fn=_check_control_messages,
|
value_fn=_check_control_messages,
|
||||||
),
|
),
|
||||||
@ -201,14 +196,14 @@ SENSOR_TYPES: tuple[BMWBinarySensorEntityDescription, ...] = (
|
|||||||
BMWBinarySensorEntityDescription(
|
BMWBinarySensorEntityDescription(
|
||||||
key="charging_status",
|
key="charging_status",
|
||||||
name="Charging status",
|
name="Charging status",
|
||||||
device_class=DEVICE_CLASS_BATTERY_CHARGING,
|
device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
|
||||||
icon="mdi:ev-station",
|
icon="mdi:ev-station",
|
||||||
value_fn=_is_vehicle_charging,
|
value_fn=_is_vehicle_charging,
|
||||||
),
|
),
|
||||||
BMWBinarySensorEntityDescription(
|
BMWBinarySensorEntityDescription(
|
||||||
key="connection_status",
|
key="connection_status",
|
||||||
name="Connection status",
|
name="Connection status",
|
||||||
device_class=DEVICE_CLASS_PLUG,
|
device_class=BinarySensorDeviceClass.PLUG,
|
||||||
icon="mdi:car-electric",
|
icon="mdi:car-electric",
|
||||||
value_fn=_is_vehicle_plugged_in,
|
value_fn=_is_vehicle_plugged_in,
|
||||||
),
|
),
|
||||||
|
@ -8,11 +8,14 @@ from typing import cast
|
|||||||
|
|
||||||
from bimmer_connected.vehicle import ConnectedDriveVehicle
|
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.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_UNIT_SYSTEM_IMPERIAL,
|
CONF_UNIT_SYSTEM_IMPERIAL,
|
||||||
DEVICE_CLASS_BATTERY,
|
|
||||||
LENGTH_KILOMETERS,
|
LENGTH_KILOMETERS,
|
||||||
LENGTH_MILES,
|
LENGTH_MILES,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
@ -61,7 +64,7 @@ SENSOR_TYPES: dict[str, BMWSensorEntityDescription] = {
|
|||||||
key="charging_level_hv",
|
key="charging_level_hv",
|
||||||
unit_metric=PERCENTAGE,
|
unit_metric=PERCENTAGE,
|
||||||
unit_imperial=PERCENTAGE,
|
unit_imperial=PERCENTAGE,
|
||||||
device_class=DEVICE_CLASS_BATTERY,
|
device_class=SensorDeviceClass.BATTERY,
|
||||||
),
|
),
|
||||||
# --- Specific ---
|
# --- Specific ---
|
||||||
"mileage": BMWSensorEntityDescription(
|
"mileage": BMWSensorEntityDescription(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user