deconz-rest-plugin
deconz-rest-plugin copied to clipboard
new REST API endpoint for network map using DOT (graphviz)
Hi, I created a new endpoint for the REST API that delivers the current network map (using Node::neighbors()) in the DOT language (similar to what Zigbee2MQTT can do). This graph representation can be easily converted to an image using graphviz, for example by passing it directly to dot, circo, etc. I also added some GET-parameters, that allow the user to change some colors.
Example:
$ curl http://192.168.178.49:8080/api/<API_KEY>/map | circo -Gratio=0.56 -Tsvg -o map.svg
leads for my zigbee network to

I have no clue on the code side, but this looks amazing. Thanks in advance!
This is pretty cool, especially for headless setups.
Note that there are always two LQI values between two routers and they can be quite different. This is the reason why deCONZ GUI shows two values for a link when the LQI button is enabled.
Note that there are always two LQI values between two routers and they can be quite different. This is the reason why deCONZ GUI shows two values for a link when the LQI button is enabled.
Correct my self I see you already show two links :D
Nice. What does the output look like? Is DOT based on JSON?
I think it's even older than JSON, the examples give a good overview https://graphviz.org/Gallery/directed/bazel.html
I like the functionality, but if it doesn't provide JSON output, it shouldn't be a REST API endpoint.
The output looks like:
digraph G { "0x00212effff06a915" [shape=Mrecord label="{Configuration tool 1|00:21:2E:FF:FF:06:A9:15}", color=green, style=solid] "0x00212effff06a915" -> "0xec1bbdfffefd47b9" [label="228", color=black] "0x00212effff06a915" -> "0x000d6ffffea93e24" [label="103", color=black] "0x00212effff06a915" -> "0x000d6ffffeab33ac" [label="252", color=black] "0x00212effff06a915" -> "0x00158d000309f37d" [label="255", color=black] "0x00212effff06a915" -> "0x00158d00031661a2" [label="255", color=black] "0x00212effff06a915" -> "0x00158d000411d2b8" [label="255", color=black] "0xec1bbdfffefd47b9" [shape=Mrecord label="{Silvercrest Smart Plug|EC:1B:BD:FF:FE:FD:47:B9}", color=black, style=solid] "0xec1bbdfffefd47b9" -> "0x00212effff06a915" [label="151", color=black] "0xec1bbdfffefd47b9" -> "0x000d6ffffea93e24" [label="68", color=black] "0xec1bbdfffefd47b9" -> "0x000d6ffffeab33ac" [label="128", color=black] "0xec1bbdfffefd47b9" -> "0x000d6ffffe23fe78" [label="75", color=black] "0x00158d000411d2b8" [shape=Mrecord label="{Multisensor 1|00:15:8D:00:04:11:D2:B8}", color=blue, style=solid] "0x00158d00031661a2" [shape=Mrecord label="{Wandsender 2-fach|00:15:8D:00:03:16:61:A2}", color=blue, style=solid] "0x000d6ffffe23fe78" [shape=Mrecord label="{TRÅDFRI Fernbedienung|00:0D:6F:FF:FE:23:FE:78}", color=blue, style=solid] "0xd0cf5efffe306678" [shape=Mrecord label="{TRÅDFRI wireless dimmer|D0:CF:5E:FF:FE:30:66:78}", color=blue, style=solid] "0x000d6ffffea93e24" [shape=Mrecord label="{Range extender 3|00:0D:6F:FF:FE:A9:3E:24}", color=black, style=solid] "0x000d6ffffea93e24" -> "0x00212effff06a915" [label="67", color=black] "0x000d6ffffea93e24" -> "0xec1bbdfffefd47b9" [label="54", color=black] "0x000d6ffffea93e24" -> "0x000d6ffffeab33ac" [label="65", color=black] "0x000d6ffffea93e24" -> "0x842e14fffe5f3c41" [label="144", color=black] "0x000d6ffffea93e24" -> "0xd0cf5efffe306678" [label="83", color=black] "0x000d6ffffeab33ac" [shape=Mrecord label="{Range extender 4|00:0D:6F:FF:FE:AB:33:AC}", color=black, style=solid] "0x000d6ffffeab33ac" -> "0x00212effff06a915" [label="180", color=black] "0x000d6ffffeab33ac" -> "0xec1bbdfffefd47b9" [label="115", color=black] "0x000d6ffffeab33ac" -> "0x000d6ffffea93e24" [label="61", color=black] "0x000d6ffffeab33ac" -> "0xd0cf5efffe306678" [label="81", color=black] "0x000d6ffffeab33ac" -> "0x680ae2fffe0a36fd" [label="92", color=black] "0x680ae2fffe0a36fd" [shape=Mrecord label="{Bewegungsmelder|68:0A:E2:FF:FE:0A:36:FD}", color=blue, style=solid] "0x00158d000309f37d" [shape=Mrecord label="{Fenster- / Türkontaktsensor|00:15:8D:00:03:09:F3:7D}", color=blue, style=solid] "0x00158d000211c6ad" [shape=Mrecord label="{|00:15:8D:00:02:11:C6:AD}", color=blue, style=solid] "0x842e14fffe5f3c41" [shape=Mrecord label="{TRÅDFRI Bewegungsmelder|84:2E:14:FF:FE:5F:3C:41}", color=blue, style=solid] }
To my knowledge, a REST API (in general) is not limited to JSON. I also thought about putting the DOT representation inside JSON but this makes it much harder to process the output than it should be (e.g. dealing with newlines in DOT and extracting it from JSON to pipe it into graphviz).
I think at a later stage there can be a call to enable and configure generation of the map via PUT.
The map itself could be updated periodically and more importantly cached, so that not each GET call generates the map which perhaps can be costly in larger networks. Downloading non JSON content is okay as long as the MIME type is set correctly.
Providing the network graph itself as JSON is also useful and on my personal plan, but that will be another endpoint.
hi, this looks like a great idea !!!
indeed related to my feature request https://github.com/dresden-elektronik/deconz-rest-plugin/issues/4326
perfect for headless setups and not touching the device hosting the GW
Hello, any news about if this can be integrated ?
would love to see this.
Thank you and best regards.
@manup
this is cool. i did a manual build of this and it's just great to use it on headless systems. integration is easy and it works great.
Hi, any news on this? I need the LQI-data for my sensors using REST. Thanks!
Can this be merged anytime soon?