mirror of
https://github.com/home-assistant/core.git
synced 2026-09-03 18:24:49 -05:00
Scale only when needed
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -779,7 +779,7 @@ async def test_unsupported_attributes_sensor(
|
||||
(
|
||||
1,
|
||||
1232000,
|
||||
"123.2",
|
||||
"123.20",
|
||||
UnitOfVolume.CUBIC_METERS,
|
||||
),
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user