dresden-elektronik / deconz-rest-plugin

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

Aqara Plug measurement & metering reports wrong values #7307

Closed bluemoehre closed 9 months ago

bluemoehre commented 9 months ago

Does the issue really belong here?

Is there already an existing issue for this?

Describe the bug

I was tracking down an issue in Homeassistant where I can see the measurement / metering values of Aqara Plugs multiplied by 10x / 1000x. Now I checked Phoscon App and the same issue is there.

API reports wrong value in field power. The value should be divided by the factor which is listed in Electrical Measurement / AC Power Divisor.

{
  "config": {
    "on": true,
    "reachable": true,
    "temperature": 0
  },
  "ep": 1,
  "etag": "ca1e04aa15eaec5a3dc55c33adfd4d22",
  "lastannounced": "2023-10-16T22:13:25Z",
  "lastseen": "2023-10-20T00:09Z",
  "manufacturername": "LUMI",
  "modelid": "lumi.plug.maeu01",
  "name": "Aqara Plug 69",
  "state": {
    "current": 0,
    "lastupdated": "2023-10-20T00:09:16.057",
    "power": 440,
    "voltage": 0
  },
  "swversion": "12-06-2021",
  "type": "ZHAPower",
  "uniqueid": "54:ef:44:10:00:70:ff:fe-01-0b04"
}

API reports wrong value in field consumption. The value should be divided by the factor which is listed in Simple Metering / Divisor.

{
  "config": {
    "on": true,
    "reachable": true,
    "temperature": 0
  },
  "ep": 1,
  "etag": "013182b778b257feb2ceb8bca0017208",
  "lastannounced": "2023-10-16T22:13:25Z",
  "lastseen": "2023-10-20T00:36Z",
  "manufacturername": "LUMI",
  "modelid": "lumi.plug.maeu01",
  "name": "Aqara Plug 68",
  "state": {
    "consumption": 308890,
    "lastupdated": "2023-10-20T00:36:49.174",
    "power": 0
  },
  "swversion": "12-06-2021",
  "type": "ZHAConsumption",
  "uniqueid": "54:ef:44:10:00:70:ff:fe-01-0702"
}

Other values may need to be adjusted accordingly.

Steps to reproduce the behavior

  1. Go to "Sensors" page
  2. Choose an Aqara Plug (lumi.plug.maeu01)
  3. See your smartphone charger pulling 440 Watts ;P

Expected behavior

Correct value 44.0 is reported. Other plugs / manufacturers may also choose different precisions.

Screenshots

Screenshot 2023-10-20 022144

Screenshot 2023-10-20 024347

Environment

deCONZ Logs

No response

Additional context

No response

SwoopX commented 9 months ago

Duplicate of #6251. Please use the search next time, it feels the tick was just set to get issue through.

bluemoehre commented 9 months ago

Hi @SwoopX , it was not on purpose to add a duplicate. I did search for an issue before, but due to naming I did not find it. Please tell me, what is the final solution to this issue if it is that old? It seems there is none.

In the code I can find manual workarounds for different manufacturers which makes the behavior even more unintentional.

Maybe you can point out the part of the code where the fields holding the divisors and multipliers are used to calc the correct final value for the API. Thanks.

bluemoehre commented 8 months ago

Today I figured out what was going wrong here and fixed the problem.

I bought my Conbee II in mid-2023 and did not expect it to have 2021 firmware. At the same time, there seems to be no automatic update mechanism, nor any information about available updates. So it was still using legacy DDF files which do contain the bug ignoring the Divisor Values (see above)

So, to help everyone dropping into this topic:

  1. make sure Aqara Plug has the product id lumi.plug.maeu01 (if not, this may not help you)
  2. make sure Aqara Plug has latest firmware, which is today 0x00000029 as seen in deCONZ OTAU Panel
  3. make sure Conbee II is using the latest firmware, which is today 26780700 as seen in Phoscon (compare with Firmware List)

After installing the latest firmwares to the devices via OTAU + flashing the latest firmware to Conbee via GCFFlasher you need to

deCONZ log should now show something like this at startup:

deconz           | 17:45:35:164 skip legacy loading 54:ef:44:10:00:70:ff:fe-01 / lumi.plug.maeu01
deconz           | 17:45:35:206 skip legacy loading 54:ef:44:10:00:75:d0:6c-01 / lumi.plug.maeu01

deCONZ should now offer new panels:

image

(You may enforce these features and speed things up by right-clicking the node and trigger all Read node descriptor & Read active endpoints & Read simple descriptors.)

References which may help you with the updates: https://github.com/dresden-elektronik/deconz-rest-plugin/wiki/Update-deCONZ-manually https://github.com/deconz-community/deconz-docker