azerty9971 / xtend_tuya

eXtend Tuya's integration
GNU General Public License v3.0
30 stars 4 forks source link

Adjustment Factor #23

Closed TobiasPSP closed 2 weeks ago

TobiasPSP commented 2 weeks ago

I am using a couple of generic Tuya Plugs with energy monitoring, plus a more professional Tuya energy monitoring device that is mounted directly to the house fuse box.

Your integration is phantastic and provides me with the missing entities.

For some reason though, the consumption displayed for the simple plugs is right on, whereas the consumption reading for the main energy monitor is off by factor 10 (i.e. instead of 100.6kWh it shows 10.06kWh).

What could be causing this, and is there possibly a way to add a correction factor so I wouldn't have to resort to helper sensors?

Many thanks!

TobiasPSP commented 2 weeks ago

After running the devices for a while, it turned out that no correction factor is needed.

Your integration simply seems to ignore the previously consumed energy and sums up the consumption from the point in time when I added the integration, basically starting at zero.

That‘s probably why my plug counted correctly: it was brand new and had no previous consumption logged before.

These findings surprised me: it feels a bit like the „calculation“ methods I used earlier where HA would sum up the available entities to calculate the total consumption.

My understanding was that your integration is reading the consumption values directly from the device/the tuya API.

When I for example clear the consumption counter via the Tuya app, your integration continues to increment the consumption regardless.

Without further insight into how and where you get the consumption data, I am happy and can work around this. But maybe you can shed some light on how the inner workings of your integration get to the consumption values.

In a perfect world, I‘d like the consumption entity to match the value shown in the original Tuya app of course.

Many thanks for all the work you invested!

TobiasPSP commented 2 weeks ago

I had to re-authenticate with Tuya after I installed a new HA version, and now all works fine. Beats me why that is, but now the consumption entity matches the values displayed in the SmartLife app.

azerty9971 commented 2 weeks ago

Hello, The way the integration works is indeed by adding the reported energy consumption deltas that are sent by the Tuya cloud. This means that you won't get the history data that was there before the installation but as soon as you install the integration the new energy data should match exactly what you have in your Tuya/Smart Life app.

For now I haven't found a way to import the history energy consumption, I'll try to see if that is possible in the future...

Have a nice day, Azerty