Use device class enum in Tractive (#60700)

This commit is contained in:
Daniel Hjelseth Høyer 2021-12-01 10:58:43 +01:00 committed by GitHub
parent 06f12fc583
commit ca55216d67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -4,7 +4,7 @@ from __future__ import annotations
from typing import Any
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_BATTERY_CHARGING,
BinarySensorDeviceClass,
BinarySensorEntity,
BinarySensorEntityDescription,
)
@ -76,7 +76,7 @@ class TractiveBinarySensor(TractiveEntity, BinarySensorEntity):
SENSOR_TYPE = BinarySensorEntityDescription(
key=ATTR_BATTERY_CHARGING,
name="Battery Charging",
device_class=DEVICE_CLASS_BATTERY_CHARGING,
device_class=BinarySensorDeviceClass.BATTERY_CHARGING,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
)

View File

@ -4,11 +4,14 @@ from __future__ import annotations
from dataclasses import dataclass
from typing import Any
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 (
ATTR_BATTERY_LEVEL,
DEVICE_CLASS_BATTERY,
ENTITY_CATEGORY_DIAGNOSTIC,
PERCENTAGE,
TIME_MINUTES,
@ -133,7 +136,7 @@ SENSOR_TYPES: tuple[TractiveSensorEntityDescription, ...] = (
key=ATTR_BATTERY_LEVEL,
name="Battery Level",
native_unit_of_measurement=PERCENTAGE,
device_class=DEVICE_CLASS_BATTERY,
device_class=SensorDeviceClass.BATTERY,
entity_class=TractiveHardwareSensor,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
),