[
{
"id": "6fabb801.91dd08",
"type": "subflow",
"name": "JSON or Obj to IOBroker (2)",
"info": "# Creates an IOBroker tree\n\nThis node creates an IOBroker tree out of an Java-Object or JSON String.\n\nThe object tree will be created under 0_userdata.0\nIn addition to the JSON-String or Java Object as msg.payload it is necessary to specify a msg.top properity in addition to the msg-Object.\n\nThe object tree will be created under 0_userdata.0\n\nExisting msg.topic entries will be deleted.\nAn iobroker-out node has to be appended to this subflow node. It is not part of the subflow itself. No topic should be specified in the iobroker out node.\n\nIs no msg.top property is defined, then you will get an error in the following iobroker-out node (key or topic does not exist) - if you append a debug node to the subflow node you will get the message: \n> Please define msg.top as root for the object structure \n\n# Erstellt einen Objektbaum im ioBroker\n\nDiese Node erstellt einen Objektbaum im ioBroker aus einem JAVA Objekt bzw. einem JSON String. \n\nDer Baum wird in jedem Fall unter 0_userdata.0 erstellt und zwar unter dem Topic der in msg.top mitgegeben wurde. In der msg.payload befindet sich dann der JSON String oder das entsprechende Objekt.\n\nExistierende msg.topic Einträge werden gelöscht.\nEin entsprechende iobroker-out Node muss an den Flow angehängt werden. Sie ist nicht Bestandteil des Subflows. In dieser iobroker-out Node darf kein Topic angegeben werden. \n\nFalls in keine Angabe in msg.top definiert wurde, wird man in der darauffolgenden iobroker-out node den Fehler erhalten, dass kein key oder topic definiert ist. Falls eine debug Node an den Subflow angehängt wirde erhält man folgende Ausgabe:\n> Please define msg.top as root for the object structure ",
"category": "",
"in": [
{
"x": 60,
"y": 160,
"wires": [
{
"id": "c15e0c9c.ecc39"
}
]
}
],
"out": [
{
"x": 2280,
"y": 260,
"wires": [
{
"id": "8a2f0a9e.602858",
"port": 0
},
{
"id": "98a0ed8b.13619",
"port": 0
}
]
}
],
"env": [],
"color": "#E2D96E",
"icon": "node-red/batch.svg"
},
{
"id": "45b4186c.2d7be8",
"type": "split",
"z": "6fabb801.91dd08",
"name": "split object",
"splt": "\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "key",
"x": 1170,
"y": 160,
"wires": [
[
"60d65adf.58b3e4"
]
]
},
{
"id": "60d65adf.58b3e4",
"type": "change",
"z": "6fabb801.91dd08",
"name": "add key to topic",
"rules": [
{
"t": "set",
"p": "stateName",
"pt": "msg",
"to": "key",
"tot": "msg"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "topic & '.' & key",
"tot": "jsonata"
},
{
"t": "change",
"p": "topic",
"pt": "msg",
"from": " ",
"fromt": "str",
"to": "_",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1360,
"y": 160,
"wires": [
[
"8c4bc152.c6d6d"
]
]
},
{
"id": "8c4bc152.c6d6d",
"type": "switch",
"z": "6fabb801.91dd08",
"name": "is type?",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "istype",
"v": "array",
"vt": "array"
},
{
"t": "istype",
"v": "object",
"vt": "object"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 1540,
"y": 160,
"wires": [
[
"1ee1b9e5.d9c646"
],
[
"45b4186c.2d7be8"
],
[
"4a5f7457.df580c"
]
]
},
{
"id": "1ee1b9e5.d9c646",
"type": "split",
"z": "6fabb801.91dd08",
"name": "split array",
"splt": "\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 580,
"y": 280,
"wires": [
[
"da3bfa91.495ae8"
]
]
},
{
"id": "da3bfa91.495ae8",
"type": "change",
"z": "6fabb801.91dd08",
"name": "add index to topic",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "topic & '.' & parts.index",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 770,
"y": 280,
"wires": [
[
"434be766.d8d348"
]
]
},
{
"id": "8a2f0a9e.602858",
"type": "change",
"z": "6fabb801.91dd08",
"name": "finalize msg.topic",
"rules": [
{
"t": "set",
"p": "top",
"pt": "msg",
"to": "'0_userdata.0.' & top",
"tot": "jsonata"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "top & topic",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1970,
"y": 240,
"wires": [
[]
]
},
{
"id": "d5c90bb.83349f8",
"type": "switch",
"z": "6fabb801.91dd08",
"name": "is type?",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "istype",
"v": "json",
"vt": "json"
},
{
"t": "istype",
"v": "object",
"vt": "object"
},
{
"t": "istype",
"v": "array",
"vt": "array"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 4,
"x": 400,
"y": 160,
"wires": [
[
"6c970fd8.5d158"
],
[
"45b4186c.2d7be8"
],
[
"1ee1b9e5.d9c646"
],
[
"434be766.d8d348"
]
]
},
{
"id": "6c970fd8.5d158",
"type": "json",
"z": "6fabb801.91dd08",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 570,
"y": 120,
"wires": [
[
"911aeb92.3731a8"
]
]
},
{
"id": "4a5f7457.df580c",
"type": "switch",
"z": "6fabb801.91dd08",
"name": "is msg.top != null",
"property": "top",
"propertyType": "msg",
"rules": [
{
"t": "nnull"
},
{
"t": "null"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 1750,
"y": 280,
"wires": [
[
"8a2f0a9e.602858"
],
[
"17a9b663.ac136a"
]
]
},
{
"id": "17a9b663.ac136a",
"type": "change",
"z": "6fabb801.91dd08",
"name": "payload = warning",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Please define msg.top as root for the object structure",
"tot": "str"
},
{
"t": "delete",
"p": "topic",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1970,
"y": 300,
"wires": [
[
"98a0ed8b.13619"
]
]
},
{
"id": "98a0ed8b.13619",
"type": "rbe",
"z": "6fabb801.91dd08",
"name": "",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"septopics": true,
"property": "payload",
"x": 2130,
"y": 300,
"wires": [
[]
]
},
{
"id": "c15e0c9c.ecc39",
"type": "change",
"z": "6fabb801.91dd08",
"name": "",
"rules": [
{
"t": "delete",
"p": "topic",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 210,
"y": 160,
"wires": [
[
"d5c90bb.83349f8"
]
]
},
{
"id": "911aeb92.3731a8",
"type": "switch",
"z": "6fabb801.91dd08",
"name": "is array?",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "istype",
"v": "array",
"vt": "array"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 700,
"y": 120,
"wires": [
[
"1ee1b9e5.d9c646"
],
[
"45b4186c.2d7be8"
]
]
},
{
"id": "4b5fe636.eaf288",
"type": "comment",
"z": "6fabb801.91dd08",
"name": "Array",
"info": "",
"x": 400,
"y": 280,
"wires": []
},
{
"id": "bb1a76c3.031228",
"type": "comment",
"z": "6fabb801.91dd08",
"name": "object",
"info": "",
"x": 1140,
"y": 100,
"wires": []
},
{
"id": "434be766.d8d348",
"type": "switch",
"z": "6fabb801.91dd08",
"name": "is type?",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "istype",
"v": "object",
"vt": "object"
},
{
"t": "istype",
"v": "array",
"vt": "array"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 3,
"x": 960,
"y": 280,
"wires": [
[
"45b4186c.2d7be8"
],
[
"1ee1b9e5.d9c646"
],
[
"4a5f7457.df580c"
]
]
},
{
"id": "1a84a0da.5e21bf",
"type": "change",
"z": "3a33383f.1533a8",
"name": "Binde Sensortyp in Datensatz",
"rules": [
{
"t": "set",
"p": "sensor",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "change",
"p": "sensor",
"pt": "msg",
"from": "regulärer Ausdruck 1",
"fromt": "re",
"to": "sensor=$1&",
"tot": "str"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "regulärer Ausdruck 1",
"fromt": "re",
"to": "$2",
"tot": "str"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "sensor & payload",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 370,
"y": 420,
"wires": [
[
"8f2f9056.142df"
]
]
},
{
"id": "422395bb.577e9c",
"type": "inject",
"z": "3a33383f.1533a8",
"name": "Datensatz 1",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "1 v=2968&c=26&t=2052&h=4400&f=1&sy=1&rssi=-890&fo=1647&be=0",
"payloadType": "str",
"x": 130,
"y": 380,
"wires": [
[
"1a84a0da.5e21bf"
]
]
},
{
"id": "5847e67d.8cb448",
"type": "inject",
"z": "3a33383f.1533a8",
"name": "Datensatz 2",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "2 v=3186&c=11&t=3584&h=1850&f=1&sy=0&rssi=-1015&fo=3601&be=2",
"payloadType": "str",
"x": 130,
"y": 460,
"wires": [
[
"1a84a0da.5e21bf"
]
]
},
{
"id": "8f2f9056.142df",
"type": "change",
"z": "3a33383f.1533a8",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "$split(payload, '&')\t",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 630,
"y": 420,
"wires": [
[
"7fde6acc.98bef4"
]
]
},
{
"id": "7fde6acc.98bef4",
"type": "split",
"z": "3a33383f.1533a8",
"name": "",
"splt": "\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 820,
"y": 420,
"wires": [
[
"ca901074.f895"
]
]
},
{
"id": "ca901074.f895",
"type": "change",
"z": "3a33383f.1533a8",
"name": "Bilde Key:Value Paare",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "payload",
"tot": "msg"
},
{
"t": "change",
"p": "topic",
"pt": "msg",
"from": "regulärer Ausdruck 2",
"fromt": "re",
"to": "$1",
"tot": "str"
},
{
"t": "change",
"p": "payload",
"pt": "msg",
"from": "regulärer Ausdruck 2",
"fromt": "re",
"to": "$2",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1020,
"y": 420,
"wires": [
[
"17727545.61385b"
]
]
},
{
"id": "17727545.61385b",
"type": "join",
"z": "3a33383f.1533a8",
"name": "",
"mode": "custom",
"build": "object",
"property": "payload",
"propertyType": "msg",
"key": "topic",
"joiner": "",
"joinerType": "str",
"accumulate": false,
"timeout": "",
"count": "10",
"reduceRight": false,
"reduceExp": "",
"reduceInit": "",
"reduceInitType": "",
"reduceFixup": "",
"x": 1210,
"y": 420,
"wires": [
[
"9d55be3c.257f5"
]
]
},
{
"id": "9d55be3c.257f5",
"type": "change",
"z": "3a33383f.1533a8",
"name": "",
"rules": [
{
"t": "set",
"p": "top",
"pt": "msg",
"to": "'Example.Sensor' & payload.sensor",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1380,
"y": 420,
"wires": [
[
"e764eefc.a2835"
]
]
},
{
"id": "e764eefc.a2835",
"type": "subflow:6fabb801.91dd08",
"z": "3a33383f.1533a8",
"name": "",
"x": 1620,
"y": 420,
"wires": [
[
"71bf22b3.d044ac"
]
]
},
{
"id": "71bf22b3.d044ac",
"type": "change",
"z": "3a33383f.1533a8",
"name": "",
"rules": [
{
"t": "change",
"p": "topic",
"pt": "msg",
"from": "0_userdata.0",
"fromt": "str",
"to": "",
"tot": "str"
},
{
"t": "change",
"p": "topic",
"pt": "msg",
"from": ".",
"fromt": "str",
"to": "/",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1860,
"y": 420,
"wires": [
[
"ea7816e.9451be8"
]
]
},
{
"id": "ea7816e.9451be8",
"type": "debug",
"z": "3a33383f.1533a8",
"name": "mqtt output",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 2050,
"y": 420,
"wires": []
}
]