[Solved] Power reading 10x on Xiaomi lumi plug

Hi,
I have a Xiaomi Aqara CN plug (model is shown as “lumi.plug”), connected via ZHA integration; it has some power reporting capabilities that I’d like to use.
It can be controlled on/off, but the reported power is off by a factor of 10.
More exactly, it shows two entities:
“Analog input” correctly reports power in watts, but it’s adimentional value, so trying to add it to energy panel doesn’t work
“Electrical_measurement” is in W, but it reports 10x the real power, so it can’t be added to energy panel.

I’ve enabled ZHA and Home Assistant debug log, and I had the impression that ZHA gets the right values, but somehow they get messed in HA:

2022-12-10 19:24:11.827 DEBUG (MainThread) [zigpy.zcl] [0xBA93:2:0x000c] Received ZCL frame: b'\x18\x84\nU\x00933\x8fB'
2022-12-10 19:24:11.829 DEBUG (MainThread) [zigpy.zcl] [0xBA93:2:0x000c] Decoded ZCL frame header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.GLOBAL_COMMAND: 0>, is_manufacturer_specific=0, direction=<Direction.Client_to_Server: 1>, disable_default_response=1, reserved=0, *is_cluster=False, *is_general=True, *is_reply=True), tsn=132, command_id=10, *direction=<Direction.Client_to_Server: 1>, *is_reply=True)
2022-12-10 19:24:11.832 DEBUG (MainThread) [zigpy.zcl] [0xBA93:2:0x000c] Decoded ZCL frame: AnalogInputCluster:Report_Attributes(attribute_reports=[Attribute(attrid=0x0055, value=TypeValue(type=Single, value=71.5999984741211))])
2022-12-10 19:24:11.834 DEBUG (MainThread) [zigpy.zcl] [0xBA93:2:0x000c] Received command 0x0A (TSN 132): Report_Attributes(attribute_reports=[Attribute(attrid=0x0055, value=TypeValue(type=Single, value=71.5999984741211))])
2022-12-10 19:24:11.835 DEBUG (MainThread) [zigpy.zcl] [0xBA93:2:0x000c] Attribute report received: present_value=71.5999984741211
2022-12-10 19:24:11.836 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.lumi_lumi_plug_analog_input, old_state=<state sensor.lumi_lumi_plug_analog_input=66.3; friendly_name=Caldaia analog_input @ 2022-12-10T19:24:01.823739+01:00>, new_state=<state sensor.lumi_lumi_plug_analog_input=71.6; friendly_name=Caldaia analog_input @ 2022-12-10T19:24:11.835949+01:00>>
2022-12-10 19:24:11.839 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.lumi_lumi_plug_electrical_measurement, old_state=<state sensor.lumi_lumi_plug_electrical_measurement=663; state_class=measurement, unit_of_measurement=W, device_class=power, friendly_name=Caldaia electrical_measurement @ 2022-12-10T19:24:01.825895+01:00>, new_state=<state sensor.lumi_lumi_plug_electrical_measurement=716; state_class=measurement, unit_of_measurement=W, device_class=power, friendly_name=Caldaia electrical_measurement @ 2022-12-10T19:24:11.839244+01:00>>
2022-12-10 19:24:11.857 DEBUG (MainThread) [zigpy_deconz.api] 'aps_data_indication' response from <DeconzAddress address_mode=AddressMode.NWK address=0xba93>, ep: 2, profile: 0x0104, cluster_id: 0x000c, data: b'18840a55003933338f42'

I understand that the plug reports an analog_meter value (AnalogInput Endpoint 3, Id 0x000c, attribute id 0x0055) with value “71.5999”, but HA receives an electrical_measurement (ElectricalMeasurementCluster, Endpoint 1, Id 0x0604, attribute id 0x050b active_power - this is not in the log but in the GUI) with value 716.

Maybe this value is created by quirk? However, as you can see it’s 10x and rounded.

I also see that the ac_power_divisor (0x0605) in ElectricalMeasurementCluster has the value of 10, so it seems that someone is trying to tell that read power has to be divided by 10 (there’s an ac_power_multiplier with value 1 though).

I guess these values make sense: actual power calculated as active_power*ac_power_multiplier/ac_power_divisor would do.

Is there a reason why it doesn’t work this way, or am I getting it wrong?

It has solved by itself. I did a “reconfigure” on the device, but probably I had to wait a bit more.

Hi @mumon66 , I have the same problem with the same device, I’ve tried to update via ota this device but the result is the same, when I put reconfigure from zha panel doesn’t change.
Did you do anything else?

Thanks.

No, I just tried to create an helper with calculation, without success. It also didn’t work immediately after reconfigure, maybe it was after a (some?) HA restart.
Or maybe the fact I manually checked the various endpoints in ZHA integration has helped? It was after that that I realized the reading was correct.