Use new enums in nissan_leaf (#61951)

This commit is contained in:
epenet 2021-12-16 22:44:50 +01:00 committed by GitHub
parent 81ea811b74
commit 39590f9917
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 7 deletions

View File

@ -2,8 +2,7 @@
import logging
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_BATTERY_CHARGING,
DEVICE_CLASS_PLUG,
BinarySensorDeviceClass,
BinarySensorEntity,
)
@ -29,7 +28,7 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
class LeafPluggedInSensor(LeafEntity, BinarySensorEntity):
"""Plugged In Sensor class."""
_attr_device_class = DEVICE_CLASS_PLUG
_attr_device_class = BinarySensorDeviceClass.PLUG
@property
def name(self):
@ -50,7 +49,7 @@ class LeafPluggedInSensor(LeafEntity, BinarySensorEntity):
class LeafChargingSensor(LeafEntity, BinarySensorEntity):
"""Charging Sensor class."""
_attr_device_class = DEVICE_CLASS_BATTERY_CHARGING
_attr_device_class = BinarySensorDeviceClass.BATTERY_CHARGING
@property
def name(self):

View File

@ -1,8 +1,8 @@
"""Battery Charge and Range Support for the Nissan Leaf."""
import logging
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import DEVICE_CLASS_BATTERY, PERCENTAGE
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
from homeassistant.const import PERCENTAGE
from homeassistant.helpers.icon import icon_for_battery_level
from homeassistant.util.distance import LENGTH_KILOMETERS, LENGTH_MILES
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM
@ -47,7 +47,7 @@ class LeafBatterySensor(LeafEntity, SensorEntity):
@property
def device_class(self):
"""Return the device class of the sensor."""
return DEVICE_CLASS_BATTERY
return SensorDeviceClass.BATTERY
@property
def native_value(self):