Skip to content

Commit a51ecd0

Browse files
authored
Add myuplink unit-based sensor descriptions (home-assistant#110370)
* Add more unit-based sensor descriptions * Adjust energy sensor state class to TOTAL_INCREASING
1 parent e3c838d commit a51ecd0

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

homeassistant/components/myuplink/sensor.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Sensor for myUplink."""
22

3-
from myuplink.models import DevicePoint
3+
from myuplink import DevicePoint
44

55
from homeassistant.components.sensor import (
66
SensorDeviceClass,
@@ -11,8 +11,13 @@
1111
from homeassistant.config_entries import ConfigEntry
1212
from homeassistant.const import (
1313
UnitOfElectricCurrent,
14+
UnitOfEnergy,
1415
UnitOfFrequency,
16+
UnitOfPower,
17+
UnitOfPressure,
1518
UnitOfTemperature,
19+
UnitOfTime,
20+
UnitOfVolumeFlowRate,
1621
)
1722
from homeassistant.core import HomeAssistant
1823
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@@ -29,18 +34,63 @@
2934
state_class=SensorStateClass.MEASUREMENT,
3035
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
3136
),
37+
"°F": SensorEntityDescription(
38+
key="fahrenheit",
39+
device_class=SensorDeviceClass.TEMPERATURE,
40+
state_class=SensorStateClass.MEASUREMENT,
41+
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
42+
),
3243
"A": SensorEntityDescription(
3344
key="ampere",
3445
device_class=SensorDeviceClass.CURRENT,
3546
state_class=SensorStateClass.MEASUREMENT,
3647
native_unit_of_measurement=UnitOfElectricCurrent.AMPERE,
3748
),
49+
"bar": SensorEntityDescription(
50+
key="pressure",
51+
device_class=SensorDeviceClass.PRESSURE,
52+
state_class=SensorStateClass.MEASUREMENT,
53+
native_unit_of_measurement=UnitOfPressure.BAR,
54+
),
55+
"h": SensorEntityDescription(
56+
key="hours",
57+
device_class=SensorDeviceClass.DURATION,
58+
state_class=SensorStateClass.MEASUREMENT,
59+
native_unit_of_measurement=UnitOfTime.HOURS,
60+
suggested_display_precision=1,
61+
),
3862
"Hz": SensorEntityDescription(
3963
key="hertz",
4064
device_class=SensorDeviceClass.FREQUENCY,
4165
state_class=SensorStateClass.MEASUREMENT,
4266
native_unit_of_measurement=UnitOfFrequency.HERTZ,
4367
),
68+
"kW": SensorEntityDescription(
69+
key="power",
70+
device_class=SensorDeviceClass.POWER,
71+
state_class=SensorStateClass.MEASUREMENT,
72+
native_unit_of_measurement=UnitOfPower.KILO_WATT,
73+
),
74+
"kWh": SensorEntityDescription(
75+
key="energy",
76+
device_class=SensorDeviceClass.ENERGY,
77+
state_class=SensorStateClass.TOTAL_INCREASING,
78+
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
79+
),
80+
"m3/h": SensorEntityDescription(
81+
key="airflow",
82+
device_class=SensorDeviceClass.VOLUME_FLOW_RATE,
83+
state_class=SensorStateClass.MEASUREMENT,
84+
native_unit_of_measurement=UnitOfVolumeFlowRate.CUBIC_METERS_PER_HOUR,
85+
icon="mdi:weather-windy",
86+
),
87+
"s": SensorEntityDescription(
88+
key="seconds",
89+
device_class=SensorDeviceClass.DURATION,
90+
state_class=SensorStateClass.MEASUREMENT,
91+
native_unit_of_measurement=UnitOfTime.SECONDS,
92+
suggested_display_precision=0,
93+
),
4494
}
4595

4696
MARKER_FOR_UNKNOWN_VALUE = -32768

0 commit comments

Comments
 (0)