Use core varh unit constant for Fronius (#180890)

This commit is contained in:
Matthias Alphart
2026-08-31 09:16:12 +02:00
committed by GitHub
parent 1100225b16
commit 5d75f39cb4
2 changed files with 12 additions and 13 deletions
+4 -5
View File
@@ -2,7 +2,7 @@
from collections.abc import Callable
from dataclasses import dataclass
from typing import TYPE_CHECKING, Any, Final, override
from typing import TYPE_CHECKING, Any, override
from homeassistant.components.sensor import (
SensorDeviceClass,
@@ -20,6 +20,7 @@ from homeassistant.const import (
UnitOfEnergy,
UnitOfFrequency,
UnitOfPower,
UnitOfReactiveEnergy,
UnitOfReactivePower,
UnitOfTemperature,
)
@@ -59,8 +60,6 @@ if TYPE_CHECKING:
PARALLEL_UPDATES = 0
ENERGY_VOLT_AMPERE_REACTIVE_HOUR: Final = "varh"
async def async_setup_entry(
hass: HomeAssistant,
@@ -405,14 +404,14 @@ METER_ENTITY_DESCRIPTIONS: list[FroniusSensorEntityDescription] = [
),
FroniusSensorEntityDescription(
key="energy_reactive_ac_consumed",
native_unit_of_measurement=ENERGY_VOLT_AMPERE_REACTIVE_HOUR,
native_unit_of_measurement=UnitOfReactiveEnergy.VOLT_AMPERE_REACTIVE_HOUR,
state_class=SensorStateClass.TOTAL_INCREASING,
entity_registry_enabled_default=False,
invalid_when_falsy=True,
),
FroniusSensorEntityDescription(
key="energy_reactive_ac_produced",
native_unit_of_measurement=ENERGY_VOLT_AMPERE_REACTIVE_HOUR,
native_unit_of_measurement=UnitOfReactiveEnergy.VOLT_AMPERE_REACTIVE_HOUR,
state_class=SensorStateClass.TOTAL_INCREASING,
entity_registry_enabled_default=False,
invalid_when_falsy=True,
@@ -1823,7 +1823,7 @@
'supported_features': 0,
'translation_key': 'energy_reactive_ac_consumed',
'unique_id': '1234567890-energy_reactive_ac_consumed',
'unit_of_measurement': 'varh',
'unit_of_measurement': <UnitOfReactiveEnergy.VOLT_AMPERE_REACTIVE_HOUR: 'varh'>,
})
# ---
# name: test_gen24[sensor.smart_meter_ts_65a_3_reactive_energy_consumed-state]
@@ -1831,7 +1831,7 @@
'attributes': ReadOnlyDict({
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Smart Meter TS 65A-3 Reactive energy consumed',
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: 'varh',
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfReactiveEnergy.VOLT_AMPERE_REACTIVE_HOUR: 'varh'>,
}),
'context': <ANY>,
'entity_id': 'sensor.smart_meter_ts_65a_3_reactive_energy_consumed',
@@ -1877,7 +1877,7 @@
'supported_features': 0,
'translation_key': 'energy_reactive_ac_produced',
'unique_id': '1234567890-energy_reactive_ac_produced',
'unit_of_measurement': 'varh',
'unit_of_measurement': <UnitOfReactiveEnergy.VOLT_AMPERE_REACTIVE_HOUR: 'varh'>,
})
# ---
# name: test_gen24[sensor.smart_meter_ts_65a_3_reactive_energy_produced-state]
@@ -1885,7 +1885,7 @@
'attributes': ReadOnlyDict({
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Smart Meter TS 65A-3 Reactive energy produced',
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: 'varh',
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfReactiveEnergy.VOLT_AMPERE_REACTIVE_HOUR: 'varh'>,
}),
'context': <ANY>,
'entity_id': 'sensor.smart_meter_ts_65a_3_reactive_energy_produced',
@@ -6008,7 +6008,7 @@
'supported_features': 0,
'translation_key': 'energy_reactive_ac_consumed',
'unique_id': '1234567890-energy_reactive_ac_consumed',
'unit_of_measurement': 'varh',
'unit_of_measurement': <UnitOfReactiveEnergy.VOLT_AMPERE_REACTIVE_HOUR: 'varh'>,
})
# ---
# name: test_gen24_storage[sensor.smart_meter_ts_65a_3_reactive_energy_consumed-state]
@@ -6016,7 +6016,7 @@
'attributes': ReadOnlyDict({
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Smart Meter TS 65A-3 Reactive energy consumed',
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: 'varh',
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfReactiveEnergy.VOLT_AMPERE_REACTIVE_HOUR: 'varh'>,
}),
'context': <ANY>,
'entity_id': 'sensor.smart_meter_ts_65a_3_reactive_energy_consumed',
@@ -6062,7 +6062,7 @@
'supported_features': 0,
'translation_key': 'energy_reactive_ac_produced',
'unique_id': '1234567890-energy_reactive_ac_produced',
'unit_of_measurement': 'varh',
'unit_of_measurement': <UnitOfReactiveEnergy.VOLT_AMPERE_REACTIVE_HOUR: 'varh'>,
})
# ---
# name: test_gen24_storage[sensor.smart_meter_ts_65a_3_reactive_energy_produced-state]
@@ -6070,7 +6070,7 @@
'attributes': ReadOnlyDict({
<EntityStateAttribute.FRIENDLY_NAME: 'friendly_name'>: 'Smart Meter TS 65A-3 Reactive energy produced',
<SensorEntityCapabilityAttribute.STATE_CLASS: 'state_class'>: <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: 'varh',
<EntityStateAttribute.UNIT_OF_MEASUREMENT: 'unit_of_measurement'>: <UnitOfReactiveEnergy.VOLT_AMPERE_REACTIVE_HOUR: 'varh'>,
}),
'context': <ANY>,
'entity_id': 'sensor.smart_meter_ts_65a_3_reactive_energy_produced',