Use correct Nissan leaf device_class (#59889)

This commit is contained in:
bwduncan 2021-11-18 14:23:57 +00:00 committed by GitHub
parent 9ab8622d72
commit ec6a67d17a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,11 @@
"""Plugged In Status Support for the Nissan Leaf."""
import logging
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_BATTERY_CHARGING,
DEVICE_CLASS_PLUG,
BinarySensorEntity,
)
from . import DATA_CHARGING, DATA_LEAF, DATA_PLUGGED_IN, LeafEntity
@ -25,6 +29,8 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
class LeafPluggedInSensor(LeafEntity, BinarySensorEntity):
"""Plugged In Sensor class."""
_attr_device_class = DEVICE_CLASS_PLUG
@property
def name(self):
"""Sensor name."""
@ -40,17 +46,12 @@ class LeafPluggedInSensor(LeafEntity, BinarySensorEntity):
"""Return true if plugged in."""
return self.car.data[DATA_PLUGGED_IN]
@property
def icon(self):
"""Icon handling."""
if self.car.data[DATA_PLUGGED_IN]:
return "mdi:power-plug"
return "mdi:power-plug-off"
class LeafChargingSensor(LeafEntity, BinarySensorEntity):
"""Charging Sensor class."""
_attr_device_class = DEVICE_CLASS_BATTERY_CHARGING
@property
def name(self):
"""Sensor name."""
@ -65,10 +66,3 @@ class LeafChargingSensor(LeafEntity, BinarySensorEntity):
def is_on(self):
"""Return true if charging."""
return self.car.data[DATA_CHARGING]
@property
def icon(self):
"""Icon handling."""
if self.car.data[DATA_CHARGING]:
return "mdi:flash"
return "mdi:flash-off"