Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
12.05k stars 1.67k forks source link

Zigbee-network map #252

Closed kirovilya closed 5 years ago

kirovilya commented 6 years ago

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 commented 6 years ago

@luci-11 as far as I know, the router on the cc253x (with current firmware) does not send data about its neighbors and therefore all the devices that are connected through it are not displayed on the map. https://github.com/ioBroker/ioBroker.zigbee/issues/40#issuecomment-414063084 we need new firmware for this purpose

ptvoinfo commented 6 years ago

I've updated a firmware for the router. It should send the necessary info now. Can someone check?

luci-11 commented 6 years ago

@ptvoinfo link? I think I can give it a try tonight or tomorrow

lolorc commented 6 years ago

will do this evening, lately I've not been able to pair a cc2531 router to a cc2531 coordinator, I don't know if it's caused by the "custom" panid I'm using. will try again anyway.

link should be http://ptvo.info/wp-content/uploads/2018/09/cc2531_1.2.2a.44539_firmware.zip

luci-11 commented 6 years ago

ok, let's update after tests

ptvoinfo commented 6 years ago

@lolorc the router firmware is hardcoded to PanId=6754 (1A62h) (Xiaomi)

ptvoinfo commented 6 years ago

@luci-11 If you use CC2530 based routers: http://ptvo.info/wp-content/uploads/2018/09/cc2530_1.2.2a.44539_firmware.zip

Koenkk commented 6 years ago

@ptvoinfo is the channel (11) also hardcoded?

lolorc commented 6 years ago

@ptvoinfo hmm does this mean it won't work, it won't pair to my coordinator ? is this panid=6754 a requirement to work with xiaomi devices ?

luci-11 commented 6 years ago

@Koenkk is graphviz still working? I just can get the situation using raw command for map. Anyway this is the export using new FW, @ptvoinfo . Please give it a look: 0x00124b0018e1cd14 is router (CC2531 router, not 2530 as written in the log below) 0x00124b0018e1cd54 is coordinator 0x00158d0001bb5289 is the latest sensor added close to router


[{"ieeeAddr":"0x00124b0018e1cd14","nwkAddr":19075,"lqi":23,"parent":"0x00124b0018e1cd54","status":"online"},
{"ieeeAddr":"0x00158d0002486ca2","nwkAddr":61474,"lqi":1,"parent":"0x00124b0018e1cd54","status":"offline"},
{"ieeeAddr":"0x00158d0001bf944a","nwkAddr":6243,"lqi":12,"parent":"0x00124b0018e1cd54","status":"online"},
{"ieeeAddr":"0x00158d00022da787","nwkAddr":47787,"lqi":54,"parent":"0x00124b0018e1cd54","status":"online"},
{"ieeeAddr":"0x00158d00023f03ea","nwkAddr":29094,"lqi":55,"parent":"0x00124b0018e1cd54","status":"online"},
{"ieeeAddr":"0x00124b0012023473","nwkAddr":25047,"lqi":1,"parent":"0x00124b0018e1cd14","status":"online"},
{"ieeeAddr":"0x00124b0018e1cd54","nwkAddr":0,"lqi":22,"parent":"0x00124b0018e1cd14","status":"online"},
{"ieeeAddr":"0x00158d0001bb5289","nwkAddr":52263,"lqi":1,"parent":"0x00124b0018e1cd14","status":"online"}]

Just for info, there is also this warning in the log:

2018-9-26 22:05:31 - info: MQTT publish, topic: 'zigbee2mqtt/0x00124b0018e1cd14', payload: '{"state":true,"linkquality":23}'
2018-9-26 22:05:31 - warn: No converter available for 'CC2530.ROUTER' with cid 'genOnOff', type 'devChange' and data '{"cid":"genOnOff","data":{"onOff":1}}'
ptvoinfo commented 6 years ago

@lolorc Yes, this router will not pair with your coordinator. As I know, all xiaomi devices use this panid.

ptvoinfo commented 6 years ago

@Koenkk no, the new firmware supports all channels, but the pairing process may take more time.

lolorc commented 6 years ago

@ptvoinfo that's weird, I have 23 xiaomi/aqara devices in my network and I'm not using panid=6754. also, it looks like my aqara gateway and the devices still paired to it are using panid=5564. It guess it's not configurable, it's a compile-time setting, isn't it ?

ptvoinfo commented 6 years ago

@lolorc Yes, this is the compile-time setting. It seems I need to look at this problem a bit more intently.

ptvoinfo commented 6 years ago

@lolorc Please, re-download firmwares. The link is the same. Now a router can connect to any panId.

lolorc commented 6 years ago

@ptvoinfo thanks ! will do this evening and report back soon after

lolorc commented 6 years ago

@ptvoinfo just been trying the usb-diag one reports

PANID:F0F0,Ch:11,Join:1
PANID:5564,Ch:11,Join:0

but never actually joins the network. zigbee2mqtt running in debug mode doesn't log anything from this device ieeeAddr.

edit: been speaking too soon, it just paired to my network !

kirovilya commented 6 years ago

@ptvoinfo I confirm - now the firmware shows the sensors behind the router image

lolorc commented 6 years ago

i've unplugged two of my four osram plugs (also acting as router) looks like the osram plug have a far better antenna, at the moment my devices communicate through the osram plug rather than the cc2531 router which is physically inbetween the osram plug and the coordinator :)

edit: I've unplugged another osram plug, during this time the cc2931 router did not take over and my networkmap lost a bunch of devices. I guess it's not working with this custom panid.

btw would you have a router firmware for cc2530+cc2591 pretty please ? ;-)

lolorc commented 6 years ago

@ptvoinfo funny, cc2531_1 (router) is marked offline map

looking at the serial console it says:

luci-11 commented 6 years ago

@lolorc stupid question, but I spent 2 days on that :) Is the green light on in the router? If it only blinks in red it's offline, press one of the two little button to turn on the green light and make it online (unfortunately, it doesn't go online automatically after plugging it)

luci-11 commented 6 years ago

@lolorc stupid question, but I spent 2 days on that :) Is the green light on in the router? If it only blinks in red it's offline, press one of the two little button to turn on the green light and make it online (unfortunately, it doesn't go online automatically after plugging it)

P.S. how did you get that map?

ptvoinfo commented 6 years ago

@lolorc Could you please test a firmware for cc2530+cc2591? http://ptvo.info/wp-content/uploads/2018/09/cc2530_cc2591_1.2.2a.44539_firmware.zip The firmware sets the maximum TX power (+18dB).

luci-11 commented 6 years ago

@ptvoinfo it's impossible to set the router initially to online via fw? after a power failure, until you press the button it remains offline...

ptvoinfo commented 6 years ago

@luci-11 I've implemented this in the latest firmware. You need to do this only once (after flashing).

luci-11 commented 6 years ago

@ptvoinfo great news! I will flash it too tonight (I'm also very interested in testing the trasmission power increase)

ptvoinfo commented 6 years ago

@luci-11 please, note, transmission power increase is only related to cc2530+cc2591.

luci-11 commented 6 years ago

@ptvoinfo ah right, i didn't read it correcty :( but i'll flash anyway

lolorc commented 6 years ago

@luci-11 the green light is now on by default, and I get the slow blinking of the red led. It's probably an issue with the network map feature, it's in its early stage, if you look at the relations between coordinators and router, on the graph only one of them gets a 2 way communication (cc2531_1 <=> prise_03 on my last graph)

cmd I use to create the graph is:

mosquitto_sub -h $MQTT_SRV -C 1 -t zigbee2mqtt/bridge/networkmap/graphviz | sfdp -Tpng | display -

and

mosquitto_pub -h $MQTT_SRV -t zigbee2mqtt/bridge/networkmap -m graphviz

to trigger it

lolorc commented 6 years ago

is the networkmap feature still working for you with latest dev branch ? looking at the logs it looks like it does the scan, but doesn't display anything.

oh I guess I know why... issue with latest commit regarding friendly_name and networkmap

lolorc commented 6 years ago

I've proposed https://github.com/Koenkk/zigbee2mqtt/pull/443 a regression has been introduced in https://github.com/Koenkk/zigbee2mqtt/commit/4180bd8933db394e126f4233f1c2689241f43048, see https://github.com/Koenkk/zigbee2mqtt/issues/417#issuecomment-427306436

jarrah31 commented 6 years ago

@ptvoinfo is this firmware for CC2531 both router and coordinator? http://ptvo.info/wp-content/uploads/2018/09/cc2531_1.2.2a.44539_firmware.zip

If just router, where can I find the latest coordinator firmware please?

Also, if I update the firmware, will I need to re-pair my Xiaomi sensors (not a problem, but just so I know).

I'm looking forward to trying out the new mapping features. :)

ptvoinfo commented 6 years ago

@jaaps There is a firmware for a router.

mark078 commented 6 years ago

Can someone briefly explain to me how I update to the dev branch? I'd like to try the network, too...

Update

git checkout HEAD -- npm-shrinkwrap.json git pull rm -rf node_modules npm install

Koenkk commented 6 years ago

@mark078 you don't need the dev branch for that, all the functionality is in zigbee2mqtt 0.1.8

mark078 commented 6 years ago

@Koenkk thank you, I tried it again and it worked, realy nice! :)

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

xmace commented 5 years ago

20190114_151937

I'm still having issues on that:

makuser commented 5 years ago

@xmace @kirovilya how did you create this type of map? Is it a function of iobroker, of zigbee2mqtt or one of its dependencies, or an independent module?

orientalsniper commented 5 years ago

It's been said before: https://github.com/Koenkk/zigbee2mqtt/issues/252#issuecomment-416723311 Send MQTT payload "graphviz" to zigbee2mqtt/bridge/networkmap Copy/paste the generated data to http://www.webgraphviz.com/

EDIT: MY BAD, you meant with the icons.

makuser commented 5 years ago

EDIT: MY BAD, you meant with the icons.

exactly. I already got the graphviz map.

jerrychong25 commented 5 years ago

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

Hi,

Your ZigBee network map looks cool!

Do you mind to share how to display this network map?

As I have no idea how to display even though I have installed Zigbee2mqtt add on.