diff --git a/homeassistant/components/nissan_leaf/binary_sensor.py b/homeassistant/components/nissan_leaf/binary_sensor.py index d2387e0e9a2..13fe666a3a8 100644 --- a/homeassistant/components/nissan_leaf/binary_sensor.py +++ b/homeassistant/components/nissan_leaf/binary_sensor.py @@ -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"