mirror of
https://github.com/home-assistant/core.git
synced 2025-04-26 18:27:51 +00:00
Use device classes in apcupsd (#83807)
This commit is contained in:
parent
87d24d4cbe
commit
2b647bcd5b
@ -17,15 +17,14 @@ from homeassistant.const import (
|
|||||||
CONF_HOST,
|
CONF_HOST,
|
||||||
CONF_PORT,
|
CONF_PORT,
|
||||||
CONF_RESOURCES,
|
CONF_RESOURCES,
|
||||||
ELECTRIC_CURRENT_AMPERE,
|
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
|
||||||
FREQUENCY_HERTZ,
|
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
POWER_WATT,
|
|
||||||
TEMP_CELSIUS,
|
|
||||||
TIME_MINUTES,
|
|
||||||
TIME_SECONDS,
|
|
||||||
UnitOfApparentPower,
|
UnitOfApparentPower,
|
||||||
|
UnitOfElectricCurrent,
|
||||||
|
UnitOfElectricPotential,
|
||||||
|
UnitOfFrequency,
|
||||||
|
UnitOfPower,
|
||||||
|
UnitOfTemperature,
|
||||||
|
UnitOfTime,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
@ -79,8 +78,8 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
"battv": SensorEntityDescription(
|
"battv": SensorEntityDescription(
|
||||||
key="battv",
|
key="battv",
|
||||||
name="UPS Battery Voltage",
|
name="UPS Battery Voltage",
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
icon="mdi:flash",
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
),
|
),
|
||||||
"bcharge": SensorEntityDescription(
|
"bcharge": SensorEntityDescription(
|
||||||
key="bcharge",
|
key="bcharge",
|
||||||
@ -151,8 +150,8 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
"hitrans": SensorEntityDescription(
|
"hitrans": SensorEntityDescription(
|
||||||
key="hitrans",
|
key="hitrans",
|
||||||
name="UPS Transfer High",
|
name="UPS Transfer High",
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
icon="mdi:flash",
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
),
|
),
|
||||||
"hostname": SensorEntityDescription(
|
"hostname": SensorEntityDescription(
|
||||||
key="hostname",
|
key="hostname",
|
||||||
@ -169,7 +168,7 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
"itemp": SensorEntityDescription(
|
"itemp": SensorEntityDescription(
|
||||||
key="itemp",
|
key="itemp",
|
||||||
name="UPS Internal Temperature",
|
name="UPS Internal Temperature",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
),
|
),
|
||||||
"laststest": SensorEntityDescription(
|
"laststest": SensorEntityDescription(
|
||||||
@ -191,14 +190,14 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
"linefreq": SensorEntityDescription(
|
"linefreq": SensorEntityDescription(
|
||||||
key="linefreq",
|
key="linefreq",
|
||||||
name="UPS Line Frequency",
|
name="UPS Line Frequency",
|
||||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
||||||
icon="mdi:information-outline",
|
device_class=SensorDeviceClass.FREQUENCY,
|
||||||
),
|
),
|
||||||
"linev": SensorEntityDescription(
|
"linev": SensorEntityDescription(
|
||||||
key="linev",
|
key="linev",
|
||||||
name="UPS Input Voltage",
|
name="UPS Input Voltage",
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
icon="mdi:flash",
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
),
|
),
|
||||||
"loadpct": SensorEntityDescription(
|
"loadpct": SensorEntityDescription(
|
||||||
key="loadpct",
|
key="loadpct",
|
||||||
@ -215,8 +214,8 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
"lotrans": SensorEntityDescription(
|
"lotrans": SensorEntityDescription(
|
||||||
key="lotrans",
|
key="lotrans",
|
||||||
name="UPS Transfer Low",
|
name="UPS Transfer Low",
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
icon="mdi:flash",
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
),
|
),
|
||||||
"mandate": SensorEntityDescription(
|
"mandate": SensorEntityDescription(
|
||||||
key="mandate",
|
key="mandate",
|
||||||
@ -232,8 +231,8 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
"maxlinev": SensorEntityDescription(
|
"maxlinev": SensorEntityDescription(
|
||||||
key="maxlinev",
|
key="maxlinev",
|
||||||
name="UPS Input Voltage High",
|
name="UPS Input Voltage High",
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
icon="mdi:flash",
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
),
|
),
|
||||||
"maxtime": SensorEntityDescription(
|
"maxtime": SensorEntityDescription(
|
||||||
key="maxtime",
|
key="maxtime",
|
||||||
@ -249,8 +248,8 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
"minlinev": SensorEntityDescription(
|
"minlinev": SensorEntityDescription(
|
||||||
key="minlinev",
|
key="minlinev",
|
||||||
name="UPS Input Voltage Low",
|
name="UPS Input Voltage Low",
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
icon="mdi:flash",
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
),
|
),
|
||||||
"mintimel": SensorEntityDescription(
|
"mintimel": SensorEntityDescription(
|
||||||
key="mintimel",
|
key="mintimel",
|
||||||
@ -266,26 +265,26 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
"nombattv": SensorEntityDescription(
|
"nombattv": SensorEntityDescription(
|
||||||
key="nombattv",
|
key="nombattv",
|
||||||
name="UPS Battery Nominal Voltage",
|
name="UPS Battery Nominal Voltage",
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
icon="mdi:flash",
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
),
|
),
|
||||||
"nominv": SensorEntityDescription(
|
"nominv": SensorEntityDescription(
|
||||||
key="nominv",
|
key="nominv",
|
||||||
name="UPS Nominal Input Voltage",
|
name="UPS Nominal Input Voltage",
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
icon="mdi:flash",
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
),
|
),
|
||||||
"nomoutv": SensorEntityDescription(
|
"nomoutv": SensorEntityDescription(
|
||||||
key="nomoutv",
|
key="nomoutv",
|
||||||
name="UPS Nominal Output Voltage",
|
name="UPS Nominal Output Voltage",
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
icon="mdi:flash",
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
),
|
),
|
||||||
"nompower": SensorEntityDescription(
|
"nompower": SensorEntityDescription(
|
||||||
key="nompower",
|
key="nompower",
|
||||||
name="UPS Nominal Output Power",
|
name="UPS Nominal Output Power",
|
||||||
native_unit_of_measurement=POWER_WATT,
|
native_unit_of_measurement=UnitOfPower.WATT,
|
||||||
icon="mdi:flash",
|
device_class=SensorDeviceClass.POWER,
|
||||||
),
|
),
|
||||||
"nomapnt": SensorEntityDescription(
|
"nomapnt": SensorEntityDescription(
|
||||||
key="nomapnt",
|
key="nomapnt",
|
||||||
@ -301,14 +300,14 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
"outcurnt": SensorEntityDescription(
|
"outcurnt": SensorEntityDescription(
|
||||||
key="outcurnt",
|
key="outcurnt",
|
||||||
name="UPS Output Current",
|
name="UPS Output Current",
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
|
||||||
icon="mdi:flash",
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
),
|
),
|
||||||
"outputv": SensorEntityDescription(
|
"outputv": SensorEntityDescription(
|
||||||
key="outputv",
|
key="outputv",
|
||||||
name="UPS Output Voltage",
|
name="UPS Output Voltage",
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||||
icon="mdi:flash",
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
),
|
),
|
||||||
"reg1": SensorEntityDescription(
|
"reg1": SensorEntityDescription(
|
||||||
key="reg1",
|
key="reg1",
|
||||||
@ -416,17 +415,17 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
SPECIFIC_UNITS = {"ITEMP": TEMP_CELSIUS}
|
SPECIFIC_UNITS = {"ITEMP": UnitOfTemperature.CELSIUS}
|
||||||
INFERRED_UNITS = {
|
INFERRED_UNITS = {
|
||||||
" Minutes": TIME_MINUTES,
|
" Minutes": UnitOfTime.MINUTES,
|
||||||
" Seconds": TIME_SECONDS,
|
" Seconds": UnitOfTime.SECONDS,
|
||||||
" Percent": PERCENTAGE,
|
" Percent": PERCENTAGE,
|
||||||
" Volts": ELECTRIC_POTENTIAL_VOLT,
|
" Volts": UnitOfElectricPotential.VOLT,
|
||||||
" Ampere": ELECTRIC_CURRENT_AMPERE,
|
" Ampere": UnitOfElectricCurrent.AMPERE,
|
||||||
" Volt-Ampere": UnitOfApparentPower.VOLT_AMPERE,
|
" Volt-Ampere": UnitOfApparentPower.VOLT_AMPERE,
|
||||||
" Watts": POWER_WATT,
|
" Watts": UnitOfPower.WATT,
|
||||||
" Hz": FREQUENCY_HERTZ,
|
" Hz": UnitOfFrequency.HERTZ,
|
||||||
" C": TEMP_CELSIUS,
|
" C": UnitOfTemperature.CELSIUS,
|
||||||
" Percent Load Capacity": PERCENTAGE,
|
" Percent Load Capacity": PERCENTAGE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user