mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Add device_class_power to sensor (#22691)
* Add device_class_power to sensor * Fix comment
This commit is contained in:
parent
a5a926bcc6
commit
8e39939b7e
@ -2,8 +2,8 @@
|
||||
import logging
|
||||
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_TEMPERATURE,
|
||||
POWER_WATT, TEMP_CELSIUS)
|
||||
DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE, DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_TEMPERATURE, POWER_WATT, TEMP_CELSIUS)
|
||||
|
||||
from . import DOMAIN as HMIPC_DOMAIN, HMIPC_HAPID, HomematicipGenericDevice
|
||||
|
||||
@ -238,6 +238,11 @@ class HomematicipPowerSensor(HomematicipGenericDevice):
|
||||
"""Initialize the device."""
|
||||
super().__init__(home, device, 'Power')
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the device class of the sensor."""
|
||||
return DEVICE_CLASS_POWER
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Represenation of the HomematicIP power comsumption value."""
|
||||
|
@ -5,12 +5,13 @@ import logging
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
from homeassistant.helpers.config_validation import ( # noqa
|
||||
PLATFORM_SCHEMA, PLATFORM_SCHEMA_BASE)
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_BATTERY, DEVICE_CLASS_HUMIDITY, DEVICE_CLASS_ILLUMINANCE,
|
||||
DEVICE_CLASS_TEMPERATURE, DEVICE_CLASS_TIMESTAMP, DEVICE_CLASS_PRESSURE)
|
||||
DEVICE_CLASS_POWER, DEVICE_CLASS_PRESSURE, DEVICE_CLASS_TEMPERATURE,
|
||||
DEVICE_CLASS_TIMESTAMP)
|
||||
from homeassistant.helpers.config_validation import ( # noqa
|
||||
PLATFORM_SCHEMA, PLATFORM_SCHEMA_BASE)
|
||||
from homeassistant.helpers.entity_component import EntityComponent
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -26,6 +27,7 @@ DEVICE_CLASSES = [
|
||||
DEVICE_CLASS_TEMPERATURE, # temperature (C/F)
|
||||
DEVICE_CLASS_TIMESTAMP, # timestamp (ISO8601)
|
||||
DEVICE_CLASS_PRESSURE, # pressure (hPa/mbar)
|
||||
DEVICE_CLASS_POWER, # power (W/kW)
|
||||
]
|
||||
|
||||
DEVICE_CLASSES_SCHEMA = vol.All(vol.Lower, vol.In(DEVICE_CLASSES))
|
||||
|
@ -188,6 +188,7 @@ DEVICE_CLASS_ILLUMINANCE = 'illuminance'
|
||||
DEVICE_CLASS_TEMPERATURE = 'temperature'
|
||||
DEVICE_CLASS_TIMESTAMP = 'timestamp'
|
||||
DEVICE_CLASS_PRESSURE = 'pressure'
|
||||
DEVICE_CLASS_POWER = 'power'
|
||||
|
||||
# #### STATES ####
|
||||
STATE_ON = 'on'
|
||||
|
Loading…
x
Reference in New Issue
Block a user