Create your own display mesh command
From Digi Developer
Contents |
Create your own 'disp mesh' command
A realistic Python application using the getnodelist() function.
Users of the Digi CLI (telnet/command line) are familiar with the disp mesh command. It shows the same basic information as the web interface mesh networking page. However, suppose you wish to see other information listed? Suppose you wish to see it sorted in extended MAC address or node identifier order? Suppose you wish to see a list containing only end-devices which are temperature sensors and include the current temperature?
You can use the getnodelist() function to create your own custom tool, which creates your own dream-list. The fully functional Python program linked below runs on any Digi ConnectPort X gateway and shows a list of nodes sorted by either node identifier, extended HW MAC addres, or product type. This sample application was created because the author tests large Zigbee systems with up to 50 devices and needs to quickly confirm if all nodes are active - and the various sort orders rapidly allows detecting if any nodes are missing.
Routines used; Things you can learn
The program my_disp_mesh.py does the following:
- uses sys.argv[] to specify the desired sort order from the command line.
- uses zigbee.getnodelist() to obtain a list of associated nodes.
- the device_type information as part of the getnodelist response is converted to a string such as "XB24-ZB:XBee232" for a Digi Xbee RS-232 adapter running on a ZB network.
- a list of dictionary items are sorted in various ways based on dictionary keys using an inline lamda function - for example nodes.sort(key=lambda x: x['name']) to sort the list of dictionaries on the key 'name'.
- the results are printed in a table form.
Sample Output
#> python my_disp_mesh.py help These arguments can be used with my_disp_mesh.py: name = sorts node list on Node Id mac = sorts node list on HW MAC Address short = sorts node list on 16 bit Address type = sorts node list on Product Type refresh = do a mesh refresh before creating your list #> python my_disp_mesh.py mac My DISP MESH - sorted on HW MAC Address GW: [00:13:a2:00:40:3e:1c:80]! [0000]! n:TankMom XB24-ZB:X4 01: [00:13:a2:00:40:34:16:14]! [a8d2]! n:DEBI_4 t:XB24-ZB:XBee232 02: [00:13:a2:00:40:3e:15:18]! [d756]! n:ANNA_1 t:XB24-ZB:XBee232 03: [00:13:a2:00:40:3e:15:2d]! [a865]! n:BELA_2 t:XB24-ZB:XBee232 04: [00:13:a2:00:40:4a:70:7e]! [6789]! n:CALI_3 t:XB24-ZB:XBee232 05: [00:13:a2:00:40:52:29:d7]! [458a]! n:FANI_6 t:XB24-ZB:XBee232PH 06: [00:13:a2:00:40:52:29:f9]! [1234]! n:ELSA_5 t:XB24-ZB:XBee232PH #> python my_disp_mesh.py name My_Disp_Mesh - sorted on Node Name + HW MAC Address GW: [00:13:a2:00:40:3e:1c:80]! [0000]! n:TankMom XB24-ZB:X4 01: [00:13:a2:00:40:3e:15:18]! [d756]! n:ANNA_1 t:XB24-ZB:XBee232 02: [00:13:a2:00:40:3e:15:2d]! [a865]! n:BELA_2 t:XB24-ZB:XBee232 03: [00:13:a2:00:40:4a:70:7e]! [6789]! n:CALI_3 t:XB24-ZB:XBee232 04: [00:13:a2:00:40:34:16:14]! [a8d2]! n:DEBI_4 t:XB24-ZB:XBee232 05: [00:13:a2:00:40:52:29:f9]! [1234]! n:ELSA_5 t:XB24-ZB:XBee232PH 06: [00:13:a2:00:40:52:29:d7]! [458a]! n:FANI_6 t:XB24-ZB:XBee232PH
Download the Python Code
This code only runs on a Digi ConnectPort X gateway:Python program "my_disp_mesh.py" in ZIP form
