Local Network Device Discovery

Tags: #<Tag:0x00007f1be825b538> #<Tag:0x00007f1be82566a0> #<Tag:0x00007f1be81d71c0> #<Tag:0x00007f1be81d6428>

(Emrys Roberts) #1

Device Scanner

We have produced a tool that scans the local network for devices. This is JavaScript tool that can be tested on your network if you follow the instructions GitHub page for this module

There is also an online version hosted at, however you must first update the emoncms devices before scanning as there are some minor changes to get this to work.

I have copied in the readme below:


It can sometimes be an difficult finding a emonbase/emonpi on a home network to access the EmonCMS interface, hostname support can be tempremental and its easy to forget the router passwords to access the device list on the router. A network scan can be done using a 3rd party app like fing however this adds another step and complexity.


We have created an emoncms module that can be accessed from an existing EmonCMS intallation or from that can scan the local network for devices with EmonCMS installed.

This is done in 2 stages.

  1. Read the local IP Address
  2. Check every entry on the network for an EmonCMS installation.

The results are shown in a list along with the IP Address and type of device that returned a response. You can click any found device to access it’s control panel.


These changes will be available with the normal EmonPi and EmonCMS updates. In the mean time you can use the following to test.


The device type is set using the emonpi repository. To update the code run the following:

$ cd /home/pi/emonpi
$ git checkout master
$ git pull 


For the device to respond with it’s correct type you have to use the master branch of emoncms.

$ cd /var/www/emoncms
$ git checkout master
$ git pull


This is written in JavaScript and only ran in the user’s browser using a standard API (webRTC). Nothing is transmitted outside the local network.

  1. The RTCPeerConnection API allows the browser to open a connection to another ip address. Once this connection is initialised the local ip address can be read.

This example shows what is returned by the WebRTC api (

  1. Send 253 ajax requests ( - to every IPv4 address possible in the current subnet testing for responses from an EmonCMS install (eg ). Only correctly formatted responses are displayed in the list, anything else is ignored.

4 different expected types are returned from an EmonCMS installation at the API endpoint /describe :-

  1. emonpi
  2. emonbase
  3. emoncms
  4. smartplug

The module asks for confirmation from the user because it must open another tab changing from https to http .

This tool does not work using https as the local installation of EmonCMS doesn’t use TLS to encrypt the communication between the client and server. The ajax requests would fail if done over https and no devices would be found.