Skip to content

Commit 14b326d

Browse files
committed
POINTTAPI: keep electricity averages informational with kWh unit
1 parent c23f4fb commit 14b326d

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

custom_components/bosch/pointtapi_entities.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,8 +1481,10 @@ def _pointtapi_electricity_average_sensor_descriptions(
14811481
"average", and an average that falls as well as rises is not a TOTAL. Given
14821482
state_class=TOTAL plus last_reset, HA reads every decrease as a meter reset
14831483
and the sensor becomes selectable as an Energy Dashboard source — wrong
1484-
statistics that are painful to unwind. Promote these only once someone has
1485-
watched the value across a full day on real hardware.
1484+
statistics that are painful to unwind. We still expose the numeric values
1485+
with a kWh unit for user visibility, but keep them as plain informational
1486+
sensors. Promote these only once someone has watched the value across a
1487+
full day on real hardware.
14861488
"""
14871489
if not data:
14881490
return ()
@@ -1499,6 +1501,7 @@ def _pointtapi_electricity_average_sensor_descriptions(
14991501
BoschPoinTTAPISensorEntityDescription(
15001502
key=path,
15011503
translation_key=translation_key,
1504+
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
15021505
)
15031506
)
15041507
return tuple(descriptions)

unittests/test_pointtapi_new_entities.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ def test_electricity_averages_carry_no_statistics_metadata(self):
201201
With state_class=TOTAL, every dip in a rolling average reads as a meter
202202
reset and the sensor becomes an Energy Dashboard source. Until someone
203203
confirms on hardware that these accumulate, they stay plain sensors.
204+
205+
They still expose the value in kWh for user-facing information.
204206
"""
205207
data = {
206208
"/energy/electricity/dayAverage": {"value": 3.21, "available": "true"},
@@ -209,6 +211,7 @@ def test_electricity_averages_carry_no_statistics_metadata(self):
209211
descs = {d.key: d for d in _pointtapi_sensor_descriptions(data)}
210212

211213
for path in ("/energy/electricity/dayAverage", "/energy/electricity/monthAverage"):
214+
assert descs[path].native_unit_of_measurement == "kWh"
212215
assert descs[path].device_class is None
213216
assert descs[path].state_class is None
214217
assert descs[path].last_reset_fn is None

0 commit comments

Comments
 (0)