From ca55216d67d1eb8a4a9977b175bf85cfeee8ea76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hjelseth=20H=C3=B8yer?= Date: Wed, 1 Dec 2021 10:58:43 +0100 Subject: [PATCH] Use device class enum in Tractive (#60700) --- homeassistant/components/tractive/binary_sensor.py | 4 ++-- homeassistant/components/tractive/sensor.py | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/tractive/binary_sensor.py b/homeassistant/components/tractive/binary_sensor.py index dfd28eed98d..453b5cf5b0c 100644 --- a/homeassistant/components/tractive/binary_sensor.py +++ b/homeassistant/components/tractive/binary_sensor.py @@ -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, ) diff --git a/homeassistant/components/tractive/sensor.py b/homeassistant/components/tractive/sensor.py index b9afbeba757..2bbd755da2c 100644 --- a/homeassistant/components/tractive/sensor.py +++ b/homeassistant/components/tractive/sensor.py @@ -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, ),