mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Correct units for sensors in nibe heatpump (#80140)
This commit is contained in:
parent
30920c3da7
commit
1c86a12233
@ -19,6 +19,7 @@ from homeassistant.const import (
|
|||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
ENERGY_MEGA_WATT_HOUR,
|
ENERGY_MEGA_WATT_HOUR,
|
||||||
ENERGY_WATT_HOUR,
|
ENERGY_WATT_HOUR,
|
||||||
|
POWER_WATT,
|
||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
TEMP_FAHRENHEIT,
|
TEMP_FAHRENHEIT,
|
||||||
TIME_HOURS,
|
TIME_HOURS,
|
||||||
@ -72,24 +73,31 @@ UNIT_DESCRIPTIONS = {
|
|||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_MILLIVOLT,
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_MILLIVOLT,
|
||||||
),
|
),
|
||||||
|
"W": SensorEntityDescription(
|
||||||
|
key="W",
|
||||||
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
|
device_class=SensorDeviceClass.POWER,
|
||||||
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
|
native_unit_of_measurement=POWER_WATT,
|
||||||
|
),
|
||||||
"Wh": SensorEntityDescription(
|
"Wh": SensorEntityDescription(
|
||||||
key="Wh",
|
key="Wh",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||||
),
|
),
|
||||||
"kWh": SensorEntityDescription(
|
"kWh": SensorEntityDescription(
|
||||||
key="kWh",
|
key="kWh",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
),
|
),
|
||||||
"MWh": SensorEntityDescription(
|
"MWh": SensorEntityDescription(
|
||||||
key="MWh",
|
key="MWh",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
device_class=SensorDeviceClass.POWER,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
state_class=SensorStateClass.TOTAL_INCREASING,
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
native_unit_of_measurement=ENERGY_MEGA_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_MEGA_WATT_HOUR,
|
||||||
),
|
),
|
||||||
@ -97,6 +105,7 @@ UNIT_DESCRIPTIONS = {
|
|||||||
key="h",
|
key="h",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
device_class=SensorDeviceClass.DURATION,
|
device_class=SensorDeviceClass.DURATION,
|
||||||
|
state_class=SensorStateClass.TOTAL_INCREASING,
|
||||||
native_unit_of_measurement=TIME_HOURS,
|
native_unit_of_measurement=TIME_HOURS,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@ -133,6 +142,7 @@ class Sensor(CoilEntity, SensorEntity):
|
|||||||
self.entity_description = entity_description
|
self.entity_description = entity_description
|
||||||
else:
|
else:
|
||||||
self._attr_native_unit_of_measurement = coil.unit
|
self._attr_native_unit_of_measurement = coil.unit
|
||||||
|
self._attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||||
|
|
||||||
def _async_read_coil(self, coil: Coil):
|
def _async_read_coil(self, coil: Coil):
|
||||||
self._attr_native_value = coil.value
|
self._attr_native_value = coil.value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user