Modbus data sent in JSON via MQTT to thingsboard

98 Views Asked by At

I'm using a Siemens LOGO!. I must be able to do remote monitoring as well as remote control. As the LOGO! has no internet connection I’m currently using a Teltonika 4G gateway which is configured as a Modbus client for the LOGO! (i.e. the server). I’m already able to read the desired registers in the LOGO!, and send the data in JSON using MQTT to thingsboard (host: thingsboard.cloud). The payload has this type:

{
    "Donnees_Logo": {
        "timestamp": 1700572138,
        "date": "21/11/2023 14:08:58",
        "server_id": 1,
        "bserver_id": 1,
        "addr": 4,
        "full_addr": "400004",
        "size": 3,
        "data": "480",
        "server_name": "EloyLogo",
        "ip": "xx.xx.xx.xx",
        "name": "Surp_Cons_TOFF"
    }
}

I assume that in order to use the various data and keys it should be converted to this type:

{
    "deviceName": "EloyLogo",
    "attributes": {
        "ip": "xx.xx.xx.xx",
        "ts": 1700572138,
        "register": "400004",
        "name": "Surp_Cons_TOFF",
        "integrationName": "Test integration"
    },
    "telemetry": {
        "value": "480"
    }
}

I managed to convert the payload using the data converter in the integration center, but it seems to be useless, and also I struggle to write a custom script in the rule engine to do the same (as I guess it is what I need to do to go further, and display the datas in widgets).

I must add that I cannot change the data type in which the data is sent for the gateway. It is either JSON or custom. I chose JSON.

Any help would be much appreciated, considering the fact that I’m not an expert in this field.

0

There are 0 best solutions below