dresden-elektronik / deconz-rest-plugin

deCONZ REST-API plugin to control ZigBee devices
BSD 3-Clause "New" or "Revised" License
1.89k stars 497 forks source link

Frient/Develco ZHEMI101 energy meter counting in MWh instead of kWh #6360

Closed engerberg closed 1 year ago

engerberg commented 1 year ago

Describe the bug

When upgrading to Home Assistant addon deCONZ 6.16, the energy meter Develco/Frient ZHEMI101 started counting total consumption in MWh instead of kWh.

Steps to reproduce the behavior

Expected behavior

Screenshots

Switched from 7640 kWh to 7.64 MWh

image

Environment

deCONZ Logs

Additional context

Downgrading to HA addon 6.15 (deCONZ 2.17.1) got it back to normal again.

rhgiter commented 1 year ago

+1

geltzer commented 1 year ago

Same issue here

M203 commented 1 year ago

Me as well. Does it work to downgrade deconz? Will it mess up historic data?

engerberg commented 1 year ago

Me as well. Does it work to downgrade deconz? Will it mess up historic data?

Works to downgrade, but I now have a jump between ~7640 kWh to 7.64 and back to 7640 again over a day or two, which makes it complicated to plot the historic data

SwoopX commented 1 year ago

For a quick solution, you can either edit the DDF (and remove the division by 1000) or delete the DDF. Both requires a restart.

kusk commented 1 year ago

Seeing the same issue.

pfefferle commented 1 year ago

same for me

Mimiix commented 1 year ago

@SwoopX you adjusted the ddf in the codebase?

pfefferle commented 1 year ago

I tried to change the pulseconfiguration using the API, but it seems to automatically reset back to the default short afterwards.

Smanar commented 1 year ago

If the device is

  "manufacturername": ["Develco Products A/S", "frient A/S"],
  "modelid": ["ZHEMI101", "ZHEMI101"],

Take a look in the file develco\zhemi101_external_meter_interface.json

        {
          "name": "state/consumption",
          "refresh.interval": 360,
          "parse": {
            "at": "0x0000",
            "cl": "0x0702",
            "ep": 2,
            "eval": "Item.val = Attr.val / 1000",
            "fn": "zcl"
          }
        },

Remove the /1000 to have a value * 1000.

kusk commented 1 year ago

Will this be fixed in an upcoming version?

Smanar commented 1 year ago

If someone can try the correction and confirm it's working, I will make the PR

jenseo commented 1 year ago

@Smanar I can confirm it works after changing the value to Attr.val without the division in the deconz zigbee vnc application, not sure if this was the correct way to do it...?

jenseo commented 1 year ago

Hmm, might have been to quick to draw that conclusion. Now, after the energy dashboard in HA has started updating the data, it says current energy usage is 11,777.457. So that seems way to high unfortunately..

Smanar commented 1 year ago

So it haven't worked, or the convertion is not enought ? What is the value for 1 day or 1 hour (with unity)?

jenseo commented 1 year ago

This is how it looks when I look at the yearly data, so it seems the / 1000 might have been correct, but it didn't seem to report any data (or very low volumes).

Skärmavbild 2022-10-02 kl  12 43 16

Now when I have reverted back to adding / 1000 again, it seems to be back to underdeliver the amount of kwh. So the question is if something has changed and that we need to do like / 100 or something?

jenseo commented 1 year ago

@Smanar ☝️

Smanar commented 1 year ago

Ha yes, If I remember HA make a calculation. The value returned is a counter, and HA display value by day, so it mean the code remember all values (at least the one at 0h or 24h) and make calculation. So to be sure you need to wait at least 1 complete day

Can check the real value direclty in the json, it the total value since you have installed / reseted the device.

jenseo commented 1 year ago

@Smanar Makes sense! I have removed the / 1000 once again and will wait for it to update properly in the energy dashboard to see how it goes :)

Here's what it's reporting at the current moment anyways:

Skärmavbild 2022-10-04 kl  10 27 34
jenseo commented 1 year ago

It looks off, but maybe that's due to the calculation you talked about, since it says almost 12,000 kWh. Otherwise I guess it's an issue with the . (dot) that's interpreted as a comma or something..?

pfefferle commented 1 year ago

Either you have to not remove the / 1000 but lower it to the matching number (for example / 10) or you can remove it, but lower the pulseconfiguration.

jenseo commented 1 year ago

@pfefferle I'm out on deep water here with changing stuff in the VNC deconz app, but when I changed it there, it reset like the next hour or so. I see that there's also a pulseconfiguration as you say. I think I will await a fix for this that's hopefully released soon, since I'm not sure exactly what I'm doing here 😄

popy2k14 commented 1 year ago

Exact same issue here after upgrading to Home Assistant addon deCONZ 6.16 (= deconz 2.18.2). Is there an working workaround?

@jenseo does removing the division and wait a whole day work?

popy2k14 commented 1 year ago

In my case, removing the division by 1000 and hot reload the DDF worked! Before it showed 0,434 kWh and now 434,71 kWh counting up after the commas.

See here: image

I will let it run for an day and see if the readings are plausible.

jenseo commented 1 year ago

@popy2k14 for me the removal of division reset itself after an hour or so, so haven't been able to verify it unfortunately. Hope this can get fixed soon, the data is all messed up now, I guess it needs to be reset once it starts working again..

kusk commented 1 year ago

Removing / 1000 work fine for me.

jenseo commented 1 year ago

Removing / 1000 work fine for me.

@kusk Where do you remove it without it resetting again after some time?

popy2k14 commented 1 year ago

@jenseo connect with VNC to deconz, select the device, select Edit -> Edit DDF in the menu. Under Items -> consumption -> Expression -> remove the " / 1000". Select File -> Save & File -> Hot Reload.

i have now correct my values in the recorder database with sqlite web addon and multiple statements.

Hope it sticks.

popy2k14 commented 1 year ago

@SwoopX can you please fix this with upcoming release. As confirmed now multiple times, removing / 1000 works.

thx a lot

Qalculus commented 1 year ago

Did someone create a PR for this? Otherwise here is one #6402

BacktrackBtk commented 1 year ago

Been following this thread a bit since last update messed up the values. 6.16 update gives me off the chart values. Removing / 1000 is not the solution for everyone. Iv deleted history of October after updating to 6.16

Skärmavbild 2022-10-29 kl  08 34 07
popy2k14 commented 1 year ago

In 2.19.1 the /1000 is fixed. Since HA was recording also during the switch to /1000 and with now removed /1000 it's messed up. You have to delete your HA recorder database, like here described: https://community.home-assistant.io/t/how-do-i-delete-the-database-on-home-assistant/222962/3?u=popy

But be aware, every recorded backlog is deleted!!!!!!!!!!!! In my case it's not a problem, but i dont know your setup.

Configuration is not affected because it's all stored in yaml files.

BacktrackBtk commented 1 year ago

Thanks for the answer! I meant 2.19.1. I looked at the wrong version. I will try what you suggest

popy2k14 commented 1 year ago

You're welcome.

github-actions[bot] commented 1 year ago

As there has not been any response in 21 days, this issue has been automatically marked as stale. At OP: Please either close this issue or keep it active It will be closed in 7 days if no further activity occurs.

github-actions[bot] commented 1 year ago

As there has not been any response in 28 days, this issue will be closed. @ OP: If this issue is solved post what fixed it for you. If it is not solved, request to get this opened again.

jenseo commented 1 year ago

Hello, I had this issue and hoped that the upgrade + deleting the database would solve it, but unfortunately not. It still counts in Watts instead of KWh it seems. Thinking it may be some cache attached to the device, either in home assistant or Deconz? Even when I completely wipe the database, two hours later it's still reporting incorrect numbers... so frustrating.

Does anyone know how to clear everything related to the energy dashboard, including the devices, sensors and what not..?

popy2k14 commented 1 year ago

Hmm, all backlogs are in the database, so when you delete it, all old data is gone. In my case the sensor works.

Maybe you got the wqrong one and there is one for other pulsed/kwh?

Qalculus commented 1 year ago

OPs and others problem in this thread was that the value got converted to MWh, i.e a factor 1000 less than the expected kWh. If you are seeing it as Wh it means you have the opposite problem, that the value is a factor 1000 larger, now that it has been fixed. What does your sensor say the expected kWh per pulse is and what is the kWh per pulse for your electrical box? It should be fixable by dividing the value by 1000 in the device configuration in the Deconz Interface, but I never figured out how to get the change to persist across restarts of the Deconz addon in Home Assistant.

jenseo commented 1 year ago

OPs and others problem in this thread was that the value got converted to MWh, i.e a factor 1000 less than the expected kWh. If you are seeing it as Wh it means you have the opposite problem, that the value is a factor 1000 larger, now that it has been fixed. What does your sensor say the expected kWh per pulse is and what is the kWh per pulse for your electrical box?

It should be fixable by dividing the value by 1000 in the device configuration in the Deconz Interface, but I never figured out how to get the change to persist across restarts of the Deconz addon in Home Assistant.

Sorry, that was just me being bad at energy values, it is de facto 1000 less than expected, so Mwh then I guess

jenseo commented 1 year ago

Hmm, all backlogs are in the database, so when you delete it, all old data is gone.

In my case the sensor works.

Maybe you got the wqrong one and there is one for other pulsed/kwh?

The weird part is that all data is removed from the energy dashboard, but after two hours when new data is added, it reports 1000 less still.

I did fiddle with it in deconz when the issue first arised (removing the /1000 value) but everything there is restored as well, but it might be that I have missed some step there perhaps. I wish I could do a "factory reset" in the deconz gui to make sure

jenseo commented 1 year ago

Alright, I was able to solve this finally. I had to call set state under developer tools, then it finally updated to the correct values 🙏 So for anyone struggling with the same issue, you can always try that

popy2k14 commented 1 year ago

nice that you solved the issue and thx for posting it.

Idaho947 commented 1 year ago

Hello, is it normal that I've no batterie return for this device ?

Smanar commented 1 year ago

Lol same than for other, from that I m reading you have a lowbattery but not a battery level (but it seem I was wrong for the previous one)

Idaho947 commented 1 year ago

Ok but it's at null

Smanar commented 1 year ago

Do you have access to the GUI to check value ? The DDF is looking on Endpoint 0x02, Cluster 0x0702, attribute 0x0200.

Idaho947 commented 1 year ago

image

Arf unknowed cluster

And I'va a huge batterie drain since 5 or 6 month (in 2.19.3)

Smanar commented 1 year ago

No, it's fine, can you check on Endpoint 0x02, Cluster 0x0702, attribute 0x0200 if the value is the battery value ? Reading it in deconz can force an update in the API too.

You probably can need to awake the device to read the value.

And I'va a huge batterie drain since 5 or 6 month (in 2.19.3)

On all device or this one ?

Can be linked, you can perhaps see a spamming request to this device in deconz log (with "info" and "info_l2") about the cluster 0x0702

Idaho947 commented 1 year ago

The batterie drain just for this one. I was blaming my battery pack but I changed it and it's the same.

I'll check for the info.

How can I check the endpoint if it is unknow ?