Skip to content
Jean-Marc Louviaux edited this page Jan 16, 2022 · 10 revisions

Create your com app for meterN

Choose your language

The language should be able to get data, via serial (RS485,RS432, P1, an arduino, ...) or an another way (MQTT, 1-Wire, Z-Wave, KNX..)
You can use PHP, python, C or whatever you prefer and you are more at ease.
Pyserial (http://pyserial.sourceforge.net/) is a good help for serial communication ports .

The output format

The output format of the communication(s) application(s) must respect JSON format or the IEC 62056 data set structure.

Grant the permission to execute your app.

Locate it with 'whereis mycomapp' and 'chmod a+x /pathto/mycomapp.py'.

Make a shortcut

'ln -s /pathto/mycomapp.py /usr/bin/mycomapp'

Allow the access the communication ports

The peripherals are usually owned by the uucp or dialout group, check (e.g. 'ls -al /dev/ttyUSB0'), add your user to the group: (e.g. 'usermod -a -G uucp http')

Test your app

From a terminal first. If all work, you can configure mN.

For security reason, set mN's allowed com. app.

Edit config/allowed_comapps.php, add an entry into $ALLWDCMD array. (e.g. $ALLWDCMD[0] = 'my_comapp';)

Deamon

You can make a daemon from a app. This way, it query continuously your app. in a loop, it's more efficient if you meter can get several data in once.
The daemon put the data into shared memory and another app. will quickly fetch the value from there.
You can start and stop the daemon via metern/config/config_daemon.php

Virtual meter

A virtual meter is a counter that dosen't physicaly exist.

IN ---> OUT
    |--> VIRTUAL

IN & OUT are reals counters. IN say 1000kWh, OUT say 800kWH so, you can guess the VIRTUAL value is at 200kWH.
And, if IN say 500W, OUT 300W, VIRTUAL is at 200W.

Pass-over

The pass-over, is the value up to where your meter can count. Let say you water can count up to 100000l, it will turn to 0 when 100000 is hit.
You have to be carefull with pass-over on virtual meter. One real meter can have pass by and may return wrong value for the virtual one.

Trigger

You can request a script each 5min via config/config_trigger.php. It can make some automation, send a warning or whatever you which.