mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use state and device class enum in Rfxtrx (#60773)
This commit is contained in:
parent
0c89c8a6b4
commit
d60517d5f4
@ -8,23 +8,14 @@ import logging
|
|||||||
from RFXtrx import ControlEvent, SensorEvent
|
from RFXtrx import ControlEvent, SensorEvent
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
DEVICE_CLASS_BATTERY,
|
SensorDeviceClass,
|
||||||
DEVICE_CLASS_HUMIDITY,
|
|
||||||
DEVICE_CLASS_SIGNAL_STRENGTH,
|
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
|
||||||
STATE_CLASS_MEASUREMENT,
|
|
||||||
STATE_CLASS_TOTAL_INCREASING,
|
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_DEVICES,
|
CONF_DEVICES,
|
||||||
DEGREE,
|
DEGREE,
|
||||||
DEVICE_CLASS_CURRENT,
|
|
||||||
DEVICE_CLASS_ENERGY,
|
|
||||||
DEVICE_CLASS_POWER,
|
|
||||||
DEVICE_CLASS_PRESSURE,
|
|
||||||
DEVICE_CLASS_VOLTAGE,
|
|
||||||
ELECTRIC_CURRENT_AMPERE,
|
ELECTRIC_CURRENT_AMPERE,
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
ELECTRIC_POTENTIAL_VOLT,
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
@ -77,94 +68,94 @@ class RfxtrxSensorEntityDescription(SensorEntityDescription):
|
|||||||
SENSOR_TYPES = (
|
SENSOR_TYPES = (
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Barometer",
|
key="Barometer",
|
||||||
device_class=DEVICE_CLASS_PRESSURE,
|
device_class=SensorDeviceClass.PRESSURE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=PRESSURE_HPA,
|
native_unit_of_measurement=PRESSURE_HPA,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Battery numeric",
|
key="Battery numeric",
|
||||||
device_class=DEVICE_CLASS_BATTERY,
|
device_class=SensorDeviceClass.BATTERY,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
convert=_battery_convert,
|
convert=_battery_convert,
|
||||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Current",
|
key="Current",
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Current Ch. 1",
|
key="Current Ch. 1",
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Current Ch. 2",
|
key="Current Ch. 2",
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Current Ch. 3",
|
key="Current Ch. 3",
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Energy usage",
|
key="Energy usage",
|
||||||
device_class=DEVICE_CLASS_POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=POWER_WATT,
|
native_unit_of_measurement=POWER_WATT,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Humidity",
|
key="Humidity",
|
||||||
device_class=DEVICE_CLASS_HUMIDITY,
|
device_class=SensorDeviceClass.HUMIDITY,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Rssi numeric",
|
key="Rssi numeric",
|
||||||
device_class=DEVICE_CLASS_SIGNAL_STRENGTH,
|
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
convert=_rssi_convert,
|
convert=_rssi_convert,
|
||||||
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Temperature",
|
key="Temperature",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Temperature2",
|
key="Temperature2",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Total usage",
|
key="Total usage",
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Voltage",
|
key="Voltage",
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Wind direction",
|
key="Wind direction",
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=DEGREE,
|
native_unit_of_measurement=DEGREE,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Rain rate",
|
key="Rain rate",
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=PRECIPITATION_MILLIMETERS_PER_HOUR,
|
native_unit_of_measurement=PRECIPITATION_MILLIMETERS_PER_HOUR,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
@ -175,33 +166,33 @@ SENSOR_TYPES = (
|
|||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Count",
|
key="Count",
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
native_unit_of_measurement="count",
|
native_unit_of_measurement="count",
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Counter value",
|
key="Counter value",
|
||||||
state_class=STATE_CLASS_TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
native_unit_of_measurement="count",
|
native_unit_of_measurement="count",
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Chill",
|
key="Chill",
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Wind average speed",
|
key="Wind average speed",
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=SPEED_METERS_PER_SECOND,
|
native_unit_of_measurement=SPEED_METERS_PER_SECOND,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Wind gust",
|
key="Wind gust",
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=SPEED_METERS_PER_SECOND,
|
native_unit_of_measurement=SPEED_METERS_PER_SECOND,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="Rain total",
|
key="Rain total",
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=LENGTH_MILLIMETERS,
|
native_unit_of_measurement=LENGTH_MILLIMETERS,
|
||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
@ -215,7 +206,7 @@ SENSOR_TYPES = (
|
|||||||
),
|
),
|
||||||
RfxtrxSensorEntityDescription(
|
RfxtrxSensorEntityDescription(
|
||||||
key="UV",
|
key="UV",
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=UV_INDEX,
|
native_unit_of_measurement=UV_INDEX,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user