From e50c4c47870ccb18e1be00f4d22ac6654fee06cd Mon Sep 17 00:00:00 2001 From: Maciej Bieniek Date: Sun, 19 Oct 2025 00:46:57 +0200 Subject: [PATCH] Fix units for Shelly TopAC EVE01-11 sensors (#154740) --- homeassistant/components/shelly/sensor.py | 12 ++++-------- tests/components/shelly/snapshots/test_sensor.ambr | 3 --- tests/components/shelly/test_sensor.py | 4 ++-- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index 5a6592a8f71..64ef9847249 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -1549,8 +1549,7 @@ RPC_SENSORS: Final = { "number_energy_charge": RpcSensorDescription( key="number", sub_key="value", - native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, - suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, suggested_display_precision=2, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL, @@ -1594,8 +1593,7 @@ RPC_SENSORS: Final = { key="object", sub_key="value", value=lambda status, _: float(status["counter"]["total"]), - native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, - suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, suggested_display_precision=2, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL_INCREASING, @@ -1606,8 +1604,7 @@ RPC_SENSORS: Final = { sub_key="value", name="Energy", value=lambda status, _: float(status["total_act_energy"]), - native_unit_of_measurement=UnitOfEnergy.WATT_HOUR, - suggested_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, suggested_display_precision=2, device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL_INCREASING, @@ -1618,8 +1615,7 @@ RPC_SENSORS: Final = { sub_key="value", name="Power", value=lambda status, _: float(status["total_power"]), - native_unit_of_measurement=UnitOfPower.WATT, - suggested_unit_of_measurement=UnitOfPower.KILO_WATT, + native_unit_of_measurement=UnitOfPower.KILO_WATT, suggested_display_precision=2, device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, diff --git a/tests/components/shelly/snapshots/test_sensor.ambr b/tests/components/shelly/snapshots/test_sensor.ambr index 09dc06c514a..11892f586a6 100644 --- a/tests/components/shelly/snapshots/test_sensor.ambr +++ b/tests/components/shelly/snapshots/test_sensor.ambr @@ -507,9 +507,6 @@ 'sensor': dict({ 'suggested_display_precision': 2, }), - 'sensor.private': dict({ - 'suggested_unit_of_measurement': , - }), }), 'original_device_class': , 'original_icon': None, diff --git a/tests/components/shelly/test_sensor.py b/tests/components/shelly/test_sensor.py index 00c08cb7868..6e6a626eb5e 100644 --- a/tests/components/shelly/test_sensor.py +++ b/tests/components/shelly/test_sensor.py @@ -1723,7 +1723,7 @@ async def test_rpc_shelly_ev_sensors( } config["number:201"] = { "name": "Session energy", - "meta": {"ui": {"unit": "Wh", "view": "label"}}, + "meta": {"ui": {"unit": "kWh", "view": "label"}}, "role": "energy_charge", } config["number:202"] = { @@ -1735,7 +1735,7 @@ async def test_rpc_shelly_ev_sensors( status = deepcopy(mock_rpc_device.status) status["number:200"] = {"value": "charger_charging"} - status["number:201"] = {"value": 5000} + status["number:201"] = {"value": 5.0} status["number:202"] = {"value": 60} monkeypatch.setattr(mock_rpc_device, "status", status)