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

Include last seen in device boxes on graphviz map #1633

Merged
merged 6 commits into from
Jun 17, 2019

Conversation

clockbrain
Copy link
Contributor

Adds a last seen timestamp to the devices on network map alongside the online/offline status. Coordinator always gets an absolute timestamp but other devices get whatever format is configured for advanced last_seen or a relative time if last_seen isn't configured.

Had to include capturing of last_seen to state for every message received so this works regardless of whether availability is configured or not.

This change highlights that something still isn't right with status as routers pretty much always show as offline even when active but looking into that is a problem for another day.

It maps the map a bit busier but hopefully this change can help users ascertain if problems they are experiencing are with the map or actual network communications.

Here's an example map fragment.
image

@clockbrain
Copy link
Contributor Author

Ok, I don't know how to fix that Travis error. Seems state isn't visible within onZigbeeMessage but code runs just fine regardless. Any suggestions?

@Koenkk
Copy link
Owner

Koenkk commented Jun 15, 2019

I've did some refactoring, can you check if everything is OK, then I will merge it.

@clockbrain
Copy link
Contributor Author

Nope. I get an error which seems related to 'this.lastSeenMap' being undefined at that point due to 'this' context not available in graphviz function. Needs the context passed but I am not sure on correct way to do that.

TypeError: Cannot read property '0x00158d0002c9865a' of undefined
    at zigbee.getDevices.forEach (/opt/zigbee2mqtt/lib/extension/networkMap.js:78:88)
    at Array.forEach (<anonymous>)
    at Object.graphviz (/opt/zigbee2mqtt/lib/extension/networkMap.js:55:29)
    at zigbee.networkScan (/opt/zigbee2mqtt/lib/extension/networkMap.js:37:65)
    at processResponse (/opt/zigbee2mqtt/lib/zigbee.js:318:29)
    at shepherd.controller.request (/opt/zigbee2mqtt/lib/zigbee.js:339:25)
    at /opt/zigbee2mqtt/node_modules/q/q.js:2055:17
    at runSingle (/opt/zigbee2mqtt/node_modules/q/q.js:137:13)
    at flush (/opt/zigbee2mqtt/node_modules/q/q.js:125:13)
    at process._tickCallback (internal/process/next_tick.js:61:11)

@Koenkk
Copy link
Owner

Koenkk commented Jun 16, 2019

Can you check again?

@clockbrain
Copy link
Contributor Author

Tried to keep the logic concise but couldn't use a ternary to build the label. Problem was 'unknown' can't be passed to utils.formatDate so had to separate out the various scenarios.

@Koenkk
Copy link
Owner

Koenkk commented Jun 17, 2019

I see, thanks!

@Koenkk Koenkk merged commit b28da02 into Koenkk:dev Jun 17, 2019
@clockbrain clockbrain deleted the map-last-seen branch June 17, 2019 22:46
wilmardo pushed a commit to wilmardo/zigbee2mqtt that referenced this pull request Sep 26, 2019
* Include last seen in device boxes on graphviz map

* Refactor

* Fix test cases

* Bind

* Refactor last seen label construction

* style fix
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.

2 participants