File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments