@jotiotech/node-red-status-parser 0.0.4
Expect two inputs - `msg.payload` and `msg.statusSchema`. If `msg.statusSchema` is not provided, the node will just forward the input message. Payload is expected to contain `payload.outJson` which is an exit object from @jotiotech/node-red-bj-parser or a
Status parser
Input
Expect two inputs - msg.payload
and msg.statusSchema
. If msg.statusSchema
is not provided, the node will just forward the input message. Payload is expected to contain payload.outJson
which is an exit object from @jotiotech/node-red-bj-parser or at least follows convenctions defined by it.
Output
Output is a copy of input message modified by the node.
Schema format
{
"name" : "TEST-PATH",
"version": "1.0.0",
"schemaVersion" : "1.0.0",
"maps" : [
{
"origin" : "path",
"originPath" : {
"path" : "network.port"
},
"mappings" : [
{
"binaryMask" : "1111'1111",
"switch" : [
{
"code" : "I1",
"description" : "No error"
},
{
"code" : "C-1",
"description" : "Flash memory or RAM error",
"equals" : "0x08"
},
{
"code" : "E-1",
"description" : "Out of temperature range, short circuit or failure of temperature sensors",
"equals" : "0x50"
},
{
"code" : "E-3",
"description" : "Temperature sensors swapped",
"equals" : "0xB0"
},
{
"code" : "E-4",
"description" : "Hardware failure in ultrasonic section",
"equals" : "0x28"
},
{
"code" : "E-5",
"description" : "Too frequent readings, M-Bus communication temporarily interrupted",
"equals" : "0x10"
},
{
"code" : "E-6",
"description" : "Reverse flow direction",
"equals" : "0xD0"
},
{
"code" : "E-7",
"description" : "Incorrect signal, measurement line airlock",
"equals" : "0x70"
},
{
"code" : "E-8",
"description" : "Mains power failure",
"equals" : "0x04"
},
{
"code" : "E-9",
"description" : "Battery almost empty",
"equals" : "0x84"
},
{
"code" : "E-L",
"description" : "Leakage detected: pipe damage, device damage, impulse input 1 leakage",
"equals" : "0xF0"
}
]
}
]
}
]
}
At the core of status parsing schema is a array named maps
, which contains mapping information for status codes. Field maps
is an array as there can be multiple sources of status codes in a single message
(like if device reads data from multiple M-Bus meters). Each map object contains the following fields: origin
and mappings
. Field origin
dictates from where status code is sourced and by extension where the output will be. Array mappings
contains objects that define how to parse status code. Each mapping object contains the following fields: binaryMask
, switch
and default
.
When processing status we first apply binary mask to the status code and than match it against cases outlined in the switch
array. If no match is found, the default
object is used. If not default is provided no entry into quantities
array is added.
There is also special mapping used as a fallback if no other mapping matches. This mapping doesn't have binaryMask
defined and has just a single case defined in fallback
structure.
{
"fallback" : {
"code" : "I1",
"description" : "No error"
}
}
Available origin types
path
- absolute path to status code is provided by the user
originPath
- object containing path to status codepath
- absolute path to status code- in case
path
option is used the parsed statys code will be placed intodeviceInfo.quantities
array
mdu
- code searchedmduList
for corresponding mdu field
originMDU
- object containing information about mdu fieldmduType
- string that must matchmduType
field inmduList
-
mduTypeDesc
- string that must matchmduTypeDesc
field inmduList
- in case
mdu
option is used the parsed status code will be placed intodeviceInfo.quantities
array
mbus
- code will searchmduList
formduType==mbus
fields and parse status code from them
- by
mduType==mbus
field is meant that the field is an output ofparseMBUS
from @jotiotech/node-red-bj-parser - as there can be multiple
mduType==mbus
fields inmduList
the output is placed into mbus field, not on higher level like in previous cases originMBUS
- object containing information about where to look for status codemanId
- string that must matchmanId
field inmduList
deviceType
- string that must matchdeviceType
field inmduList
statusLocation
- picks between using standard M-Bus status byte or using some manufacturer specific fieldstatusByte
- if defined will use standard M-Bus status bytecustom
- contains information about custom fielddif
- array of numbers that must matchdif
field inval.data
vif
- array of numbers that must matchvif
field inval.data
PATH
"origin" : "path",
"originPath" : {
"path" : "network.port"
},
```
#### MDU
```json
"origin" : "mdu",
"originMDU" : {
"mduType" : "sensor",
"mduTypeDesc" : "pulse Ch1"
},
```
#### MBUS
```json
"origin" : "mbus",
"originMBUS" : {
"manId" : "TIP",
"deviceType" : "Electricity meter",
"statusLocation" : {
"statusByte" : true,
"custom" : {}
}
},
"origin" : "mbus",
"originMBUS" : {
"manId" : "TIP",
"deviceType" : "Electricity meter",
"statusLocation" : {
"custom" : {
"dif" : [1],
"vif" : [255, 97]
}
}
}