From 8fb6f9065e249f6ae2380f6f1d1876e1d4173153 Mon Sep 17 00:00:00 2001 From: Zeyu Li Date: Tue, 21 Jan 2025 16:09:58 +0800 Subject: [PATCH] fix: add prop trans rule for surge-power (#595) * fix: potentiaol problems for properties identification error for sensors * fix incorrect SPEC name --- .../xiaomi_home/miot/specs/specv2entity.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/custom_components/xiaomi_home/miot/specs/specv2entity.py b/custom_components/xiaomi_home/miot/specs/specv2entity.py index c5bdbea..19023bb 100644 --- a/custom_components/xiaomi_home/miot/specs/specv2entity.py +++ b/custom_components/xiaomi_home/miot/specs/specv2entity.py @@ -399,6 +399,14 @@ SPEC_PROP_TRANS_MAP: dict[str, dict | str] = { 'unit_of_measurement': UnitOfElectricPotential.VOLT } }, + 'electric-current': { + 'device_class': SensorDeviceClass.CURRENT, + 'entity': 'sensor', + 'optional': { + 'state_class': SensorStateClass.MEASUREMENT, + 'unit_of_measurement': UnitOfElectricCurrent.AMPERE + } + }, 'illumination': { 'device_class': SensorDeviceClass.ILLUMINANCE, 'entity': 'sensor' @@ -415,12 +423,12 @@ SPEC_PROP_TRANS_MAP: dict[str, dict | str] = { 'unit_of_measurement': UnitOfPower.WATT } }, - 'electric-current': { - 'device_class': SensorDeviceClass.CURRENT, + 'surge-power': { + 'device_class': SensorDeviceClass.POWER, 'entity': 'sensor', 'optional': { 'state_class': SensorStateClass.MEASUREMENT, - 'unit_of_measurement': UnitOfElectricCurrent.AMPERE + 'unit_of_measurement': UnitOfPower.WATT } }, 'power-consumption': {