An emoncms module to find OpenEnergyMonitor devices on your local network.
hosted version: https://emoncms.org/find
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 emoncms.org that can scan the local network for devices with EmonCMS installed.
- Read the local IP Address
- 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.
- 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 (https://codepen.io/emrys/full/aPKPzv)
- Send 253 ajax requests (0.0.0.1 - 0.0.0.254) to every IPv4 address possible in the current subnet testing for responses from an EmonCMS install (eg
http://192.168.1.136/emoncms/describe
). 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
:-
- emonpi
- emonbase
- emoncms
- smartplug
- openevse
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.