Scale only when needed

This commit is contained in:
Jan-Philipp Benecke
2024-01-12 20:31:01 +01:00
parent ddbdbbc161
commit a9e0403402
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -494,7 +494,7 @@ class SmartEnergyMeteringEntityDescription(SensorEntityDescription):
key: str = "instantaneous_demand"
state_class: SensorStateClass | None = SensorStateClass.MEASUREMENT
scale: int = 1
scale: int | None = None
@MULTI_MATCH(
@@ -608,7 +608,7 @@ class SmartEnergyMetering(PollableSensor):
description = self._ENTITY_DESCRIPTION_MAP.get(
self._cluster_handler.unit_of_measurement
)
if description is not None and state is not None:
if description and description.scale and state:
return float(state) * description.scale
return state
+1 -1
View File
@@ -779,7 +779,7 @@ async def test_unsupported_attributes_sensor(
(
1,
1232000,
"123.2",
"123.20",
UnitOfVolume.CUBIC_METERS,
),
(