diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index 67e2ad19008..4fd614172fd 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -465,6 +465,84 @@ RPC_SENSORS: Final = { device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL_INCREASING, ), + "total_act": RpcSensorDescription( + key="emdata", + sub_key="total_act", + name="Total active energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + value=lambda status, _: round(float(status) / 1000, 2), + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + ), + "a_total_act_energy": RpcSensorDescription( + key="emdata", + sub_key="a_total_act_energy", + name="Phase A total active energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + value=lambda status, _: round(float(status) / 1000, 2), + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + entity_registry_enabled_default=False, + ), + "b_total_act_energy": RpcSensorDescription( + key="emdata", + sub_key="b_total_act_energy", + name="Phase B total active energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + value=lambda status, _: round(float(status) / 1000, 2), + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + entity_registry_enabled_default=False, + ), + "c_total_act_energy": RpcSensorDescription( + key="emdata", + sub_key="c_total_act_energy", + name="Phase C total active energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + value=lambda status, _: round(float(status) / 1000, 2), + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + entity_registry_enabled_default=False, + ), + "total_act_ret": RpcSensorDescription( + key="emdata", + sub_key="total_act_ret", + name="Total active returned energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + value=lambda status, _: round(float(status) / 1000, 2), + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + ), + "a_total_act_ret_energy": RpcSensorDescription( + key="emdata", + sub_key="a_total_act_ret_energy", + name="Phase A total active returned energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + value=lambda status, _: round(float(status) / 1000, 2), + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + entity_registry_enabled_default=False, + ), + "b_total_act_ret_energy": RpcSensorDescription( + key="emdata", + sub_key="b_total_act_ret_energy", + name="Phase B total active returned energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + value=lambda status, _: round(float(status) / 1000, 2), + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + entity_registry_enabled_default=False, + ), + "c_total_act_ret_energy": RpcSensorDescription( + key="emdata", + sub_key="c_total_act_ret_energy", + name="Phase C total active returned energy", + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, + value=lambda status, _: round(float(status) / 1000, 2), + device_class=SensorDeviceClass.ENERGY, + state_class=SensorStateClass.TOTAL_INCREASING, + entity_registry_enabled_default=False, + ), "temperature": RpcSensorDescription( key="switch", sub_key="temperature", diff --git a/homeassistant/components/shelly/utils.py b/homeassistant/components/shelly/utils.py index 95fbf94a83b..55c08620e81 100644 --- a/homeassistant/components/shelly/utils.py +++ b/homeassistant/components/shelly/utils.py @@ -284,6 +284,7 @@ def get_model_name(info: dict[str, Any]) -> str: def get_rpc_channel_name(device: RpcDevice, key: str) -> str: """Get name based on device and channel name.""" + key = key.replace("emdata", "em") if device.config.get("switch:0"): key = key.replace("input", "switch") device_name = device.name