Add support for entity categories to NUT entities (#57689)

This commit is contained in:
Michael 2021-10-14 22:51:31 +02:00 committed by GitHub
parent 7104750008
commit 997d014111
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,6 +16,8 @@ from homeassistant.components.sensor import (
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE, ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT, ELECTRIC_POTENTIAL_VOLT,
ENTITY_CATEGORY_CONFIG,
ENTITY_CATEGORY_DIAGNOSTIC,
FREQUENCY_HERTZ, FREQUENCY_HERTZ,
PERCENTAGE, PERCENTAGE,
POWER_VOLT_AMPERE, POWER_VOLT_AMPERE,
@ -68,6 +70,7 @@ SENSOR_TYPES: Final[dict[str, SensorEntityDescription]] = {
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT, state_class=STATE_CLASS_MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
), ),
"ups.load": SensorEntityDescription( "ups.load": SensorEntityDescription(
key="ups.load", key="ups.load",
@ -81,6 +84,7 @@ SENSOR_TYPES: Final[dict[str, SensorEntityDescription]] = {
name="Overload Setting", name="Overload Setting",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon="mdi:gauge", icon="mdi:gauge",
entity_category=ENTITY_CATEGORY_CONFIG,
), ),
"ups.id": SensorEntityDescription( "ups.id": SensorEntityDescription(
key="ups.id", key="ups.id",
@ -92,18 +96,21 @@ SENSOR_TYPES: Final[dict[str, SensorEntityDescription]] = {
name="Load Restart Delay", name="Load Restart Delay",
native_unit_of_measurement=TIME_SECONDS, native_unit_of_measurement=TIME_SECONDS,
icon="mdi:timer-outline", icon="mdi:timer-outline",
entity_category=ENTITY_CATEGORY_CONFIG,
), ),
"ups.delay.reboot": SensorEntityDescription( "ups.delay.reboot": SensorEntityDescription(
key="ups.delay.reboot", key="ups.delay.reboot",
name="UPS Reboot Delay", name="UPS Reboot Delay",
native_unit_of_measurement=TIME_SECONDS, native_unit_of_measurement=TIME_SECONDS,
icon="mdi:timer-outline", icon="mdi:timer-outline",
entity_category=ENTITY_CATEGORY_CONFIG,
), ),
"ups.delay.shutdown": SensorEntityDescription( "ups.delay.shutdown": SensorEntityDescription(
key="ups.delay.shutdown", key="ups.delay.shutdown",
name="UPS Shutdown Delay", name="UPS Shutdown Delay",
native_unit_of_measurement=TIME_SECONDS, native_unit_of_measurement=TIME_SECONDS,
icon="mdi:timer-outline", icon="mdi:timer-outline",
entity_category=ENTITY_CATEGORY_CONFIG,
), ),
"ups.timer.start": SensorEntityDescription( "ups.timer.start": SensorEntityDescription(
key="ups.timer.start", key="ups.timer.start",
@ -128,16 +135,19 @@ SENSOR_TYPES: Final[dict[str, SensorEntityDescription]] = {
name="Self-Test Interval", name="Self-Test Interval",
native_unit_of_measurement=TIME_SECONDS, native_unit_of_measurement=TIME_SECONDS,
icon="mdi:timer-outline", icon="mdi:timer-outline",
entity_category=ENTITY_CATEGORY_CONFIG,
), ),
"ups.test.result": SensorEntityDescription( "ups.test.result": SensorEntityDescription(
key="ups.test.result", key="ups.test.result",
name="Self-Test Result", name="Self-Test Result",
icon="mdi:information-outline", icon="mdi:information-outline",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
), ),
"ups.test.date": SensorEntityDescription( "ups.test.date": SensorEntityDescription(
key="ups.test.date", key="ups.test.date",
name="Self-Test Date", name="Self-Test Date",
icon="mdi:calendar", icon="mdi:calendar",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
), ),
"ups.display.language": SensorEntityDescription( "ups.display.language": SensorEntityDescription(
key="ups.display.language", key="ups.display.language",
@ -196,6 +206,7 @@ SENSOR_TYPES: Final[dict[str, SensorEntityDescription]] = {
key="ups.watchdog.status", key="ups.watchdog.status",
name="Watchdog Status", name="Watchdog Status",
icon="mdi:information-outline", icon="mdi:information-outline",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
), ),
"ups.start.auto": SensorEntityDescription( "ups.start.auto": SensorEntityDescription(
key="ups.start.auto", key="ups.start.auto",
@ -229,6 +240,7 @@ SENSOR_TYPES: Final[dict[str, SensorEntityDescription]] = {
name="Low Battery Setpoint", name="Low Battery Setpoint",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon="mdi:gauge", icon="mdi:gauge",
entity_category=ENTITY_CATEGORY_CONFIG,
), ),
"battery.charge.restart": SensorEntityDescription( "battery.charge.restart": SensorEntityDescription(
key="battery.charge.restart", key="battery.charge.restart",
@ -241,6 +253,7 @@ SENSOR_TYPES: Final[dict[str, SensorEntityDescription]] = {
name="Warning Battery Setpoint", name="Warning Battery Setpoint",
native_unit_of_measurement=PERCENTAGE, native_unit_of_measurement=PERCENTAGE,
icon="mdi:gauge", icon="mdi:gauge",
entity_category=ENTITY_CATEGORY_CONFIG,
), ),
"battery.charger.status": SensorEntityDescription( "battery.charger.status": SensorEntityDescription(
key="battery.charger.status", key="battery.charger.status",
@ -297,12 +310,14 @@ SENSOR_TYPES: Final[dict[str, SensorEntityDescription]] = {
native_unit_of_measurement=TEMP_CELSIUS, native_unit_of_measurement=TEMP_CELSIUS,
device_class=DEVICE_CLASS_TEMPERATURE, device_class=DEVICE_CLASS_TEMPERATURE,
state_class=STATE_CLASS_MEASUREMENT, state_class=STATE_CLASS_MEASUREMENT,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
), ),
"battery.runtime": SensorEntityDescription( "battery.runtime": SensorEntityDescription(
key="battery.runtime", key="battery.runtime",
name="Battery Runtime", name="Battery Runtime",
native_unit_of_measurement=TIME_SECONDS, native_unit_of_measurement=TIME_SECONDS,
icon="mdi:timer-outline", icon="mdi:timer-outline",
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
), ),
"battery.runtime.low": SensorEntityDescription( "battery.runtime.low": SensorEntityDescription(
key="battery.runtime.low", key="battery.runtime.low",
@ -320,6 +335,7 @@ SENSOR_TYPES: Final[dict[str, SensorEntityDescription]] = {
key="battery.alarm.threshold", key="battery.alarm.threshold",
name="Battery Alarm Threshold", name="Battery Alarm Threshold",
icon="mdi:information-outline", icon="mdi:information-outline",
entity_category=ENTITY_CATEGORY_CONFIG,
), ),
"battery.date": SensorEntityDescription( "battery.date": SensorEntityDescription(
key="battery.date", key="battery.date",