From 0a13e0074c82f4ef3f8b50bfb2d64e3d834fc032 Mon Sep 17 00:00:00 2001 From: Brandon Chen Date: Tue, 22 Aug 2023 22:42:48 +0800 Subject: [PATCH] fix energy for qmi.plug.tw02 --- .../xiaomi_miot/core/device_customizes.py | 35 +++++++++++++++++++ .../xiaomi_miot/core/miot_local_devices.py | 1 + 2 files changed, 36 insertions(+) diff --git a/custom_components/xiaomi_miot/core/device_customizes.py b/custom_components/xiaomi_miot/core/device_customizes.py index 8af0f79f3..9157a2f26 100644 --- a/custom_components/xiaomi_miot/core/device_customizes.py +++ b/custom_components/xiaomi_miot/core/device_customizes.py @@ -823,6 +823,41 @@ 'cloud_delay_update': 8, 'miot_type': 'urn:miot-spec-v2:device:air-conditioner:0000A004:qdhkl-b23:2', }, + 'qmi.plug.tw02': { + 'main_miot_services': 'switch-2', + 'sensor_attributes': 'power_cost_today,power_cost_month', + 'sensor_properties': 'switch.temperature', + 'stat_power_cost_key': '4.1', + }, + 'qmi.plug.tw02:electric_power': { + 'unit_of_measurement': 'W', + }, + 'qmi.plug.tw02:electric_current': { + 'value_ratio': 0.001, + 'unit_of_measurement': 'A', + }, + 'qmi.plug.tw02:voltage': { + 'value_ratio': 1, + 'unit_of_measurement': 'V', + }, + 'qmi.plug.tw02:power_consumption': { + 'value_ratio': 1, + 'state_class': "total_increasing", + 'device_class': "energy", + 'unit_of_measurement': "kWh", + }, + 'qmi.plug.tw02:power_cost_today': { + 'value_ratio': 1, + 'state_class': 'total_increasing', + 'device_class': 'energy', + 'unit_of_measurement': 'kWh', + }, + 'qmi.plug.tw02:power_cost_month': { + 'value_ratio': 1, + 'state_class': 'total_increasing', + 'device_class': 'energy', + 'unit_of_measurement': 'kWh', + }, 'qmi.plug.2a1c1': { 'main_miot_services': 'switch-2', 'sensor_attributes': 'power_cost_today,power_cost_month', diff --git a/custom_components/xiaomi_miot/core/miot_local_devices.py b/custom_components/xiaomi_miot/core/miot_local_devices.py index 369cd86b9..1ba2d5310 100644 --- a/custom_components/xiaomi_miot/core/miot_local_devices.py +++ b/custom_components/xiaomi_miot/core/miot_local_devices.py @@ -359,6 +359,7 @@ 'qdhkl.gateway.sm', 'qmdq88.dishwasher.p116', 'qmdq88.dishwasher.s1', + 'qmi.plug.tw02', 'qmi.plug.2a1c1', 'qmi.plug.psv1', 'qshui.blanket.d1',