Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new REST API endpoint for network map using DOT (graphviz) #4136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

remat
Copy link

@remat remat commented Jan 8, 2021

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
map

@Mimiix
Copy link
Collaborator

Mimiix commented Jan 8, 2021

I have no clue on the code side, but this looks amazing. Thanks in advance!

@manup
Copy link
Member

manup commented Jan 12, 2021

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.

@manup
Copy link
Member

manup commented Jan 12, 2021

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

@ebaauw
Copy link
Collaborator

ebaauw commented Jan 12, 2021

Nice. What does the output look like? Is DOT based on JSON?

@manup
Copy link
Member

manup commented Jan 12, 2021

I think it's even older than JSON, the examples give a good overview https://graphviz.org/Gallery/directed/bazel.html

@ebaauw
Copy link
Collaborator

ebaauw commented Jan 12, 2021

I like the functionality, but if it doesn't provide JSON output, it shouldn't be a REST API endpoint.

@remat
Copy link
Author

remat commented Jan 12, 2021

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).

@manup
Copy link
Member

manup commented Jan 13, 2021

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.

@superjaegermaster
Copy link

hi, this looks like a great idea !!!

indeed related to my feature request #4326

perfect for headless setups and not touching the device hosting the GW

@superjaegermaster
Copy link

Hello, any news about if this can be integrated ?

would love to see this.

Thank you and best regards.

@Mimiix
Copy link
Collaborator

Mimiix commented Mar 8, 2021

@manup

@leonardpitzu
Copy link

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.

@Jan1503
Copy link

Jan1503 commented Mar 10, 2022

Hi, any news on this? I need the LQI-data for my sensors using REST.
Thanks!

@cskowronnek
Copy link

Can this be merged anytime soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants