Use enums in senses (#62050)
This commit is contained in:
parent
65b67d9d91
commit
b6ed3e87e0
2 changed files with 13 additions and 12 deletions
|
@ -1,8 +1,11 @@
|
||||||
"""Support for monitoring a Sense energy sensor device."""
|
"""Support for monitoring a Sense energy sensor device."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
from homeassistant.components.binary_sensor import (
|
||||||
from homeassistant.const import ATTR_ATTRIBUTION, DEVICE_CLASS_POWER
|
BinarySensorDeviceClass,
|
||||||
|
BinarySensorEntity,
|
||||||
|
)
|
||||||
|
from homeassistant.const import ATTR_ATTRIBUTION
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||||
from homeassistant.helpers.entity_registry import async_get_registry
|
from homeassistant.helpers.entity_registry import async_get_registry
|
||||||
|
@ -113,7 +116,7 @@ class SenseDevice(BinarySensorEntity):
|
||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the device class of the binary sensor."""
|
"""Return the device class of the binary sensor."""
|
||||||
return DEVICE_CLASS_POWER
|
return BinarySensorDeviceClass.POWER
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
"""Support for monitoring a Sense energy sensor."""
|
"""Support for monitoring a Sense energy sensor."""
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
STATE_CLASS_MEASUREMENT,
|
SensorDeviceClass,
|
||||||
STATE_CLASS_TOTAL,
|
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ATTRIBUTION,
|
ATTR_ATTRIBUTION,
|
||||||
DEVICE_CLASS_ENERGY,
|
|
||||||
DEVICE_CLASS_POWER,
|
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
ELECTRIC_POTENTIAL_VOLT,
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
|
@ -157,7 +155,7 @@ class SenseActiveSensor(SensorEntity):
|
||||||
_attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
_attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
_attr_available = False
|
_attr_available = False
|
||||||
_attr_state_class = STATE_CLASS_MEASUREMENT
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
@ -250,8 +248,8 @@ class SenseVoltageSensor(SensorEntity):
|
||||||
class SenseTrendsSensor(CoordinatorEntity, SensorEntity):
|
class SenseTrendsSensor(CoordinatorEntity, SensorEntity):
|
||||||
"""Implementation of a Sense energy sensor."""
|
"""Implementation of a Sense energy sensor."""
|
||||||
|
|
||||||
_attr_device_class = DEVICE_CLASS_ENERGY
|
_attr_device_class = SensorDeviceClass.ENERGY
|
||||||
_attr_state_class = STATE_CLASS_TOTAL
|
_attr_state_class = SensorStateClass.TOTAL
|
||||||
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||||
_attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
_attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||||
_attr_icon = ICON
|
_attr_icon = ICON
|
||||||
|
@ -299,10 +297,10 @@ class SenseEnergyDevice(SensorEntity):
|
||||||
"""Implementation of a Sense energy device."""
|
"""Implementation of a Sense energy device."""
|
||||||
|
|
||||||
_attr_available = False
|
_attr_available = False
|
||||||
_attr_state_class = STATE_CLASS_MEASUREMENT
|
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
_attr_native_unit_of_measurement = POWER_WATT
|
_attr_native_unit_of_measurement = POWER_WATT
|
||||||
_attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
_attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
||||||
_attr_device_class = DEVICE_CLASS_POWER
|
_attr_device_class = SensorDeviceClass.POWER
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
|
|
||||||
def __init__(self, sense_devices_data, device, sense_monitor_id):
|
def __init__(self, sense_devices_data, device, sense_monitor_id):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue