Giter VIP home page Giter VIP logo

mmm-networkscanner's Introduction

MMM-NetworkScanner

A module for MagicMirror which determines the status of devices on the network based on their MAC address. It can also look up devices by IP addresses or hostnames. Static IP addresses work more consistently.

Example

Installation

In your terminal, install arp-scan:

cd ~/
sudo apt-get install arp-scan   

In your terminal, go to your MagicMirror's Module folder:

cd ~/MagicMirror/modules

Clone this repository:

git clone https://github.com/ianperrin/MMM-NetworkScanner.git

Go to the modules folder:

cd MMM-NetworkScanner

Install the dependencies (sudo, ping):

npm install

Add the module to the modules array in the config/config.js file:

    {
        module: 'MMM-NetworkScanner',
        position: 'top_left', 
        config: {
            // Optional config options
        }        
    },

Config Options

Option Default Description
devices [] an array of devices to be found on the network. See Device object
network -l optional a network mask to limit the scope of the network scan, i.e. 192.168.0.0/24. If omitted, or set to -l, the entire network will be scanned.
showUnknown true optional shows devices found on the network even if not specified in the devices option
showOffline true optional shows devices specified in the devices option even when offline
showLastSeen false optional shows when the device was last seen e.g. "Device Name - last seen 5 minutes ago"
keepAlive 180 optional how long (in seconds) a device should be considered 'alive' since it was last found on the network
updateInterval 20 optional how often (in seconds) the module should scan the network
sort true optional sorts the devices in alphabetical order when shown in the mirror
residents [] optional an array of names of the devices that should be monitored if they are online
occupiedCMD {} optional the notification to be sent if one of the devices in the residents array is found online. See Notification Example.
vacantCMD {} optional the notification to be sent if NONE of the devices in the residents array is found online. See Notification Example.
debug false optional adds extended messages to the log.

Device Object

The device object contains information about the devices to be found on the network.

Key Description Example
macAddress optional the MAC address of the device. aa:bb:cc:11:22:33
ipAddress optional the IP address or host name of the device. 192.168.0.1 or github.com
name optional the friendly name for the device. If omitted, the macAddress or ipAddress will be used. Phone or Router
icon optional the symbol to show next to the device. See Font Awesome website. If omitted, question will be used. There are a huge number of icons to choose from. Here are some examples: globe, server, desktop, laptop, mobile, wifi.

Note A device object should only contain either a macAddress or an ipAddress NOT both.

Example Config

Simple example

Scans the network (using the default updateInterval) and display the status of the four specified devices:

    {
        module: "MMM-NetworkScanner",
        position: "top_left",
        header: "Who's home",
        config: {
            devices: [
                { macAddress: "1a:1b:1c:1a:1b:1c", name: "Dad", icon: "male"},
                { macAddress: "2a:2b:2c:2a:2b:2c", name: "Mum", icon: "female"},
                { macAddress: "3a:3b:3c:3a:3b:3c", name: "Son", icon: "male"},
                { macAddress: "4a:4b:4c:4a:4b:4c", name: "Daughter", icon: "female"}
            ],
            showUnknown: false
     }

Keep alive example

Scan every 5 seconds and only display the specified devices whether they are online or offline. Devices will continue to be shown as online (i.e. kept alive) for 5 mins after they are last found:

    {
        module: 'MMM-NetworkScanner',
        position: 'top_left', 
        config: {
            devices: [
                    { ipAddress: "github.com", name: "Github", icon: "globe"},
                    { macAddress: "1a:1b:1c:1a:1b:1c", name: "Server", icon: "server"},
                    { macAddress: "2a:2b:2c:2a:2b:2c", name: "Desktop", icon: "desktop"},
                    { ipAddress: "10.1.1.10", name: "Laptop", icon: "laptop"},
                    { macAddress: "4a:4b:4c:4a:4b:4c", name: "Mobile", icon: "mobile"},
                ],
            showUnknown: false,
            showOffline: true,
            keepAlive: 300,
            updateInterval: 5
        }        
    },

Notification example

As with the previous example, this scans every 5 seconds and only display the specified devices whether they are online or offline. Devices will continue to be shown as online (i.e. kept alive) for 5 mins after they are last found on the network.

In addition, the module will send a notification (occupiedCMD) to turn the monitor on when either Mobile or Laptop (the residents) are found on the network. Another notification (vacantCMD) will be sent when neither device is online:

    {
        module: 'MMM-NetworkScanner',
        position: 'top_left', 
        config: {
            devices: [
                    { ipAddress: "github.com", name: "Github", icon: "globe"},
                    { macAddress: "1a:1b:1c:1a:1b:1c", name: "Server", icon: "server"},
                    { macAddress: "2a:2b:2c:2a:2b:2c", name: "Desktop", icon: "desktop"},
                    { ipAddress: "10.1.1.10", name: "Laptop", icon: "laptop"},
                    { macAddress: "4a:4b:4c:4a:4b:4c", name: "Mobile", icon: "mobile"},
                ],
            showUnknown: false,
            showOffline: true,
            keepAlive: 300,
            updateInterval: 5,
            residents: ["Mobile", "Laptop"],
            occupiedCMD: {notification: 'REMOTE_ACTION', payload: {action: 'MONITORON'}},
            vacantCMD  : {notification: 'REMOTE_ACTION', payload: {action: 'MONITOROFF'}},

        }        
    },

NOTE The REMOTE_ACTION notifications (MONITORON and MONITOROFF) actions require the MMM-Remote-Control module to be installed.

Updating

To update the module to the latest version, use your terminal to go to your MMM-NetworkScanner module folder and type the following command:

cd ~/MagicMirror/modules/MMM-NetworkScanner
git pull
npm install

If you haven't changed the modules, this should work without any problems. Type git status to see your changes, if there are any, you can reset them with git reset --hard. After that, git pull should be possible.

mmm-networkscanner's People

Contributors

ben5756 avatar bennewsome avatar boazarad avatar brobergp avatar ianperrin avatar leveneg avatar s-cotton avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.