Skip to content

Commit 7267c3c

Browse files
bieniufrenck
authored andcommitted
Fix units for Shelly TopAC EVE01-11 sensors (home-assistant#154740)
1 parent 6ac4d2d commit 7267c3c

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

homeassistant/components/shelly/sensor.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,8 +1554,7 @@ def __init__(
15541554
"number_energy_charge": RpcSensorDescription(
15551555
key="number",
15561556
sub_key="value",
1557-
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
1558-
suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
1557+
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
15591558
suggested_display_precision=2,
15601559
device_class=SensorDeviceClass.ENERGY,
15611560
state_class=SensorStateClass.TOTAL,
@@ -1599,8 +1598,7 @@ def __init__(
15991598
key="object",
16001599
sub_key="value",
16011600
value=lambda status, _: float(status["counter"]["total"]),
1602-
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
1603-
suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
1601+
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
16041602
suggested_display_precision=2,
16051603
device_class=SensorDeviceClass.ENERGY,
16061604
state_class=SensorStateClass.TOTAL_INCREASING,
@@ -1611,8 +1609,7 @@ def __init__(
16111609
sub_key="value",
16121610
name="Total Active Energy",
16131611
value=lambda status, _: float(status["total_act_energy"]),
1614-
native_unit_of_measurement=UnitOfEnergy.WATT_HOUR,
1615-
suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
1612+
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
16161613
suggested_display_precision=2,
16171614
device_class=SensorDeviceClass.ENERGY,
16181615
state_class=SensorStateClass.TOTAL_INCREASING,
@@ -1623,8 +1620,7 @@ def __init__(
16231620
sub_key="value",
16241621
name="Total Power",
16251622
value=lambda status, _: float(status["total_power"]),
1626-
native_unit_of_measurement=UnitOfPower.WATT,
1627-
suggested_unit_of_measurement=UnitOfPower.KILO_WATT,
1623+
native_unit_of_measurement=UnitOfPower.KILO_WATT,
16281624
suggested_display_precision=2,
16291625
device_class=SensorDeviceClass.POWER,
16301626
state_class=SensorStateClass.MEASUREMENT,

tests/components/shelly/snapshots/test_sensor.ambr

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,6 @@
307307
'sensor': dict({
308308
'suggested_display_precision': 2,
309309
}),
310-
'sensor.private': dict({
311-
'suggested_unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
312-
}),
313310
}),
314311
'original_device_class': <SensorDeviceClass.ENERGY: 'energy'>,
315312
'original_icon': None,

tests/components/shelly/test_sensor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,7 @@ async def test_rpc_shelly_ev_sensors(
17141714
}
17151715
config["number:201"] = {
17161716
"name": "Session energy",
1717-
"meta": {"ui": {"unit": "Wh", "view": "label"}},
1717+
"meta": {"ui": {"unit": "kWh", "view": "label"}},
17181718
"role": "energy_charge",
17191719
}
17201720
config["number:202"] = {
@@ -1726,7 +1726,7 @@ async def test_rpc_shelly_ev_sensors(
17261726

17271727
status = deepcopy(mock_rpc_device.status)
17281728
status["number:200"] = {"value": "charger_charging"}
1729-
status["number:201"] = {"value": 5000}
1729+
status["number:201"] = {"value": 5.0}
17301730
status["number:202"] = {"value": 60}
17311731
monkeypatch.setattr(mock_rpc_device, "status", status)
17321732

0 commit comments

Comments
 (0)