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

colors for network map #1666

Merged
merged 9 commits into from
Jun 26, 2019
Merged

colors for network map #1666

merged 9 commits into from
Jun 26, 2019

Conversation

andreasbrett
Copy link
Contributor

I added some colors to the nodes and edges to make the map even clearer. I also added a node containing the creation timestamp. Not sure if this is okay with you but I thought it would be good to know what point in time the map pictures.

Colors can be re-defined in configuration.yaml.

NOTE: I removed the textRoutes labels from a previous commit by @clockbrain as they were somehow crashing my zigbee2mqtt instance. I haven't had the time to investigate why this happened.

added default color options for network map
- add timestamp node to indicate when the map was created
- colorize nodes by device type
- colorize edges by activity
make travis happy
@Koenkk
Copy link
Owner

Koenkk commented Jun 24, 2019

Let's fix the textRoute part first, what errors/crashes do you see? (logs please).

@andreasbrett
Copy link
Contributor Author

andreasbrett commented Jun 24, 2019

Let's fix the textRoute part first, what errors/crashes do you see? (logs please).

I'd love to help with something meaningful but logs did not show a lot of useful info (at least to me). Not even in debug mode. In order to find the causing line I had to test manually by commenting out lines and without the textRoute line it worked right away.

Those are the last lines right before zigbee2mqtt restarted itself and created a new log file (of course without resuming the network scan): https://pastebin.com/7vT0EjrN

Checking further it is not lib/zigbee.js and the networkScan method that caused the crash but rather the call to e.routes.map((r) => ... within lib/extension/networkMap.js. If I removed that line from networkMap.js the log would show exactly the same but with a mqtt publish of the network map (digraph....): https://pastebin.com/5vc3z9rR

Those errors with rtg scans are always with both my OSRAM Smart+ plugs (...e447 and ...cdf9).

andreasbrett referenced this pull request Jun 24, 2019
* Initial inclusion of routes on map

* Forgot to include zigbee.js

* Hex string for route address

* Rebaseline to dev

* Cleaner merging of scan arrays

* style fixes
@clockbrain
Copy link
Contributor

If you start z2m manually with npm start then you may see additional error messages from a crash that don't show in the log files.

I've just tried a blend of your code and the text routes bit and this works fine here:

                const lineStyle = (device.type=='EndDevice') ? 'style="dashed", '
                    : (!e.routes.length) ? 'style="dotted", ' : '';
                const lineWeight = (!e.routes.length) ? `weight=0, color="${rInactiveColor}", `
                    : `weight=1, color="${rActiveColor}", `;
                const textRoutes = e.routes.map((r) => `0x${r.toString(16)}`);
                const lineLabels = `label="${e.lqi}\\n[${textRoutes.join(']\\n[')}]"`;
                text += `  "${e.parent}" -> "${device.ieeeAddr}" [${lineStyle}${lineWeight}${lineLabels}]\n`;

Note that the order of line arrow changed to parent->device so the routes make sense.

Also, I don't think you need the timestamp node as the last_seen timestamp on the coordinator (now) shows when the map was created.

Good work though - colored map looks good.

@andreasbrett
Copy link
Contributor Author

I don't know why but now it worked with those blended lines of code.

@Koenkk
Copy link
Owner

Koenkk commented Jun 25, 2019

I've refactored the code a little bit, @andreasbrett can you verify it is still working? Then it's ready to merge.

@andreasbrett
Copy link
Contributor Author

I've refactored the code a little bit, @andreasbrett can you verify it is still working? Then it's ready to merge.

Can confirm it's still working nicely.

Koenkk added a commit to Koenkk/zigbee2mqtt.io that referenced this pull request Jun 26, 2019
@Koenkk
Copy link
Owner

Koenkk commented Jun 26, 2019

Thanks!

@Koenkk Koenkk merged commit 7cabe3a into Koenkk:dev Jun 26, 2019
wilmardo pushed a commit to wilmardo/zigbee2mqtt that referenced this pull request Sep 26, 2019
* Update settings.js

added default color options for network map

* Update networkMap.js

- add timestamp node to indicate when the map was created
- colorize nodes by device type
- colorize edges by activity

* Update networkMap.js

make travis happy

* Update networkMap.js

* Update networkMap.js

* Update settings.js

* Refactor

* Move to graphviz.
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.

3 participants