mirror of https://github.com/home-assistant/core
Use device classes in mysensors (#83653)
This commit is contained in:
parent
b44e8673a8
commit
55b996f5db
|
@ -15,22 +15,20 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import (
|
||||
CONDUCTIVITY,
|
||||
DEGREE,
|
||||
ELECTRIC_POTENTIAL_MILLIVOLT,
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
LENGTH_METERS,
|
||||
LIGHT_LUX,
|
||||
MASS_KILOGRAMS,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
VOLUME_CUBIC_METERS,
|
||||
Platform,
|
||||
UnitOfApparentPower,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfElectricPotential,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfLength,
|
||||
UnitOfMass,
|
||||
UnitOfPower,
|
||||
UnitOfSoundPressure,
|
||||
UnitOfTemperature,
|
||||
UnitOfVolume,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
@ -94,12 +92,12 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||
),
|
||||
"V_WEIGHT": SensorEntityDescription(
|
||||
key="V_WEIGHT",
|
||||
native_unit_of_measurement=MASS_KILOGRAMS,
|
||||
native_unit_of_measurement=UnitOfMass.KILOGRAMS,
|
||||
device_class=SensorDeviceClass.WEIGHT,
|
||||
),
|
||||
"V_DISTANCE": SensorEntityDescription(
|
||||
key="V_DISTANCE",
|
||||
native_unit_of_measurement=LENGTH_METERS,
|
||||
native_unit_of_measurement=UnitOfLength.METERS,
|
||||
device_class=SensorDeviceClass.DISTANCE,
|
||||
),
|
||||
"V_IMPEDANCE": SensorEntityDescription(
|
||||
|
@ -108,13 +106,13 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||
),
|
||||
"V_WATT": SensorEntityDescription(
|
||||
key="V_WATT",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
"V_KWH": SensorEntityDescription(
|
||||
key="V_KWH",
|
||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
|
||||
device_class=SensorDeviceClass.ENERGY,
|
||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||
),
|
||||
|
@ -125,12 +123,14 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||
),
|
||||
"V_FLOW": SensorEntityDescription(
|
||||
key="V_FLOW",
|
||||
native_unit_of_measurement=LENGTH_METERS,
|
||||
native_unit_of_measurement=UnitOfLength.METERS,
|
||||
icon="mdi:gauge",
|
||||
device_class=SensorDeviceClass.DISTANCE,
|
||||
),
|
||||
"V_VOLUME": SensorEntityDescription(
|
||||
key="V_VOLUME",
|
||||
native_unit_of_measurement=VOLUME_CUBIC_METERS,
|
||||
native_unit_of_measurement=UnitOfVolume.CUBIC_METERS,
|
||||
device_class=SensorDeviceClass.VOLUME,
|
||||
),
|
||||
"V_LEVEL_S_SOUND": SensorEntityDescription(
|
||||
key="V_LEVEL_S_SOUND",
|
||||
|
@ -139,7 +139,7 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||
),
|
||||
"V_LEVEL_S_VIBRATION": SensorEntityDescription(
|
||||
key="V_LEVEL_S_VIBRATION",
|
||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
||||
),
|
||||
"V_LEVEL_S_LIGHT_LEVEL": SensorEntityDescription(
|
||||
key="V_LEVEL_S_LIGHT_LEVEL",
|
||||
|
@ -154,7 +154,7 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||
),
|
||||
"V_VOLTAGE": SensorEntityDescription(
|
||||
key="V_VOLTAGE",
|
||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
|
@ -170,7 +170,8 @@ SENSORS: dict[str, SensorEntityDescription] = {
|
|||
),
|
||||
"V_ORP": SensorEntityDescription(
|
||||
key="V_ORP",
|
||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_MILLIVOLT,
|
||||
native_unit_of_measurement=UnitOfElectricPotential.MILLIVOLT,
|
||||
device_class=SensorDeviceClass.VOLTAGE,
|
||||
),
|
||||
"V_EC": SensorEntityDescription(
|
||||
key="V_EC",
|
||||
|
@ -245,8 +246,8 @@ class MySensorsSensor(mysensors.device.MySensorsEntity, SensorEntity):
|
|||
|
||||
if set_req(self.value_type) == set_req.V_TEMP:
|
||||
if self.hass.config.units is METRIC_SYSTEM:
|
||||
return TEMP_CELSIUS
|
||||
return TEMP_FAHRENHEIT
|
||||
return UnitOfTemperature.CELSIUS
|
||||
return UnitOfTemperature.FAHRENHEIT
|
||||
|
||||
if hasattr(self, "entity_description"):
|
||||
return self.entity_description.native_unit_of_measurement
|
||||
|
|
Loading…
Reference in New Issue