zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

Zigbee-network map

Open kirovilya opened this issue 8 years ago • 92 comments

For my application, I began to make feature to display the network map. It shows the connections between devices and nodes, as well as the quality of link. image I use the ZShepherd.prototype.lqiScan (thanks to @splitice and HalleyAssist fork) function that collects this info. https://github.com/kirovilya/zigbee-shepherd/blob/dev/lib/shepherd.js#L417

But it does not always work correctly and some devices are not included in the map. Until I figured out why and how to fix it. :(

Another possibility is to start the pairing process on a separate router, rather than in the entire network. To do this, you need to send the NWK-address of the device to permitJoin function.

https://github.com/kirovilya/zigbee-shepherd/blob/dev/lib/components/controller.js#L338

kirovilya avatar Aug 06 '18 06:08 kirovilya

Good plan! I'd also be keen to see some device mapping info available via MQTT which could potentially be rendered by e.g. HA.

I got a map of my small network using the method from here https://community.smartthings.com/t/faq-mapping-your-zigbee-network-with-digis-xctu/28477/55. I could do this because I had a Digi XU-Z11 XStick laying around from when I had previously hoped it would work with HA. Here's the map it shows of my zigbee2mqtt network. image

The XU-Z11 is the R in the top left. The CC2531 is the C. Note that it shows true mesh links and did pick up all my devices. Not suggesting that an XU-Z11 should be required, this is just an example of the level of detail that would be useful in a map. Does the lqi function report the mesh or just shortest path?

clockbrain avatar Aug 06 '18 11:08 clockbrain

@clockbrain In contrast to Digi XU-Z11, this map can be obtained from coordinator and sent by mqtt to HA.

kirovilya avatar Aug 06 '18 11:08 kirovilya

@kirovilya If the problem is on our end PR's are welcome.

I suspect however that the device may not be LQI robust (sometimes ignoring them or similar). Currently the LQI scan is lazy (it's intensive enough without repeats) but I would welcome any well thought out patch for robustness in any area of our forks.

splitice avatar Aug 06 '18 11:08 splitice

@splitice yes of course! thank you!

kirovilya avatar Aug 06 '18 11:08 kirovilya

@splitice I found one error in your code :) https://github.com/HalleyAssist/zigbee-shepherd/blob/master/lib/shepherd.js#L426 - you has not return result in chain function, in compare with my version https://github.com/kirovilya/zigbee-shepherd/blob/dev/lib/shepherd.js#L433

kirovilya avatar Aug 06 '18 11:08 kirovilya

Thanks, Nice find, looks like you are correct. I'll patch that in the morning

splitice avatar Aug 06 '18 12:08 splitice

I added more devices with 2 router. Some end-devices join to first router, some devices to second, and one to coordinator. image

kirovilya avatar Aug 06 '18 20:08 kirovilya

This looks really great!

Koenkk avatar Aug 07 '18 04:08 Koenkk

@Koenkk what about provide json array with map Informations as mqtt topic?

tb-killa avatar Aug 07 '18 05:08 tb-killa

@tb-killa I think we need a separate topic for this.

Also it would be nice if we somehow could provide a rendered graph to home assistant (e.g. via an http jpeg endpoint) which can be used with https://www.home-assistant.io/components/camera.generic/

Koenkk avatar Aug 07 '18 06:08 Koenkk

I used the visjs to draw a graph.

kirovilya avatar Aug 07 '18 06:08 kirovilya

Yes New topic sounds right. Some Javascript map to jpeg could be work. But if we would provide the source of map data via mqtt json i think it would be the best if the thirdparty application would generate this. As your example we could provide some sort of docker who use our input and generate the jpeg Web. I think we should Show that zigbee2mqtt is cleaner and doesnt overloaded :)

tb-killa avatar Aug 07 '18 06:08 tb-killa

With visjs we could export as png... Does this is okay or have it to be jpeg?

https://stackoverflow.com/questions/42663203/export-visjs-network-to-jpeg-png-image

tb-killa avatar Aug 07 '18 06:08 tb-killa

I think that the rendering of the image should not be on the side of the Zigbee2mqtt

kirovilya avatar Aug 07 '18 06:08 kirovilya

@kirovilya would you be willing to submit your networkmap code as pr so we can continue with the editing?

tb-killa avatar Aug 08 '18 10:08 tb-killa

@tb-killa ok. later, in evening

kirovilya avatar Aug 08 '18 10:08 kirovilya

Would be nice to create an Hassio plugin for installing this! Really interested in this tools!

Baseje avatar Aug 08 '18 13:08 Baseje

Example for PR https://github.com/Koenkk/zigbee-shepherd/pull/3 :

shepherd.lqiScan().then((result)=>{
     debug('lqiScan result: ', result);
});

kirovilya avatar Aug 08 '18 16:08 kirovilya

Permit join through router:

const router = shepherd._findDevByAddr(routerIeeeAddr);
const permitDev = router.nwkAddr;
shepherd.permitJoin(permitTime ? permitTime : 0, permitDev, (error) => {});

kirovilya avatar Aug 08 '18 18:08 kirovilya

then tests are needed for the max number of connected devices. eg: 10 devices on the coordinator + 2 routers + 10 devices on the router1 and 10 devices on the router2

I have not so much :)

kirovilya avatar Aug 08 '18 18:08 kirovilya