You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is due to the keepAlive only being respected when showOffline is active.
I will leave a patch here, as this repository does not seem to be maintained. Alternatively, you may provide some instructions on what a pull request should contain.
--- MMM-NetworkScanner.js
+++ MMM-NetworkScanner.js
@@ -14,7 +14,7 @@
defaults: {
devices: [], // an array of device objects e.g. { macAddress: "aa:bb:cc:11:22:33", name: "DEVICE-NAME", icon: "FONT-AWESOME-ICON"}
network: "-l", // a Local Network IP mask to limit the mac address scan, i.e. `192.168.0.0/24`. Use `-l` for the entire localnet
- showUnknown: true, // shows devices found on the network even if not specified in the 'devices' option
+ showUnknown: true, // shows devices found on the network even if not specified in the 'devices' option
showOffline: true, // shows devices specified in the 'devices' option even when offline
showLastSeen: false, // shows when the device was last seen e.g. "Device Name - last seen 5 minutes ago"
keepAlive: 180, // how long (in seconds) a device should be considered 'alive' since it was last found on the network
@@ -87,31 +87,30 @@
})
);
- if (this.config.showOffline) {
- var networkDevicesByMac = getKeyedObject(this.networkDevices, 'macAddress');
- var payloadDevicesByMac = getKeyedObject(nextState, 'macAddress');
+ var networkDevicesByMac = getKeyedObject(this.networkDevices, 'macAddress');
+ var payloadDevicesByMac = getKeyedObject(nextState, 'macAddress');
- nextState = this.config.devices.map(device => {
- if (device.macAddress) {
- var oldDeviceState = networkDevicesByMac[device.macAddress];
- var payloadDeviceState = payloadDevicesByMac[device.macAddress];
- var newDeviceState = payloadDeviceState || oldDeviceState || device;
+ nextState = this.config.devices.map(device => {
+ if (device.macAddress) {
+ var oldDeviceState = networkDevicesByMac[device.macAddress];
+ var payloadDeviceState = payloadDevicesByMac[device.macAddress];
+ var newDeviceState = payloadDeviceState || oldDeviceState || device;
- var sinceLastSeen = newDeviceState.lastSeen ?
- moment().diff(newDeviceState.lastSeen, 'seconds') :
- null;
- var isStale = (sinceLastSeen >= this.config.keepAlive);
+ var sinceLastSeen = newDeviceState.lastSeen ?
+ moment().diff(newDeviceState.lastSeen, 'seconds') :
+ null;
+ var isStale = (sinceLastSeen >= this.config.keepAlive);
- newDeviceState.online = (sinceLastSeen != null) && (!isStale);
+ newDeviceState.online = (sinceLastSeen != null) && (!isStale);
- return newDeviceState;
- } else {
- return device;
- }
- });
- }
+ return newDeviceState;
+ } else {
+ return device;
+ }
+ });
- this.networkDevices = nextState;
+ this.networkDevices = this.config.showOffline ?
+ nextState : nextState.filter(d => { return d.online; });
// Sort list by known device names, then unknown device mac addresses
if (this.config.sort) {
@@ -213,7 +212,7 @@
deviceRow.appendChild(deviceCell);
// When last seen
- if ((self.config.showLastSeen && device.lastSeen && !self.config.showLastSeenWhenOffline) ||
+ if ((self.config.showLastSeen && device.lastSeen && !self.config.showLastSeenWhenOffline) ||
(self.config.showLastSeen && !device.lastSeen && self.config.showLastSeenWhenOffline)) {
var dateCell = document.createElement("td");
dateCell.classList.add("date", "dimmed", "light");
The text was updated successfully, but these errors were encountered:
This is due to the keepAlive only being respected when showOffline is active.
I will leave a patch here, as this repository does not seem to be maintained. Alternatively, you may provide some instructions on what a pull request should contain.
The text was updated successfully, but these errors were encountered: