mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 04:07:08 +00:00
Use correct Nissan leaf device_class (#59889)
This commit is contained in:
parent
9ab8622d72
commit
ec6a67d17a
@ -1,7 +1,11 @@
|
|||||||
"""Plugged In Status Support for the Nissan Leaf."""
|
"""Plugged In Status Support for the Nissan Leaf."""
|
||||||
import logging
|
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
|
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):
|
class LeafPluggedInSensor(LeafEntity, BinarySensorEntity):
|
||||||
"""Plugged In Sensor class."""
|
"""Plugged In Sensor class."""
|
||||||
|
|
||||||
|
_attr_device_class = DEVICE_CLASS_PLUG
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Sensor name."""
|
"""Sensor name."""
|
||||||
@ -40,17 +46,12 @@ class LeafPluggedInSensor(LeafEntity, BinarySensorEntity):
|
|||||||
"""Return true if plugged in."""
|
"""Return true if plugged in."""
|
||||||
return self.car.data[DATA_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):
|
class LeafChargingSensor(LeafEntity, BinarySensorEntity):
|
||||||
"""Charging Sensor class."""
|
"""Charging Sensor class."""
|
||||||
|
|
||||||
|
_attr_device_class = DEVICE_CLASS_BATTERY_CHARGING
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Sensor name."""
|
"""Sensor name."""
|
||||||
@ -65,10 +66,3 @@ class LeafChargingSensor(LeafEntity, BinarySensorEntity):
|
|||||||
def is_on(self):
|
def is_on(self):
|
||||||
"""Return true if charging."""
|
"""Return true if charging."""
|
||||||
return self.car.data[DATA_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"
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user