Use new enums in spider (#62396)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet 2021-12-20 18:06:33 +01:00 committed by GitHub
parent 36a57b00d9
commit bae82d76b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,15 +1,10 @@
"""Support for Spider Powerplugs (energy & power)."""
from homeassistant.components.sensor import (
STATE_CLASS_MEASUREMENT,
STATE_CLASS_TOTAL_INCREASING,
SensorDeviceClass,
SensorEntity,
SensorStateClass,
)
from homeassistant.const import (
DEVICE_CLASS_ENERGY,
DEVICE_CLASS_POWER,
ENERGY_KILO_WATT_HOUR,
POWER_WATT,
)
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT
from homeassistant.helpers.entity import DeviceInfo
from .const import DOMAIN
@ -31,8 +26,8 @@ class SpiderPowerPlugEnergy(SensorEntity):
"""Representation of a Spider Power Plug (energy)."""
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
_attr_device_class = DEVICE_CLASS_ENERGY
_attr_state_class = STATE_CLASS_TOTAL_INCREASING
_attr_device_class = SensorDeviceClass.ENERGY
_attr_state_class = SensorStateClass.TOTAL_INCREASING
def __init__(self, api, power_plug) -> None:
"""Initialize the Spider Power Plug."""
@ -72,8 +67,8 @@ class SpiderPowerPlugEnergy(SensorEntity):
class SpiderPowerPlugPower(SensorEntity):
"""Representation of a Spider Power Plug (power)."""
_attr_device_class = DEVICE_CLASS_POWER
_attr_state_class = STATE_CLASS_MEASUREMENT
_attr_device_class = SensorDeviceClass.POWER
_attr_state_class = SensorStateClass.MEASUREMENT
_attr_native_unit_of_measurement = POWER_WATT
def __init__(self, api, power_plug) -> None: