mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Add state_class
to the sensor entity descriptions for apcupsd integration (#84829)
This commit is contained in:
parent
8cbbdf21f3
commit
7a7f986444
@ -9,6 +9,7 @@ from homeassistant.components.sensor import (
|
|||||||
SensorDeviceClass,
|
SensorDeviceClass,
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
@ -39,6 +40,9 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
key="ambtemp",
|
key="ambtemp",
|
||||||
name="UPS Ambient Temperature",
|
name="UPS Ambient Temperature",
|
||||||
icon="mdi:thermometer",
|
icon="mdi:thermometer",
|
||||||
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"apc": SensorEntityDescription(
|
"apc": SensorEntityDescription(
|
||||||
key="apc",
|
key="apc",
|
||||||
@ -72,12 +76,15 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
name="UPS Battery Voltage",
|
name="UPS Battery Voltage",
|
||||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
device_class=SensorDeviceClass.VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"bcharge": SensorEntityDescription(
|
"bcharge": SensorEntityDescription(
|
||||||
key="bcharge",
|
key="bcharge",
|
||||||
name="UPS Battery",
|
name="UPS Battery",
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
icon="mdi:battery",
|
icon="mdi:battery",
|
||||||
|
device_class=SensorDeviceClass.BATTERY,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"cable": SensorEntityDescription(
|
"cable": SensorEntityDescription(
|
||||||
key="cable",
|
key="cable",
|
||||||
@ -89,6 +96,7 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
key="cumonbatt",
|
key="cumonbatt",
|
||||||
name="UPS Total Time on Battery",
|
name="UPS Total Time on Battery",
|
||||||
icon="mdi:timer-outline",
|
icon="mdi:timer-outline",
|
||||||
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
"date": SensorEntityDescription(
|
"date": SensorEntityDescription(
|
||||||
key="date",
|
key="date",
|
||||||
@ -155,13 +163,16 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
key="humidity",
|
key="humidity",
|
||||||
name="UPS Ambient Humidity",
|
name="UPS Ambient Humidity",
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
icon="mdi:water-percent",
|
icon="mdi:water-percent",
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"itemp": SensorEntityDescription(
|
"itemp": SensorEntityDescription(
|
||||||
key="itemp",
|
key="itemp",
|
||||||
name="UPS Internal Temperature",
|
name="UPS Internal Temperature",
|
||||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"laststest": SensorEntityDescription(
|
"laststest": SensorEntityDescription(
|
||||||
key="laststest",
|
key="laststest",
|
||||||
@ -184,18 +195,21 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
name="UPS Line Frequency",
|
name="UPS Line Frequency",
|
||||||
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
||||||
device_class=SensorDeviceClass.FREQUENCY,
|
device_class=SensorDeviceClass.FREQUENCY,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"linev": SensorEntityDescription(
|
"linev": SensorEntityDescription(
|
||||||
key="linev",
|
key="linev",
|
||||||
name="UPS Input Voltage",
|
name="UPS Input Voltage",
|
||||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
device_class=SensorDeviceClass.VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"loadpct": SensorEntityDescription(
|
"loadpct": SensorEntityDescription(
|
||||||
key="loadpct",
|
key="loadpct",
|
||||||
name="UPS Load",
|
name="UPS Load",
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
icon="mdi:gauge",
|
icon="mdi:gauge",
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"loadapnt": SensorEntityDescription(
|
"loadapnt": SensorEntityDescription(
|
||||||
key="loadapnt",
|
key="loadapnt",
|
||||||
@ -288,18 +302,21 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
key="numxfers",
|
key="numxfers",
|
||||||
name="UPS Transfer Count",
|
name="UPS Transfer Count",
|
||||||
icon="mdi:counter",
|
icon="mdi:counter",
|
||||||
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
"outcurnt": SensorEntityDescription(
|
"outcurnt": SensorEntityDescription(
|
||||||
key="outcurnt",
|
key="outcurnt",
|
||||||
name="UPS Output Current",
|
name="UPS Output Current",
|
||||||
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||||
device_class=SensorDeviceClass.CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"outputv": SensorEntityDescription(
|
"outputv": SensorEntityDescription(
|
||||||
key="outputv",
|
key="outputv",
|
||||||
name="UPS Output Voltage",
|
name="UPS Output Voltage",
|
||||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
device_class=SensorDeviceClass.VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"reg1": SensorEntityDescription(
|
"reg1": SensorEntityDescription(
|
||||||
key="reg1",
|
key="reg1",
|
||||||
@ -362,16 +379,19 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
key="stesti",
|
key="stesti",
|
||||||
name="UPS Self Test Interval",
|
name="UPS Self Test Interval",
|
||||||
icon="mdi:information-outline",
|
icon="mdi:information-outline",
|
||||||
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
"timeleft": SensorEntityDescription(
|
"timeleft": SensorEntityDescription(
|
||||||
key="timeleft",
|
key="timeleft",
|
||||||
name="UPS Time Left",
|
name="UPS Time Left",
|
||||||
icon="mdi:clock-alert",
|
icon="mdi:clock-alert",
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"tonbatt": SensorEntityDescription(
|
"tonbatt": SensorEntityDescription(
|
||||||
key="tonbatt",
|
key="tonbatt",
|
||||||
name="UPS Time on Battery",
|
name="UPS Time on Battery",
|
||||||
icon="mdi:timer-outline",
|
icon="mdi:timer-outline",
|
||||||
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
"upsmode": SensorEntityDescription(
|
"upsmode": SensorEntityDescription(
|
||||||
key="upsmode",
|
key="upsmode",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user