dresden-elektronik / deconz-rest-plugin

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

Aqara QBKG21LM one gang showing as 4 devices #3156

Closed Creatish closed 4 years ago

Creatish commented 4 years ago

Describe the question or issue you are having

Purchased this item which is a one gang button devices, when adding into phoscon it would not find the devices, looking at deconz it detected the device, after refreshing phoscon, there was 3 lights and 1 plug added, it seems the plug is what controls the light, deleting one of the bulbs removes all 4, so I repaired.

Using the device fine in Homeassistant by only toggling the plug socket, but would like to be able to control the light in deconz with my other zigbee switch for redundancy from homeassistant.

Screenshots

If applicable, add screenshots to help explain the problem. image image image

Environment

Creatish commented 4 years ago

Updatw with the cluster info

Smanar commented 4 years ago

Ok, there is something strange, this device is already filterer, but there is something not working

                       if (checkMacVendor(node->address(), VENDOR_JENNIC) &&
                           // prevent false positives like Immax IM-Z3.0-DIM which has only two endpoints (0x01)
                           // lumi.ctrl_neutral1 and lumi.ctrl_neutral2 have more 5 endpoints
                           node->simpleDescriptors().size() > 5  &&
                           node->nodeDescriptor().manufacturerCode() == VENDOR_JENNIC && i->endpoint() != 0x02 && i->endpoint() != 0x03)
                       {
                           // TODO better filter for lumi. devices (i->deviceId(), modelid?)
                           // blacklist switch endpoints for lumi.ctrl_neutral1 and lumi.ctrl_neutral2
                           DBG_Printf(DBG_INFO, "Skip load endpoint 0x%02X for 0x%016llX (expect: lumi.ctrl_neutral1 / lumi.ctrl_neutral2)\n", i->endpoint(), node->address().ext());
                       }
ebaauw commented 4 years ago

If this code gets executed before all simple descriptors have been read, it fails.

Smanar commented 4 years ago

So you mean the fonction void DeRestPluginPrivate::addLightNode(const deCONZ::Node *node) can be called before all simple descriptor was read ?

I thought the list was complete, it s not good at all, and for lot of devices .... Now I understand my problem with tuya and the invisible cluster.

And I don't see a clean method to force that.

    /*! Returns all known active endpoint numbers. */
    const std::vector<uint8_t> &endpoints() const;

This fonction will have the endpoint number event it haven't all SD ?

The "Simple Descriptor Request" is done after the "Active Endpoint Request" ?

ebaauw commented 4 years ago

Bingo. This is why we need to refactor the pairing of devices, making sure all descriptors and Basic cluster attributes have been read, before creating any resource, /lights or /sensors.

Smanar commented 4 years ago

Yeah I know, every week I find a new problem to avoid in api v2 ...

Will try with this fonction for the moment to test.

@Creatish can you try with this code ? git clone --branch divers https://github.com/Smanar/deconz-rest-plugin.git

Or first, do you know how to test code ?

Creatish commented 4 years ago

no Idea how to test code, what can i doo to help

Smanar commented 4 years ago

You just need a Unix machine, you have the procedure on github homepage https://github.com/dresden-elektronik/deconz-rest-plugin at "Install deCONZ development package (optional, Linux only)"

Just replace the step 1 by git clone --branch divers https://github.com/Smanar/deconz-rest-plugin.git

Creatish commented 4 years ago

my host is windows 10, don't have any linux machines

Smanar commented 4 years ago

Ok so need to wait for someone with the same device and an OS on Unix ^^

Creatish commented 4 years ago

Would it work in a Virtual machine?

Smanar commented 4 years ago

Yes, idk wich one VM, but some users use deconz on VM.

stale[bot] commented 4 years ago

As there hasn't 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.

stale[bot] commented 4 years ago

As there hasn't 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 isn't solved, request to get this opened again.

Creatish commented 3 years ago

Someone replied to this and I can't see it

I am using this device no problem really, it adds like 3 lights and 1 switch in phoscon ui aswell as homeassistant, none of the lights function its the switch that is triggering the light, it works although as I am not sure on the speed it should be I am not sure if its slower then it should be stock to xiaomi hub.

Would be nice for all these range to work out of box as they are the best quality no neutral switches you can buy currently.

Smanar commented 3 years ago

This device still not working ?

Since august I have delete my branch, but your problem is there is too much device created ? All is working but you have too much device created ?

russellfortune commented 3 years ago

Sorry! It was me that added a comment and deleted it as I wasn’t able to reopen this issue and was intending to open another.

I ran across this issue as I’m experiencing the same behaviour today - it was very difficult to pair this through Phoscon and in Home Assistant 4x switches appeared which worked cyclically (i.e switch 1 worked intermittently and then switch 2 did and so on)

I’m capable of testing development code and have the device in hand if I can be of help?

Smanar commented 3 years ago

4x switches appeared which worked cyclically ?

Seriously ?

russellfortune commented 3 years ago

Yep. On my initial pairing attempt I got 3x lights and a socket as initially described. I deleted and re-paired and got 4x lights and they worked sporadically amongst each other. It’s only a 1x gang switch so I wasn’t able to make it usable from Home Assistant.

I’m using a Raspbee II if that’s important.

Smanar commented 3 years ago

I’m capable of testing development code and have the device in hand if I can be of help?

Yep, probably.

In the code we are checking some information to display only 2 devices

                            if (checkMacVendor(node->address(), VENDOR_JENNIC) &&
                                // prevent false positives like Immax IM-Z3.0-DIM which has only two endpoints (0x01)
                                // lumi.ctrl_neutral1 and lumi.ctrl_neutral2 have more 5 endpoints
                                node->simpleDescriptors().size() > 5  &&
                                node->nodeDescriptor().manufacturerCode() == VENDOR_JENNIC && i->endpoint() != 0x02 && i->endpoint() != 0x03)
                            {
                                // TODO better filter for lumi. devices (i->deviceId(), modelid?)
                                // blacklist switch endpoints for lumi.ctrl_neutral1 and lumi.ctrl_neutral2
                                DBG_Printf(DBG_INFO, "Skip load endpoint 0x%02X for 0x%016llX (expect: lumi.ctrl_neutral1 / lumi.ctrl_neutral2)\n", i->endpoint(), node->address().ext());
                            }

But it seem we have a problem in the "event order", cf the ebaauwn comment. So can you edit the code like that

                        if (hasServerOnOff)
                        {

                            DBG_Printf(DBG_INFO, "Xiaomi debug 1 : %d", node->simpleDescriptors().size());
                            DBG_Printf(DBG_INFO, "Xiaomi debug 2 : %d ",node->endpoints().size());

                            if (checkMacVendor(node->address(), VENDOR_JENNIC) &&

It will display in log the problematic value (and perhaps a solution), on the capture the device have 7 endpoints, but it seem we haven't the same during the process.

We probably can use the node->endpoints().size() instead of node->simpleDescriptors().size() to make the check

Creatish commented 3 years ago

Yeah It did work intermititaly with me for a while, it ended up settling down and now the ''switch'' in deconz and ha works 100% of the time, What might help is add a phoscon group and add the switch only to it. see if after some times the switch works reliably.

Creatish commented 3 years ago

Yep mine is working 100%, but do have 3 devices added that don't do anything, can't be for sure if this effects the speed or not, im content with it