Aqara (Lumi) 2 Channel Relay with ZHA

Hi all,

I have been using the Aqara relay for a few fans in my house. These are integrated direct to Home Assistant using the ZHA component. These relays have been talking and operating with my HUSBZB-1 stick for a few months now without a problem. These are the relays I am referecing: AQARA RELAY

The problem I have just noticed is that when I restart Home Assistant, I lose the power monitoring entity of the device. I can go through the cluster management screen and see that the device is still reading the proper wattage, however the entities just show “Unavailable”. Not sure why they would work fine until I reset Home Assistant, but that is what is going on. If I remove the device from the network and then re-add it, they will start working again.

The only thing I am doing differently with these relays is that I am specifying their domain in the config.yaml as they default to coming in as a light, however I am using them as a switch so I force this in the config. I am not forcing anything to change on the electrical monitoring cluster however, only the on/off.

Would anyone know why the entities would just stop working after a restart? These relays have been great for me and I use them for power and energy calculations. Any help is appreciated.

2021-11-16 EDIT1
So I removed the domain customization from my config to see if that was causing the issue. It is not the issue. After a restart, the entities go back to the light domain however the power/voltage/current entities continue to show “Unavailable”. Just wanted to rule this out. I have them set back to the switch domain now. Will continue to research…

Hi @L1gerZer0,
I’m facing the same issue. Even on a straightforward setup HA+ConBeeII+some Aqara Devices my LLKZMK11LM relay shows up and behave as you described. The communication with the devices is still okay, and I can turn the relay on and off. I’m not sure, but for me, it looks like a problem with the new HA energy feature.
Did you find something in the meanwhile?
Best regards

Hi @Burges,
I have had no luck getting these to report the power reliably. I am thinking I may end up getting an Aqara hub to try and update the firmware of the relays and see if that may help. In the interim, I have set up a few sql sensors that pull this data directly out of the zigbee.db as seen here. Here is my template sensor:

- platform: sql
  db_url: sqlite:////config/zigbee.db
  scan_interval: 10
    - name: Radon Fan Power SQL
      query: "SELECT value FROM attributes_cache_v7 WHERE ieee = '00:15:xx:xx:xx:xx:xx:xx' and cluster = 2820 and attrid = 1291"
      column: "value" 
      unit_of_measurement: "W"

These sql sensors seem to work fairly well even though they are just a bandaid. Not sure if the cluster and attribute ID would be the same on yours so you may want to use a db explorer to verify. One thing to note is that the power measurement in the db has like 10 decimal places. This doesn’t affect my integration sensor that calculates kwh, but it looks bad on the lovelace. To fix this I use the multiple-entity-row addon in HACS which allows you to set how precise a value is.

Hope this helps. I will revisit this topic when I get an Aqara hub or if a future release of ZHA quirks fixes the issue.

I update ‘zha_custom’ to cope with this need : Read Zigbee attribute directly into a state .

With deconz it worked fine for me, when I went to zha with the conbeeII I stopped having the consumption of my two relays aqara.
Is there any way to fix the aqara relay consumption sensor with zha?

Unfortunately no. I current use ZHA Toolkit on HACS to poll the device cluster and attribute to grab the power value and dump it into the entity. This works decently and has been good for me. I would like it to work outright however.

Thanks, I’m also trying to solve the problem with zhatoolkit but the value it gives me is multiplied by 10.
To write to the sensor, do you do it through automation?

Yes this just changed recently for me as well. I used to be able to grab the value direct from the relay and use that as my power value but I am also having the same issue with the value being 10 times higher than it should. To remedy this I just created a template sensor dividing it by ten.

This isn’t the cleanest method but I do end up with the correct power value and it does work for my purposes. I would like to stick with zigbee relays as I tend to stay away from wifi solutions. We will see however. If this relay continues to be problematic I may switch back to the shelly I had in before.

1 Like

To constantly rewrite the consumption value to the sensor, how do you do it? I am doing it through automation executing the zha toolkit service but it does not quite convince me because it is somewhat delayed and sometimes an erroneous value is left