home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.43k stars 30.67k forks source link

Power metrics cannot be added to "Energy" dashboard due to "No matching statistics found" (Tuya integration) #81113

Closed Boilerplate4u closed 1 year ago

Boilerplate4u commented 2 years ago

The problem

Tuya integration works using the Nedis (WIFIP121FWT) Smart Plug with built-in power meter and the real time values for current, power and voltage are displayed correctly in "Overview" dashboard. However, metrics cannot be added to the "Energy" dashboard due to the error "No matching statistics found" as in:

Settings -> Dashboards -> Energy -> Individual devices -> Add device: Error: "No matching statistics found".

Error message links to "Learn more about statistis" -> https://www.home-assistant.io/more-info/statistics/

"You’re configuring a statistic but you couldn’t find your source in the dropdown? That’s caused by a bug in the integration providing the entity. Integrations need to configure their entities correctly so Home Assistant knows that we need to track statistics for it and how.

Open an issue with the author of the integration and link them to https://developers.home-assistant.io/docs/core/entity/sensor#long-term-statistics."

What version of Home Assistant Core has the issue?

core-2022.10.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Tuya

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tuya

Diagnostics information

config_entry-tuya-7b744dfd1431a904b94ec52d25dc1990.json.txt

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 2 years ago

Hey there @tuya, @zlinoliver, @frenck, mind taking a look at this issue as it has been labeled with an integration (tuya) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `tuya` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Change the title of the issue. - `@home-assistant unassign tuya` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


tuya documentation tuya source (message by IssueLinks)

Boilerplate4u commented 2 years ago

It might be OT and maybe not be related to the current issue but all metrics are disabled by default during initialization of the Tuya integration. This might be the root cause why a lot of people report that the power monitoring isn't working.

kris-haos commented 1 year ago

I have the same problem. What I did in Home Assistant to solve are the ff:

Settings > Devices & Services > Helpers > Create Helper > Integration - Riemann sum integral sensor Under input sensor > selected the entity that outputs power Then click submit

After a few minutes, I can now add it under energy dashboard.

Boilerplate4u commented 1 year ago

@kris-haos: great, thanks a million!!

What integration method did you pick of Trapezoidal, Left Riemann sum or Right Riemann sum? Also, do you have any clue how these settings affects the Energy dashboard?

kris-haos commented 1 year ago

@Boilerplate4u I just used trapezoidal and it's good enough for my use case. I think the options have something to do with calculation accuracy.

This article explains it better than what I can say: https://www.khanacademy.org/math/ap-calculus-ab/ab-integration-new/ab-6-2/a/left-and-right-riemann-sums#:~:text=A%20left%20Riemann%20sum%20uses,vertices%20are%20on%20the%20curve.&text=The%20graph%20of%20the%20function,at%20the%20top%20left%20corners.

cheers!

Boilerplate4u commented 1 year ago

Thanks but I'm familiar with the Riemann rules but can't find any details in the docs regarding how the approximation is supposed be used and how it will affect the outcome of the dashboard. Well I guess I'll have to dig into the source code to find that out eventually. Cheers!

Boilerplate4u commented 1 year ago

I've added three Riemann helpers for power, voltage and current but the issue still persists after 30 mins and a restart of HA.

I'm using Settings -> Dashboards -> Energy -> "Individual devices" -> "Add Device" that still results in the error "No matching statistics found". Very odd indeed!

image

Boilerplate4u commented 1 year ago

@kris-haos Btw, I forgot to ask you if you made this to work specifically with the Tuya integration and what type of power meter device you are using?

pisti222 commented 1 year ago

I have similar problem. I could not add any sensor for energy dashboard, only solaredge visible. I made lot of integration, sensor etc.. based on energy requirements, but does not work. If somebody knows any solution, please share it...

kris-haos commented 1 year ago

@Boilerplate4u, we may have a similar problem. In my case, I played around with the units of the riemann integral sensor and somehow messed it up. Eventually I checked Developer Tools > Statistics, and found related issues. If I remembered correctly, I went to the list of entities and removed the problematic helper. Then started over.

If that did not work, I remember I found something online to get to the SQL database of Home Assistant and manually updating the records from there. Luckily I did not need to do that in my case.

Hope that helps!

PS: yes, I made this to work with Tuya, I have a bunch of smart plugs with power monitoring on them

Boilerplate4u commented 1 year ago

@kris-haos: Thanks, but I've removed and added all the Helpers using different settings a number of times without success.

Since Melcloud worked "out of the box" and I was able to add "Daily Energy Consumed" and "Total Energy" to the Energy dashboard without any further modification I'm quite confident the issue is caused by the Tuya integrator module itself that lacks certain implementations details required by the Enery Dahsboard according to the link the poped up during the error message: https://www.home-assistant.io/more-info/statistics

However if you got the Energy Dashboard to work with Tuya, can you please provide the exact details how and what power meter device you are using? Thanks in advance!

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

Boilerplate4u commented 1 year ago

Ok, will check again and get back!

issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.