[
{
"id": "c3403a60.92fbb8",
"type": "subflow",
"name": "JSON or Obj to IOBroker",
"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": "94876630.f71748"
}
]
}
],
"out": [
{
"x": 2280,
"y": 260,
"wires": [
{
"id": "74b0b536.02371c",
"port": 0
},
{
"id": "ab9b1e85.eea2a",
"port": 0
}
]
}
],
"env": [],
"color": "#E2D96E",
"icon": "node-red/batch.svg"
},
{
"id": "eea737e7.7e8fb8",
"type": "split",
"z": "c3403a60.92fbb8",
"name": "split object",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "key",
"x": 1170,
"y": 160,
"wires": [
[
"dc473616.c2b508"
]
]
},
{
"id": "dc473616.c2b508",
"type": "change",
"z": "c3403a60.92fbb8",
"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": [
[
"78697695.9a72c8"
]
]
},
{
"id": "78697695.9a72c8",
"type": "switch",
"z": "c3403a60.92fbb8",
"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": [
[
"d839cef8.577f1"
],
[
"eea737e7.7e8fb8"
],
[
"bdfdae99.f4d9d"
]
]
},
{
"id": "d839cef8.577f1",
"type": "split",
"z": "c3403a60.92fbb8",
"name": "split array",
"splt": "\\n",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 580,
"y": 280,
"wires": [
[
"36327f2d.8efc3"
]
]
},
{
"id": "36327f2d.8efc3",
"type": "change",
"z": "c3403a60.92fbb8",
"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": [
[
"d8f58d9b.b6a1"
]
]
},
{
"id": "74b0b536.02371c",
"type": "change",
"z": "c3403a60.92fbb8",
"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": "4cdee7cb.910c38",
"type": "switch",
"z": "c3403a60.92fbb8",
"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": [
[
"c1c41535.17d3b8"
],
[
"eea737e7.7e8fb8"
],
[
"d839cef8.577f1"
],
[
"d8f58d9b.b6a1"
]
]
},
{
"id": "c1c41535.17d3b8",
"type": "json",
"z": "c3403a60.92fbb8",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 570,
"y": 120,
"wires": [
[
"3ccd67db.375058"
]
]
},
{
"id": "bdfdae99.f4d9d",
"type": "switch",
"z": "c3403a60.92fbb8",
"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": [
[
"74b0b536.02371c"
],
[
"7ba7dc21.fdb214"
]
]
},
{
"id": "7ba7dc21.fdb214",
"type": "change",
"z": "c3403a60.92fbb8",
"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": [
[
"ab9b1e85.eea2a"
]
]
},
{
"id": "ab9b1e85.eea2a",
"type": "rbe",
"z": "c3403a60.92fbb8",
"name": "",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"septopics": true,
"property": "payload",
"x": 2130,
"y": 300,
"wires": [
[]
]
},
{
"id": "94876630.f71748",
"type": "change",
"z": "c3403a60.92fbb8",
"name": "",
"rules": [
{
"t": "delete",
"p": "topic",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 210,
"y": 160,
"wires": [
[
"4cdee7cb.910c38"
]
]
},
{
"id": "3ccd67db.375058",
"type": "switch",
"z": "c3403a60.92fbb8",
"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": [
[
"d839cef8.577f1"
],
[
"eea737e7.7e8fb8"
]
]
},
{
"id": "80dde279.c28ec",
"type": "comment",
"z": "c3403a60.92fbb8",
"name": "Array",
"info": "",
"x": 400,
"y": 280,
"wires": []
},
{
"id": "95ee816e.68a16",
"type": "comment",
"z": "c3403a60.92fbb8",
"name": "object",
"info": "",
"x": 1140,
"y": 100,
"wires": []
},
{
"id": "d8f58d9b.b6a1",
"type": "switch",
"z": "c3403a60.92fbb8",
"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": [
[
"eea737e7.7e8fb8"
],
[
"d839cef8.577f1"
],
[
"bdfdae99.f4d9d"
]
]
},
{
"id": "b1c7e4de.c5e3b8",
"type": "change",
"z": "6e170384.60c96c",
"name": "",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "$split(payload, ',')\t",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1770,
"y": 4500,
"wires": [
[
"dbb1239.52cf7e",
"3b50374d.40bbc8",
"8f074db1.50967"
]
]
},
{
"id": "8088f4f7.6eb0d8",
"type": "inject",
"z": "6e170384.60c96c",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "mqtt.0.SmartZähler_4_1.Status None, 32766, 32766, 32766, 32766, C82B961DCB31, FRITZBOX, -64dB, 192.168.178.99, 5 ",
"payloadType": "str",
"x": 1580,
"y": 4500,
"wires": [
[
"b1c7e4de.c5e3b8"
]
]
},
{
"id": "dbb1239.52cf7e",
"type": "debug",
"z": "6e170384.60c96c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 1990,
"y": 4440,
"wires": []
},
{
"id": "3b50374d.40bbc8",
"type": "change",
"z": "6e170384.60c96c",
"name": "",
"rules": [
{
"t": "set",
"p": "top",
"pt": "msg",
"to": "Example.roland1000",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1990,
"y": 4500,
"wires": [
[
"c95221db.97524"
]
]
},
{
"id": "c95221db.97524",
"type": "subflow:c3403a60.92fbb8",
"z": "6e170384.60c96c",
"name": "",
"x": 2220,
"y": 4500,
"wires": [
[
"d51846e1.274e08"
]
]
},
{
"id": "d51846e1.274e08",
"type": "ioBroker out",
"z": "6e170384.60c96c",
"name": "",
"topic": "",
"ack": "false",
"autoCreate": "true",
"stateName": "",
"role": "",
"payloadType": "",
"readonly": "",
"stateUnit": "",
"stateMin": "",
"stateMax": "",
"x": 2480,
"y": 4500,
"wires": []
},
{
"id": "8f074db1.50967",
"type": "change",
"z": "6e170384.60c96c",
"name": "IP Adress",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "payload.8",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1960,
"y": 4580,
"wires": [
[
"440328e1.b3b188"
]
]
},
{
"id": "440328e1.b3b188",
"type": "debug",
"z": "6e170384.60c96c",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 2140,
"y": 4580,
"wires": []
}
]