HA, deconz addon, apex smart plug - wrong interpretation of current attribute

Apex Smart Plug via Deconz addon (using Conbee II) in Home Assistant:

The plug works and the power sensor is fine. The power sensor has current and voltage as attributes. The voltage is fine, but it seems that the current (which is apparently reported as milliamperes by the plug - as seen in the deconz interface Electrical measurements cluster) is multiplied by 1000 instead of divided by 1000 when received by Home Assistant.

Node info, Electrical measurements cluster, and HA sensors:

I used template sensors to get at the “current” and “voltage” attributes from the power sensor. The “Vaskemaskin oppe strøm raw” sensor (in µA) is the “current” attribute directly, while the “Vaskemaskin opp strøm” sensor (in A) is the “current” attribute divided by 1e6 in an attempt to convert from µA to A.

As you can see, the numbers make sense for this case with very little load, but for a case with high load (2 kW for example), the “current” value is still in the thousands of microamperes range. My guess is that somewhere along the way, the “current” value is multiplied by 1000 instead of divided by 1000 (or left alone and reported as milliamperes), and since the HA attribute is probably in the form of a 16-bit integer, the value for the current becomes wrong when the actual current exceeds 65535 milliamperes…

I reported this as a bug on HA github issues but the reponse was that there is no numerical conversion of the numbers done by pydeconz or the integration.

You’re indeed right, sorry for that. I’ve created a PR correcting that.

2 Likes

Wow, that was really fast response! Thanks a lot for fixing that issue so quickly.