ianperrin / MMM-NetworkScanner

A module for MagicMirror which determines the status of devices on the network based on their MAC or IP address

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiply configs

TimerWolf opened this issue · comments

It seems like it not possible to have multiply configs, when i have everything in one it seems to work fine, but when i have it separated it seems to be harder for it to work.

And that's a bit fun, as the other starts works as well when everything is in the first one, anyways i could be good whit more then only "one" headline" for the differtent things you will check...

I have try to do it like this

{
      module: 'MMM-NetworkScanner',
      position: 'top_left',
      header: "Network",

      config: {
        devices: [
          {
            macAddress: "1a:1b:1c:1a:1b:1c",
            name: "Desktop",
            icon: "desktop"
          },
          {
            macAddress: "2a:2b:2c:2a:2b:2c",
            name: "Server",
            icon: "server"
          },
        ],

        showUnknown: false,
        showOffline: true,
        showLastSeen: true,
        showLastSeenWhenOffline: true,
        keepAlive: 300,
        updateInterval: 5
      }
    },

    {
      module: 'MMM-NetworkScanner',
      position: 'top_left',
      header: "Phones",

      config: {
        devices: [
          {
            macAddress: "3a:3b:3c:3a:3b:3c",
            name: "Me",
            icon: "mobile"
          },
          {
            macAddress: "4a:4b:4c:4a:4b:4c",
            name: "Other",
            icon: "mobile"
          },
        ],

        showUnknown: false,
        showOffline: true,
        showLastSeen: true,
        showLastSeenWhenOffline: true,
        keepAlive: 300,
        updateInterval: 5,
        sort: false
      }
    },

And if i change the two mac-adresses from the "Phones" to the "Network", both starts to work just fine....

I am far from an expert on this, but i found a workaround for this problem

By modify the code in "MMM-NetworkScanner.js" and add three lines of code

updateInterval: 20
hide: false, // <- This line is added
sort: true,

And then add fallowing code

getDom: function() {
  var self = this;

  if (self.config.hide) { // <- This line is added
    this.style.display = "none"; // <- This line is added
  } // <- This line is added

And then do the config in the following way

    // MMM-NetworkScanner

    {
      module: 'MMM-NetworkScanner',
      position: 'top_left',
      header: "Dummy",

      config: {
        devices: [

          // Network
          {
            macAddress: "1a:1b:1c:1a:1b:1c",
            name: "Desktop",
            icon: "desktop"
          },
          {
            macAddress: "2a:2b:2c:2a:2b:2c",
            name: "Server",
            icon: "server"
          },

          // Phone
          {
            macAddress: "3a:3b:3c:3a:3b:3c",
            name: "Me",
            icon: "mobile"
          },
          {
            macAddress: "4a:4b:4c:4a:4b:4c",
            name: "Other",
            icon: "mobile"
          },
        ],

        showUnknown: false,
        showOffline: true,
        showLastSeen: true,
        showLastSeenWhenOffline: true,
        keepAlive: 300,
        updateInterval: 5,
        hide: true
      }
    },
    
    {
      module: 'MMM-NetworkScanner',
      position: 'top_left',
      header: "Network",

      config: {
        devices: [
          {
            macAddress: "1a:1b:1c:1a:1b:1c",
            name: "Desktop",
            icon: "desktop"
          },
          {
            macAddress: "2a:2b:2c:2a:2b:2c",
            name: "Server",
            icon: "server"
          },
        ],

        showUnknown: false,
        showOffline: true,
        showLastSeen: true,
        showLastSeenWhenOffline: true,
        keepAlive: 300,
        updateInterval: 5
      }
    },

    {
      module: 'MMM-NetworkScanner',
      position: 'top_left',
      header: "Phones",

      config: {
        devices: [
          {
            macAddress: "3a:3b:3c:3a:3b:3c",
            name: "Me",
            icon: "mobile"
          },
          {
            macAddress: "4a:4b:4c:4a:4b:4c",
            name: "Other",
            icon: "mobile"
          },
        ],

        showUnknown: false,
        showOffline: true,
        showLastSeen: true,
        showLastSeenWhenOffline: true,
        keepAlive: 300,
        updateInterval: 5,
        sort: false
      }
    },

Then it actually work as expected, hopefully someone come whit a better solution then this but it has to work for now!

@TimerWolf
Nice work, but it will not update after the line

        showUnknown: false,
        showOffline: true,
        showLastSeen: true,
        showLastSeenWhenOffline: true,
        keepAlive: 300,
        updateInterval: 5,
        hide: true
      }'

Can you please take a look on it. ???