Wireless m-Bus integration

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
junky84
Posts: 3
Joined: Saturday 14 December 2013 16:10
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Wireless m-Bus integration

Post by junky84 »

Hi,

the last weeks i tried out to connect my new smart Watermeter to domoticz and i succeeded.

Some Facts:
Hardware: RasPi 1 Modell B
OS: Raspbian Jessie Lite
domoticz: v3.5877
wM-Bus USB-Stick: iM871A-USB https://wireless-solutions.de/products/ ... apter.html
Watermeter: Sensus iPerl

Two month ago my Watercompany installed a new Watermeter, a Sensus iPerl. This meter has a wireless M-bus (wM-Bus) interface using the open metering system (OMS) standard. The payload is AES encrypted but my Watercompany gave me the key.

I tested several tools, but this one is working and installation is easy.

1. Add dummy hardware and virtual device

You could do it with the Webfrontend (see domoticz wiki) or with the api:

Code: Select all

/json.htm?type=createvirtualsensor&idx=7&sensorname=Water&sensortype=113
/json.htm?type=setused&idx=IDXNUMBER&name=Water&switchtype=2&used=true
Replace IDXNUMBER with the one resulted from the first api command

2. Clone and Install (part of ecpiww/install.txt)

Code: Select all

//get ecpiww source
$mkdir projects
$cd projects
$git clone https://github.com/ffcrg/ecpiww.git

$cd ecpiww

//for domoticz not rally necessary, but there is the default location for the data log files. copy websource to var/www
$chmod u+x cpwww.sh
$./cpwww.sh 
3. Modify Code

ecpiww/linux/include/energycam/ecpiww.h

Code: Select all

//#define FASTFORWARD             0x18C4
#define FASTFORWARD             0x4CAE // Sensus ManufacturerID
ecpiww/linux/src/energycam/ecpiww.c

Code: Select all

//ecpiwwMeter[iX].version        = 0x01;
ecpiwwMeter[iX].version        = 0x68; //maybe different for other devices
Modify the switch statement for LOGTOCSV in the Log2File function. Then in addition to writing the log the values are updated with the api. May be there is a better way to do it, but for me it works. Feel free to make suggestions.

Cause the values are given in liters the RFXMeter/Counter Dividers for Water must be '1000'.

Code: Select all

int Log2File(char *DataPath, uint16_t mode, uint16_t meterindex, uint16_t infoflag, float metervalue, ecMBUSData *rfData, uint32_t ident) {
    char  param[  _MAX_PATH];
    char  datFile[_MAX_PATH];
    FILE  *hDatFile;
    time_t t;
    struct tm curtime;
    char command[512];
    float liter_f; //define variables for domoticz mod
    int liter; 

    switch(mode) {
        case LOGTOCSV : if (strlen(DataPath) == 0) {
                            sprintf(param, "/var/www/ecpiww/data/ecpiwwM%d.csv", meterindex+1);
                        } else {
                            sprintf(param, "%s/ecpiwwM%d.csv", DataPath, meterindex+1);
                        }
                        Log2CSVFile(param, metervalue); //log kWh
                       	liter_f = metervalue * 1000; // cubic meter to liter
                        liter = (int)liter_f; // float to integer; domoticz can't handle floating point values
                        snprintf(command, sizeof(command), "curl -i -H \"Accept: application/json\" -H \"Content-Type: application/json\" http://localhost/json.htm?type=command\\&param=udevice\\&idx=IDXNUMBER\\&svalue=%i", liter); // update Meter with the current total usage value
                        system(command); // replace IDXNUMBER with the IDX of the created virtual meter
                        return APIOK;
                        break;
4. Add Meter to ecpiww
Follow the instructions in ecpiww/install.txt and add a Meter

5. Run ecpiww
Run ecpiww

Code: Select all

sudo ./ecpiww
For ecpiww maybe a auto check if the process is running and a is useful. Somebody an idea?
schurgan
Posts: 9
Joined: Monday 20 March 2017 15:49
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Wireless m-Bus integration

Post by schurgan »

Hello, has anyone else dealt with the subject? I have a heat meter from Techem, Techem compact v in the house, and I want to connect it to Domoticz. If someone has realized such a thing, please for feedback. Thank you
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest