al-one / hass-xiaomi-miot

Automatic integrate all Xiaomi devices to HomeAssistant via miot-spec, support Wi-Fi, BLE, ZigBee devices. 小米米家智能家居设备接入Hass集成
https://miot-spec.com
Apache License 2.0
4.17k stars 584 forks source link

Xiaomi Smart Plug 2 WIFI sensor shows 0 as Power Consumption #1347

Open try4cou opened 9 months ago

try4cou commented 9 months ago

Device model / 设备型号

cuco.plug.v2eur

Component version / 插件版本

0.7.13

HA core version / HA版本

2023.10.1

Integrated mode / 集成方式

Automatic (自动模式)

The problem / 问题详情

Integration of Xiaomi Mi Smart Plug 2 (https://www.mi.com/global/product/xiaomi-smart-plug-2-wi-fi/) cuco.plug.v2eur as entity in Home Assistant via Xiaomi Miot Auto works well, but the sensor that records the consumption (Power Consumption) does not show values. It always shows 0 as power consuption.

Entity attributes / 实体属性

state_class: total_increasing entity_class: MiotSensorSubEntity parent_entity_id: switch.cuco_v2eur_b49f_switch service_description: Power Consumption property_description: Power Consumption updated_time: '2023-10-09T20:49:01.957822+02:00' power_consumption: 0 unit_of_measurement: Wh friendly_name: Xiaomi Smart Plug Power Consumption supported_features: 0

Home Assistant Logs / 系统日志

No response

al-one commented 9 months ago

Please provide debug logs.

ekorsanov01 commented 6 months ago

2023-12-18 10:47:39.094 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration xiaomi_miot which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2023-12-18 10:47:39.095 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant 2023-12-18 10:47:54.124 DEBUG (SyncWorker_5) [custom_components.xiaomi_miot.core.xiaomi_cloud] Request miot api: v2/message/v2/check_new_msg {'begin_at': 1702889213} result: bytearray(b'{"code":0,"message":"ok","result":false}') 2023-12-18 10:47:54.139 DEBUG (MainThread) [custom_components.xiaomi_miot] Setup xiaomi cloud for user: 41656XXXXX, 3 devices 2023-12-18 10:47:54.269 DEBUG (MainThread) [custom_components.xiaomi_miot] Xiaomi cloud device: {'name': 'Mi Smart LED Bulb Essential (White and Color)', 'host': '192.168.10.23', 'token': '', 'model': 'yeelink.light.color5', 'miot_did': '454789597', 'miot_type': 'urn:miot-spec-v2:device:light:0000A001:yeelink-color5:1', 'miio_info': {'ap': {'ssid': 'CYTA_M2m3', 'bssid': '------', 'rssi': -82}, 'netif': {'localIp': '192.168.10.23', 'gw': '', 'mask': ''}, 'fw_ver': '2.0.8_0022', 'hw_ver': '', 'mac': '---', 'model': 'yeelink.light.color5', 'token': ''}, 'conn_mode': 'local', 'miot_local': True, 'miot_cloud': False, 'home_name': '41656XXXXX', 'room_name': 'Сашина', 'entry_id': 'fdb634364224f48a2b1677739127b5c0', 'config_version': 0.3} 2023-12-18 10:47:54.383 DEBUG (MainThread) [custom_components.xiaomi_miot] Xiaomi cloud device: {'name': 'Mi WiFi Range Extender AC1200', 'host': '192.168.10.6', 'token': '', 'model': 'xiaomi.repeater.v6', 'miot_did': '607182275', 'miot_type': 'urn:miot-spec-v2:device:repeater:0000A037:xiaomi-v6:1', 'miio_info': {'ap': {'ssid': 'CYTA_M2m3', 'bssid': '-----', 'rssi': -85}, 'netif': {'localIp': '192.168.10.6', 'gw': '', 'mask': ''}, 'fw_ver': '1.0.94', 'hw_ver': '', 'mac': '---', 'model': 'xiaomi.repeater.v6', 'token': ''}, 'conn_mode': 'local', 'miot_local': True, 'miot_cloud': False, 'home_name': '41656XXXXX', 'room_name': 'спальня', 'entry_id': 'fdb634364224f48a2b1677739127b5c0', 'config_version': 0.3} 2023-12-18 10:47:54.498 DEBUG (MainThread) [custom_components.xiaomi_miot] Xiaomi cloud device: {'name': 'Xiaomi Smart Plug 2 (Wi-Fi)', 'host': '192.168.10.30', 'token': '', 'model': 'cuco.plug.v2eur', 'miot_did': '676082617', 'miot_type': 'urn:miot-spec-v2:device:outlet:0000A002:cuco-v2eur:1', 'miio_info': {'ap': {'ssid': 'CYTA_M2m3', 'bssid': '-----', 'rssi': -57}, 'netif': {'localIp': '192.168.10.30', 'gw': '', 'mask': ''}, 'fw_ver': '1.0.6', 'hw_ver': '', 'mac': '---', 'model': 'cuco.plug.v2eur', 'token': ''}, 'conn_mode': 'local', 'miot_local': True, 'miot_cloud': False, 'home_name': '41656XXXXX', 'room_name': 'спальня', 'entry_id': 'fdb634364224f48a2b1677739127b5c0', 'config_version': 0.3} 2023-12-18 10:47:54.669 DEBUG (MainThread) [custom_components.xiaomi_miot.sensor] xiaomi scene history 41656XXXXX 180001065350, async_added_to_hass restore state: state= None attrs= {'entity_class': 'MihomeSceneHistorySensor'} 2023-12-18 10:47:54.729 INFO (MainThread) [custom_components.xiaomi_miot.switch] Xiaomi Smart Plug 2 (Wi-Fi)(cuco.plug.v2eur): Initializing miot device with mapping: {'switch.on': {'siid': 2, 'piid': 1}, 'switch.default_power_on_state': {'siid': 2, 'piid': 2}, 'switch.fault': {'siid': 2, 'piid': 3}, 'max_power_limit.on': {'siid': 9, 'piid': 1}, 'max_power_limit.power': {'siid': 9, 'piid': 2}, 'cycle.status': {'siid': 5, 'piid': 1}, 'cycle.data_value': {'siid': 5, 'piid': 2}, 'charging_protection.on': {'siid': 4, 'piid': 1}, 'charging_protection.power': {'siid': 4, 'piid': 2}, 'protect_time-4-3': {'siid': 4, 'piid': 3}, 'delay': {'siid': 14, 'piid': 1}, 'delay.delay_time': {'siid': 14, 'piid': 2}, 'delay.delay_remain_time': {'siid': 14, 'piid': 3}, 'indicator_light.on': {'siid': 13, 'piid': 1}, 'power_consumption': {'siid': 11, 'piid': 1}, 'electric_power-11-2': {'siid': 11, 'piid': 2}, 'physical_controls_locked': {'siid': 7, 'piid': 1}} 2023-12-18 10:47:54.747 INFO (MainThread) [custom_components.xiaomi_miot.light] Mi Smart LED Bulb Essential (White and Color)(yeelink.light.color5): Initializing miot device with mapping: {'light.on': {'siid': 2, 'piid': 1}, 'light.brightness': {'siid': 2, 'piid': 2}, 'light.color_temperature': {'siid': 2, 'piid': 3}, 'light.color': {'siid': 2, 'piid': 4}, 'light.mode': {'siid': 2, 'piid': 5}, 'light.nl_br': {'siid': 2, 'piid': 101}, 'light.off_delay_time': {'siid': 2, 'piid': 102}} 2023-12-18 10:47:54.968 DEBUG (SyncWorker_0) [custom_components.xiaomi_miot.core.xiaomi_cloud] Request miot api: v2/message/v2/typelist {} result: bytearray(b'{"code":0,"message":"ok","result":{"messages":null}}') 2023-12-18 10:47:54.970 WARNING (MainThread) [custom_components.xiaomi_miot.sensor] Get xiaomi message for 41656XXXXX failed: {'code': 0, 'message': 'ok', 'result': {'messages': None}} 2023-12-18 10:47:54.970 DEBUG (MainThread) [custom_components.xiaomi_miot.sensor] Finished fetching xiaomi_miot-mihome-message-41656XXXXX data in 0.315 seconds (success: True) 2023-12-18 10:47:54.991 DEBUG (SyncWorker_1) [custom_components.xiaomi_miot.core.xiaomi_cloud] Request miot api: scene/history {'home_id': 18000XXXXXXX, 'uid': 41656XXXXX, 'owner_uid': 41656XXXXX, 'command': 'history', 'limit': 15} result: bytearray(b'{"code":0,"message":"\xe6\x88\x90\xe5\x8a\x9f","result":{"history":[]}}') 2023-12-18 10:47:54.992 WARNING (MainThread) [custom_components.xiaomi_miot.sensor] Get xiaomi scene history for 41656XXXXX 18000XXXXXXX failed: {'code': 0, 'message': '成功', 'result': {'history': []}} 2023-12-18 10:47:54.992 DEBUG (MainThread) [custom_components.xiaomi_miot.sensor] Finished fetching xiaomi_miot-mihome-scene-history-41656XXXXX_18000XXXXXXX data in 0.323 seconds (success: True) 2023-12-18 10:47:55.413 DEBUG (MainThread) [custom_components.xiaomi_miot.switch] Xiaomi Smart Plug 2 (Wi-Fi)(cuco.plug.v2eur): Got new state: {'switch.on': True, 'switch.default_power_on_state': 0, 'switch.fault': 0, 'max_power_limit.on': False, 'max_power_limit.power': 3600, 'cycle.status': False, 'cycle.data_value': '30;30;0;1', 'charging_protection.on': False, 'charging_protection.power': 2, 'protect_time-4-3': 5, 'delay': False, 'delay.delay_time': 60, 'delay.delay_remain_time': 0, 'indicator_light.on': True, 'power_consumption': 0, 'electric_power-11-2': 0, 'physical_controls_locked': False, 'state_updater': 'lan'} 2023-12-18 10:47:55.414 DEBUG (MainThread) [custom_components.xiaomi_miot.switch] Xiaomi Smart Plug 2 (Wi-Fi)(cuco.plug.v2eur): Added to hass: [{'main_miot_services': 'switch-2'}] 2023-12-18 10:47:59.758 ERROR (MainThread) [custom_components.xiaomi_miot.light] Mi Smart LED Bulb Essential (White and Color)(yeelink.light.color5): Got MiioException while fetching the state: Unable to discover the device 192.168.10.23, mapping: {'light.on': {'siid': 2, 'piid': 1}, 'light.brightness': {'siid': 2, 'piid': 2}, 'light.color_temperature': {'siid': 2, 'piid': 3}, 'light.color': {'siid': 2, 'piid': 4}, 'light.mode': {'siid': 2, 'piid': 5}, 'light.nl_br': {'siid': 2, 'piid': 101}, 'light.off_delay_time': {'siid': 2, 'piid': 102}}, max_properties: 10/7 2023-12-18 10:47:59.760 DEBUG (MainThread) [custom_components.xiaomi_miot.light] Mi Smart LED Bulb Essential (White and Color)(yeelink.light.color5): Added to hass: [{'number_properties': 'off_delay_time', 'switch_properties': 'bg_on', 'main_miot_services': 'light-2', 'extend_miot_specs': 'yeelink.light.color1'}] 2023-12-18 10:48:10.321 DEBUG (SyncWorker_3) [custom_components.xiaomi_miot.core.xiaomi_cloud] Request miot api: scene/history {'home_id': 18000XXXXXXX, 'uid': 41656XXXXX, 'owner_uid': 41656XXXXX, 'command': 'history', 'limit': 15} result: bytearray(b'{"code":0,"message":"\xe6\x88\x90\xe5\x8a\x9f","result":{"history":[]}}') 2023-12-18 10:48:10.324 DEBUG (MainThread) [custom_components.xiaomi_miot.sensor] Finished fetching xiaomi_miot-mihome-scene-history-41656XXXXX_18000XXXXXXX data in 0.387 seconds (success: True) 2023-12-18 10:48:10.369 DEBUG (SyncWorker_4) [custom_components.xiaomi_miot.core.xiaomi_cloud] Request miot api: v2/message/v2/typelist {} result: bytearray(b'{"code":0,"message":"ok","result":{"messages":null}}') 2023-12-18 10:48:10.371 DEBUG (MainThread) [custom_components.xiaomi_miot.sensor] Finished fetching xiaomi_miot-mihome-message-41656XXXXX data in 0.302 seconds (success: True)

ekorsanov01 commented 6 months ago

Please provide debug logs.

I have the same problem, is there a solution?

mihome screenshot: mihome

jerry411 commented 5 months ago

+1

LordZozzy commented 5 months ago

+1

AlexKratky commented 5 months ago

same issue

GazdagGabor commented 4 months ago

+1

swas commented 4 months ago

+1

al-one commented 4 months ago

Try master branch.

Komzpa commented 4 months ago

Hello, I updated to the new release and the new tunables start showing for me. I appreciate that they are now tunable. However, can they be moved from Controls to Configuration, so that they don't show up on dashboards by default? I have a dozen of them and suddenly the dashboard became a lot larger. I am currently on a trip to manually hide them but maybe there's a better way.

image

Additionally, the electricity consumption history is still not going through, the current consumption goes through though. Here's from my heater via app:

image

and via HA:

image

Komzpa commented 4 months ago

I upgraded v0.7.16 to v0.7.17 and the monthly and daily consumed is now showing up. Controls are still in a bit inconvenient spot.

image

Komzpa commented 3 months ago

I added a new plug into the Xiaomi app and it got imported into HA. There is one stray entity:

image image

Komzpa commented 3 months ago

The plug in my kitchen hob stopped reporting live power usage. It did before update.

No data on dash: image

There is something that looks like current live power usage in "attributes" if I unfold these image

The only thing I can find in logs that might be relevant:

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:719
integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: March 20, 2024 at 1:12:05 PM (4 occurrences)
Last logged: March 20, 2024 at 1:12:06 PM

Platform xiaomi_miot does not generate unique IDs. ID d4:f0:ea:2a:b1:95-3fe80335f83d07e48f9bdaf987040461-power_consumption-11.electric_power-2 is already used by sensor.cuco_v2eur_b195_electric_power - ignoring sensor.cuco_v2eur_b195_electric_power
Platform xiaomi_miot does not generate unique IDs. ID 64:9e:31:bd:1f:f8-3fe80335f83d07e48f9bdaf987040461-power_consumption-11.electric_power-2 is already used by sensor.cuco_v2eur_1ff8_electric_power - ignoring sensor.cuco_v2eur_1ff8_electric_power
Platform xiaomi_miot does not generate unique IDs. ID 64:9e:31:b1:3d:e9-3fe80335f83d07e48f9bdaf987040461-power_consumption-11.electric_power-2 is already used by sensor.cuco_v2eur_3de9_electric_power - ignoring sensor.cuco_v2eur_3de9_electric_power
Platform xiaomi_miot does not generate unique IDs. ID d4:f0:ea:33:3a:34-3fe80335f83d07e48f9bdaf987040461-power_consumption-11.electric_power-2 is already used by sensor.cuco_v2eur_3a34_electric_power - ignoring sensor.cuco_v2eur_3a34_electric_power
swas commented 3 months ago

Same here Since the last update the power cosumption sensor is always 0 W

swas commented 2 months ago

No fix yet?

sunnyiiii commented 2 months ago

I have the same problem. But I found this is not related to the XIAOMI MIoT integration. I updated the integration to V0.7.18 With any core version after 2024.2.5 the update stops to work.

swas commented 2 months ago

Yes.

Since HA core versión 2024.3, cuco.plug power cosumption sensors stops working.

sunnyiiii commented 1 month ago

Any updates on this?

sunnyiiii commented 1 month ago

Anyone tested the latest version, 2024.6.2? Is this still an issue?

Komzpa commented 3 weeks ago

Yes, this is still an issue.