zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

Does the zigbee network map work correctly?

Open dobrynski opened this issue 7 years ago • 92 comments

Does the zigbee network map work as it should? Here is mine:

digraph G { node[shape=record]; "0x00124b001202328b" [label="{0x00124b001202328b|Coordinator|No model information available|online}"]; "0x00158d000123df04" [label="{study_button|EndDevice|Xiaomi Aqara wireless switch (WXKG11LM)|online}"]; "0x00158d000200d0c4" [label="{bedroom_motion|EndDevice|Xiaomi Aqara human body movement and illuminance sensor (RTCGQ11LM)|online}"]; "0x00158d00017206c0" [label="{office_door|EndDevice|Xiaomi MiJia door & window contact sensor (MCCGQ01LM)|online}"]; "0x00158d0001720704" [label="{bedroom_door|EndDevice|Xiaomi MiJia door & window contact sensor (MCCGQ01LM)|online}"]; "0x00158d0002476ba9" [label="{bedroom_temp|EndDevice|Xiaomi Aqara temperature, humidity and pressure sensor (WSDCGQ11LM)|online}"]; "0x00158d0002476ba9" -> "0x00124b001202328b" [label="94"] "0x00158d00023f5036" [label="{bathroom_temp|EndDevice|Xiaomi Aqara temperature, humidity and pressure sensor (WSDCGQ11LM)|online}"]; "0x00158d0001872b69" [label="{living_room_button|EndDevice|Xiaomi MiJia wireless switch (WXKG01LM)|online}"]; "0x00158d0002476b3c" [label="{outside_temp|EndDevice|Xiaomi Aqara temperature, humidity and pressure sensor (WSDCGQ11LM)|online}"]; "0x00158d0001a668e8" [label="{master_bedroom_button|EndDevice|Xiaomi Aqara wireless switch (WXKG11LM)|online}"]; "0x00158d0001a668e8" -> "0x00124b001202328b" [label="45"] "0x00158d00019dee01" [label="{spare_bedroom_button|EndDevice|Xiaomi MiJia wireless switch (WXKG01LM)|online}"]; "0x00158d00019dee01" -> "0x00124b001202328b" [label="71"] "0x00158d000216085f" [label="{master_bedroom_fan|Router|Xiaomi Mi power plug ZigBee (ZNCZ02LM)|online}"]; "0x00158d000216085f" -> "0x00124b001202328b" [label="62"] "0x00158d0001148b7e" [label="{office_cube|EndDevice|Xiaomi Mi smart home cube (MFKZQ01LM)|online}"]; "0x00158d0002437899" [label="{office_temp|EndDevice|Xiaomi Aqara temperature, humidity and pressure sensor (WSDCGQ11LM)|online}"]; "0x00158d00015da618" [label="{master_bedroom_motion|EndDevice|Xiaomi MiJia human body movement sensor (RTCGQ01LM)|online}"]; "0x00158d00015da618" -> "0x00124b001202328b" [label="72"] "0x00158d0001fa6453" [label="{spare_bedroom_booklight|Router|Xiaomi Mi power plug ZigBee (ZNCZ02LM)|online}"]; "0x00158d0001fa6453" -> "0x00124b001202328b" [label="69"] "0x00158d000204658a" [label="{master_bedroom_door|EndDevice|Xiaomi Aqara door & window contact sensor (MCCGQ11LM)|online}"]; "0x00158d000200e303" [label="{office_motion|EndDevice|Xiaomi Aqara human body movement and illuminance sensor (RTCGQ11LM)|online}"]; "0x00158d00015da4c3" [label="{spare_bedroom_motion|EndDevice|Xiaomi MiJia human body movement sensor (RTCGQ01LM)|online}"]; "0x00158d00015da604" [label="{stairs_motion|EndDevice|Xiaomi MiJia human body movement sensor (RTCGQ01LM)|online}"]; "0x00158d0001a2b36b" [label="{office_storage_motion|EndDevice|Xiaomi MiJia human body movement sensor (RTCGQ01LM)|online}"]; "0x00158d00026d387e" [label="{study_backlight|Router|Xiaomi Mi power plug ZigBee (ZNCZ02LM)|online}"]; "0x00158d00026d387e" -> "0x00124b001202328b" [label="7"] }

I'm confused by the lack of links with signal quality in the diagram to the online (and working) zigbee devices. Additionally, should a router be able to connect to another router if it is closer than the co-ordinator? Because in my scenario study_backlight would be much better off connecting via master_bedroom_fan. Link quality of the study_button in the same room as the study_backlight is 68 and I assume it's connecting to the study_backlight router even if the diagram doesn't show that.

Thanks in advance.

Regards, Michal

dobrynski avatar Dec 04 '18 11:12 dobrynski

The networkmap is indeed still buggy (but it's not high on my priority list).

Koenkk avatar Dec 04 '18 18:12 Koenkk

Fair enough, how about router to router connections? Is that a supported feature or is that not part of the spec/implementation?

dobrynski avatar Dec 04 '18 22:12 dobrynski

Some router to router connections are shown, but note that a device can communicated with multiple other devices (something which is not shown in the networkmap).

Koenkk avatar Dec 05 '18 07:12 Koenkk

Does that mean an end device can communicate with another end device to relay messages? And does this apply to low power battery powered devices? I'm slowly shifting devices from the Xiaomi gateway to zigbee2mqtt and am hoping this will make the Zigbee network more robust.

dobrynski avatar Dec 05 '18 12:12 dobrynski

No, only routers can communicate with other (multiple) routers. end devices are sleeping most of the time.

Koenkk avatar Dec 05 '18 12:12 Koenkk

Is there a way to view any of this information and confirm what is happening without using the graph?

danpowell88 avatar Dec 17 '18 05:12 danpowell88

@danpowell88 the debug version the router firmwares show which childs it has.

Koenkk avatar Dec 17 '18 07:12 Koenkk

Do you have an example of what the output looks like?

On Mon, 17 Dec. 2018, 5:17 pm Koen Kanters <[email protected] wrote:

@danpowell88 https://github.com/danpowell88 the debug version the router firmwares show which childs it has.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Koenkk/zigbee2mqtt/issues/652#issuecomment-447745614, or mute the thread https://github.com/notifications/unsubscribe-auth/ABDKbca4peHDqD-Vpb8pZWWg--Q0FraLks5u50T2gaJpZM4ZAb6y .

danpowell88 avatar Dec 17 '18 07:12 danpowell88

I also observe that the network map generated has a number of online end devices, which are not connected to anything. At the same time 2 routers (Xiaomi smart plug) don't have any end devices connected to them. Could it be that end device to router connections are just not shown? Having correct network map would help to identify issues with connectivity and reliability, which is especially relevant for CC2531 USB dongle, which seems to have lower signal strength than XIaomi gateway.

milakov avatar Jan 10 '19 07:01 milakov

The missing links in the network graph are due to a bug in the lqiScan code in zigbee-shepherd. Here https://github.com/Koenkk/zigbee-shepherd/blob/aa1b9496b7aca7a14c76330c5a70a99bb8fa7918/lib/shepherd.js#L440 it looks for duplicates devices by ieee address but this also has a side effect of limiting links to one per device, i.e. it omits many valid links. A mesh network should have many links per device. The deduplication instead needs to occur for links using a composite key of device and its parent. So code should change to something like this:

                key = ieeeAddr + '|' + parent
                if (dev && dev.type == "Router" && !noDuplicate[key]) {
                    chain = chain.then(function () {
                        return self.lqi(ieeeAddr).then(processResponse(ieeeAddr));
                    });
                }
                noDuplicate[key] = devinfo;

Making this change I get a much richer list of links coming back from lqiScan. A matching change would also need to be done in zigbee2mqtt network map code https://github.com/Koenkk/zigbee2mqtt/blob/9380bbcadf6a361e9c9e621f8175c3c30c2eba9d/lib/extension/networkMap.js#L79 to process the list of links for each device instead of one link per device. So the code should be something like:

            lqiDevices.forEach((lqiDevice) => {
                if (lqiDevice != undefined && lqiDevice.ieeeAddr == device.ieeeAddr) {
                    text += `  "${device.ieeeAddr}" -> "${lqiDevice.parent}" [label="${lqiDevice.lqi}"]\n`;
                }
            });

Unfortunately I couldn't actually get the code fully working - my limited nodeJS got in the way but this may give someone else the hint to get this working.

clockbrain avatar Jan 16 '19 03:01 clockbrain

@clockbrain looks good, could you make a PR? We can further polish the code there.

Koenkk avatar Jan 16 '19 06:01 Koenkk

@Koenkk i've made a PR for the change to zigbee-shepherd https://github.com/Koenkk/zigbee-shepherd/pull/9.

With this change I now get 18 links in my raw network map instead of 6 links.

I'm new to github etc and I don't know how to relate my fork of zigbee-shepherd to my fork of zigbee2mqtt so I'm stuck trying to get the zigbee2mqtt network graph to show the extra links.

clockbrain avatar Jan 17 '19 13:01 clockbrain

@clockbrain thanks, I will take care of the zigbee2mqtt update.

Koenkk avatar Jan 17 '19 14:01 Koenkk

@clockbrain merged and updated zigbee2mqtt.

Koenkk avatar Jan 18 '19 21:01 Koenkk

here is the result, still have unlinked devices here :) 20190119172445

lolorc avatar Jan 19 '19 16:01 lolorc

This morning my network map showed really nice like this:

download

Then I removed two devices and added them back, and after that my network map looked like this:

download 1

It has been like this for some hours now.. Is there something I can do to improve the network map again? I tried restarting Zigbee2mqtt, removed the dongle. Waked up every device, still no change.

I'm on the latest DEV build.

bizziebis avatar Jan 27 '19 19:01 bizziebis

@lolorc regarding the unlinked devices in the map - can you try requesting the map just after triggering those missing end devices. If end devices are asleep when the coordinator issues the lqi scan they may be missed. I also sometimes have unlinked end devices on my map.

@bizziebis does your network map still not work? Make sure you don't have zigbee2mqtt admin panel running as it spams the network with map requests. You could also try requesting a raw network map and counting the returned links but it is more likely that the network is busy during the lqi probe rather than something wrong with the graphviz generation code.

clockbrain avatar Feb 01 '19 14:02 clockbrain

It was looking great when I rebuild the network and had 10 devices connected. Then I added 3 more including a CC2531 router, it didn't show the connection between routers anymore. Only between coordinator <-> router <-> end device.

About the busy network, I was thinking the same, as I see a lot of diag messages from my two routers. I'll try them with the non diag version so the network is more at rest.

Edit: I had to re-pair the whole network because the panId somehow got changed.. But now the network is looking good: 8zwave_mesh_0102_22 14

bizziebis avatar Feb 01 '19 14:02 bizziebis

@clockbrain At some point I had a nice map with all devices connected. Not anymore. Using dev branch. It seems like the map shows connections from end devices to coordinator fine but no connections from end devices to routers. Waking up end devices (pressing reset buton shortly) and re-generating the map doesn't help. map

milakov avatar Feb 02 '19 07:02 milakov

@milakov I see it is only end devices that aren't showing links. Are you sure these devices are all paired and actually working ok? Are all your routers shown on the map?

The online status for end devices doesn't necessarily mean they are actually online. zigbee2mqtt only checks online for routers. End devices are always shown as online regardless.

To gather the network links in response to a map request, each router is polled in turn and their neighbour table is examined. Given that you have reasonable links showing for your coordinator and some routers I guess that either a critical router to which many end devices are paired has gone away or many of these end devices have themselves dropped off your network.

clockbrain avatar Feb 02 '19 13:02 clockbrain