Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
try4cou opened this issue Oct 9, 2023 · 38 comments
Closed

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

try4cou opened this issue Oct 9, 2023 · 38 comments

Comments

@try4cou
Copy link

try4cou commented Oct 9, 2023

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
Copy link
Owner

al-one commented Oct 12, 2023

Please provide debug logs.

@ekorsanov01
Copy link

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
Copy link

Please provide debug logs.

I have the same problem,
is there a solution?

mihome screenshot:
mihome

@jerry411
Copy link

+1

1 similar comment
@LordZozzy
Copy link

+1

@AlexKratky
Copy link

same issue

@GazdagGabor
Copy link

+1

1 similar comment
@swas
Copy link

swas commented Feb 29, 2024

+1

@al-one
Copy link
Owner

al-one commented Mar 6, 2024

Try master branch.

@Komzpa
Copy link

Komzpa commented Mar 16, 2024

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
Copy link

Komzpa commented Mar 16, 2024

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
Copy link

Komzpa commented Mar 18, 2024

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

image
image

@Komzpa
Copy link

Komzpa commented Mar 21, 2024

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
Copy link

swas commented Mar 21, 2024

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

@swas
Copy link

swas commented Apr 30, 2024

No fix yet?

@sunnyiiii
Copy link

sunnyiiii commented May 6, 2024

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
Copy link

swas commented May 8, 2024

Yes.

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

@sunnyiiii
Copy link

Any updates on this?

@sunnyiiii
Copy link

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

@Komzpa
Copy link

Komzpa commented Jun 18, 2024

Yes, this is still an issue.

@sunnyiiii
Copy link

Just tested 2024.7.3. This is still an issue. Can someone please take a look at this?

@sunnyiiii

This comment was marked as off-topic.

@beqabeqa473
Copy link

is there any progress? For me it is also showing 0w

@sunnyiiii
Copy link

I am using 2024.9.1 same problem.

Can someone please take a look at this?

@Taronaga
Copy link

Hello everyone!
Version HA 2024.10.2.
The issue is still relevant!!!

@al-one
Copy link
Owner

al-one commented Oct 28, 2024

Debug logs need to be provided.
xiaomi_miot_debug

@sunnyiiii

This comment has been minimized.

@al-one
Copy link
Owner

al-one commented Oct 28, 2024

@sunnyiiii Not cuco.plug.v2eur!

@sunnyiiii
Copy link

sunnyiiii commented Oct 28, 2024

@al-one, I thought this was related. I have another thread that is specific for the lumi.plug.v1. I wasn't sure if it is the core issue or miot. Because, it was working all the way until a core version update.

home-assistant/core#114690

#1781

@Komzpa
Copy link

Komzpa commented Oct 31, 2024

Hello, I slowly dug into this:

  • The problem of duplicate ids is really a problem of upgrade. It leaves behind the old entity and creates a new one with -2 at the end which starts using. This can be "fixed" manually by removing the old one manually (loses the stats alas, but by now you've lost a lot of it anyway)

  • The problem of readings of 0 is really a problem of a wrong scale being applied. If you plug something that consumes a lot into the plug, it starts reading not-0, however not nearly enough.

Here is screenshot from my energy dashboard. All the devices are tracked using the v2eur device of this thread, most of consumption should be covered in principle but you can see it taking around 10% of total, so I assume that scaling is off by 10x lower. Is it gets below 0.01 it seemingly becomes 0 which might be another reason for 0 reports in the thread.

image

I hope this helps.

@Komzpa
Copy link

Komzpa commented Oct 31, 2024

For reference, here is my AC as seen in the HA.
image

Here it is from the app:
image

Note that current consumption matches (it's in fan mode now) and monthly is 10x off.

@al-one
Copy link
Owner

al-one commented Nov 1, 2024

@Komzpa Try master branch.

@Komzpa
Copy link

Komzpa commented Nov 1, 2024

Does not seem to help. I feel like this line overrides what you define for the plug as it goes later?

@sunnyiiii
Copy link

@Komzpa, in your last comment you said to remove the old entity. Do you mean the entity in HA? Can you please point me to how I can do this? Just delete the broken one from the xiaomi miot integration?

In this case, the entity ends with "Power Consumption"?

image

@sunnyiiii
Copy link

sunnyiiii commented Nov 5, 2024

For reference: I am getting the following error

logs.txt

@al-one
Copy link
Owner

al-one commented Nov 18, 2024

@Komzpa
Copy link

Komzpa commented Nov 20, 2024

With latest release the situation improved. Now monthly consumption shows fine. Daily is still on zeros. Great progress!

image
image

There is also an issue that sometimes for no obvious reason the consumption drops to zero. This messes up the Energy dashboard as it believes the consumption is very very high. I guess these need to get filtered or maybe they are produced as a side effect of some other bug?

image

image

@sunnyiiii
Copy link

Looks like the v1.0.0b3 working find now. Many thanks. Can you please push to official?

image

@al-one al-one closed this as completed Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests