mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 06:17:07 +00:00
Use new enums in mysensors (#61935)
This commit is contained in:
parent
b03ead1c9b
commit
c9dbcc49e3
@ -3,13 +3,9 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from homeassistant.components import mysensors
|
from homeassistant.components import mysensors
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
DEVICE_CLASS_MOISTURE,
|
|
||||||
DEVICE_CLASS_MOTION,
|
|
||||||
DEVICE_CLASS_SAFETY,
|
|
||||||
DEVICE_CLASS_SOUND,
|
|
||||||
DEVICE_CLASS_VIBRATION,
|
|
||||||
DEVICE_CLASSES,
|
DEVICE_CLASSES,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
BinarySensorDeviceClass,
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -23,13 +19,13 @@ from .helpers import on_unload
|
|||||||
|
|
||||||
SENSORS = {
|
SENSORS = {
|
||||||
"S_DOOR": "door",
|
"S_DOOR": "door",
|
||||||
"S_MOTION": DEVICE_CLASS_MOTION,
|
"S_MOTION": BinarySensorDeviceClass.MOTION,
|
||||||
"S_SMOKE": "smoke",
|
"S_SMOKE": "smoke",
|
||||||
"S_SPRINKLER": DEVICE_CLASS_SAFETY,
|
"S_SPRINKLER": BinarySensorDeviceClass.SAFETY,
|
||||||
"S_WATER_LEAK": DEVICE_CLASS_SAFETY,
|
"S_WATER_LEAK": BinarySensorDeviceClass.SAFETY,
|
||||||
"S_SOUND": DEVICE_CLASS_SOUND,
|
"S_SOUND": BinarySensorDeviceClass.SOUND,
|
||||||
"S_VIBRATION": DEVICE_CLASS_VIBRATION,
|
"S_VIBRATION": BinarySensorDeviceClass.VIBRATION,
|
||||||
"S_MOISTURE": DEVICE_CLASS_MOISTURE,
|
"S_MOISTURE": BinarySensorDeviceClass.MOISTURE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,22 +8,15 @@ from awesomeversion import AwesomeVersion
|
|||||||
from homeassistant.components import mysensors
|
from homeassistant.components import mysensors
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
STATE_CLASS_MEASUREMENT,
|
SensorDeviceClass,
|
||||||
STATE_CLASS_TOTAL_INCREASING,
|
|
||||||
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 (
|
||||||
CONDUCTIVITY,
|
CONDUCTIVITY,
|
||||||
DEGREE,
|
DEGREE,
|
||||||
DEVICE_CLASS_CURRENT,
|
|
||||||
DEVICE_CLASS_ENERGY,
|
|
||||||
DEVICE_CLASS_HUMIDITY,
|
|
||||||
DEVICE_CLASS_ILLUMINANCE,
|
|
||||||
DEVICE_CLASS_POWER,
|
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
|
||||||
DEVICE_CLASS_VOLTAGE,
|
|
||||||
ELECTRIC_CURRENT_AMPERE,
|
ELECTRIC_CURRENT_AMPERE,
|
||||||
ELECTRIC_POTENTIAL_MILLIVOLT,
|
ELECTRIC_POTENTIAL_MILLIVOLT,
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
ELECTRIC_POTENTIAL_VOLT,
|
||||||
@ -50,14 +43,14 @@ from .helpers import on_unload
|
|||||||
SENSORS: dict[str, SensorEntityDescription] = {
|
SENSORS: dict[str, SensorEntityDescription] = {
|
||||||
"V_TEMP": SensorEntityDescription(
|
"V_TEMP": SensorEntityDescription(
|
||||||
key="V_TEMP",
|
key="V_TEMP",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"V_HUM": SensorEntityDescription(
|
"V_HUM": SensorEntityDescription(
|
||||||
key="V_HUM",
|
key="V_HUM",
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
device_class=DEVICE_CLASS_HUMIDITY,
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"V_DIMMER": SensorEntityDescription(
|
"V_DIMMER": SensorEntityDescription(
|
||||||
key="V_DIMMER",
|
key="V_DIMMER",
|
||||||
@ -115,14 +108,14 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
"V_WATT": SensorEntityDescription(
|
"V_WATT": SensorEntityDescription(
|
||||||
key="V_WATT",
|
key="V_WATT",
|
||||||
native_unit_of_measurement=POWER_WATT,
|
native_unit_of_measurement=POWER_WATT,
|
||||||
device_class=DEVICE_CLASS_POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"V_KWH": SensorEntityDescription(
|
"V_KWH": SensorEntityDescription(
|
||||||
key="V_KWH",
|
key="V_KWH",
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
),
|
),
|
||||||
"V_LIGHT_LEVEL": SensorEntityDescription(
|
"V_LIGHT_LEVEL": SensorEntityDescription(
|
||||||
key="V_LIGHT_LEVEL",
|
key="V_LIGHT_LEVEL",
|
||||||
@ -150,8 +143,8 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
"V_LEVEL_S_LIGHT_LEVEL": SensorEntityDescription(
|
"V_LEVEL_S_LIGHT_LEVEL": SensorEntityDescription(
|
||||||
key="V_LEVEL_S_LIGHT_LEVEL",
|
key="V_LEVEL_S_LIGHT_LEVEL",
|
||||||
native_unit_of_measurement=LIGHT_LUX,
|
native_unit_of_measurement=LIGHT_LUX,
|
||||||
device_class=DEVICE_CLASS_ILLUMINANCE,
|
device_class=SensorDeviceClass.ILLUMINANCE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"V_LEVEL_S_MOISTURE": SensorEntityDescription(
|
"V_LEVEL_S_MOISTURE": SensorEntityDescription(
|
||||||
key="V_LEVEL_S_MOISTURE",
|
key="V_LEVEL_S_MOISTURE",
|
||||||
@ -161,14 +154,14 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||||||
"V_VOLTAGE": SensorEntityDescription(
|
"V_VOLTAGE": SensorEntityDescription(
|
||||||
key="V_VOLTAGE",
|
key="V_VOLTAGE",
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"V_CURRENT": SensorEntityDescription(
|
"V_CURRENT": SensorEntityDescription(
|
||||||
key="V_CURRENT",
|
key="V_CURRENT",
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
"V_PH": SensorEntityDescription(
|
"V_PH": SensorEntityDescription(
|
||||||
key="V_PH",
|
key="V_PH",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user