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

View File

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