Hello Forum,
i want to process Data from a external Device and the Data looks like "P-131_SPO=-200W"
i want to process the Filed "P-131_SPO" -> -131
and The Value "-200W" -> -200 (W)
split at "=" and "_" works well, but i can´t find a splitter / seperator to the letters form the Numbers ( in String)
thanks for your help in advanced
olby2
My Flow:
( I split it here fixed with "P" but that is not a allover solution )
[
{
"id": "1ab3bd40d14573ed",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": "",
"env": []
},
{
"id": "df6d6c66.b6c4e",
"type": "split",
"z": "1ab3bd40d14573ed",
"name": "",
"splt": "=",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "xy",
"x": 550,
"y": 260,
"wires": [
[
"3ba2aff1.e8af5",
"9052efa8.e5f0a"
]
]
},
{
"id": "d9822859.20a7b8",
"type": "inject",
"z": "1ab3bd40d14573ed",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": "",
"topic": "",
"payload": "P-131_SPO=-200W",
"payloadType": "str",
"x": 320,
"y": 260,
"wires": [
[
"bc23045.f5103f8",
"df6d6c66.b6c4e"
]
]
},
{
"id": "2f990562.44d8ea",
"type": "debug",
"z": "1ab3bd40d14573ed",
"name": "out 1",
"active": false,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 840,
"y": 100,
"wires": []
},
{
"id": "fe502aa1.ee37c8",
"type": "change",
"z": "1ab3bd40d14573ed",
"name": "to number",
"rules": [
{
"t": "set",
"p": "payload[1]",
"pt": "msg",
"to": "$number(msg.payload)\t",
"tot": "jsonata"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1090,
"y": 580,
"wires": [
[
"d6f23ad6.490eb8"
]
]
},
{
"id": "9052efa8.e5f0a",
"type": "switch",
"z": "1ab3bd40d14573ed",
"name": "route",
"property": "parts.index",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "0",
"vt": "num"
},
{
"t": "eq",
"v": "1",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 710,
"y": 260,
"wires": [
[
"2f990562.44d8ea",
"c2ce6b8c765f31cc"
],
[
"35825546.228baa"
]
]
},
{
"id": "35825546.228baa",
"type": "debug",
"z": "1ab3bd40d14573ed",
"name": "out 2",
"active": false,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 860,
"y": 400,
"wires": []
},
{
"id": "bc23045.f5103f8",
"type": "debug",
"z": "1ab3bd40d14573ed",
"name": "source data",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 450,
"y": 600,
"wires": []
},
{
"id": "3ba2aff1.e8af5",
"type": "debug",
"z": "1ab3bd40d14573ed",
"name": "spltted",
"active": false,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 680,
"y": 500,
"wires": []
},
{
"id": "d6f23ad6.490eb8",
"type": "debug",
"z": "1ab3bd40d14573ed",
"name": "converted",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 1390,
"y": 580,
"wires": []
},
{
"id": "c2ce6b8c765f31cc",
"type": "split",
"z": "1ab3bd40d14573ed",
"name": "",
"splt": "_",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 910,
"y": 240,
"wires": [
[
"b37d5ea810ae500e",
"d26639cda9cc46fb"
]
]
},
{
"id": "81c9a0927cc47837",
"type": "debug",
"z": "1ab3bd40d14573ed",
"name": "Feldnummer",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 1660,
"y": 340,
"wires": []
},
{
"id": "ab6aafad6bfcafec",
"type": "debug",
"z": "1ab3bd40d14573ed",
"name": "",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 1310,
"y": 200,
"wires": []
},
{
"id": "05e66712e76b09f5",
"type": "switch",
"z": "1ab3bd40d14573ed",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "$split(msg.payload,\"P\" )",
"vt": "jsonata"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 1490,
"y": 260,
"wires": [
[]
]
},
{
"id": "b37d5ea810ae500e",
"type": "switch",
"z": "1ab3bd40d14573ed",
"name": "separator",
"property": "parts.index",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "0",
"vt": "str"
},
{
"t": "eq",
"v": "1",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 1120,
"y": 260,
"wires": [
[
"ab6aafad6bfcafec",
"6f51716ebffcbe6a"
],
[
"0f8f4bed7a12472e"
]
]
},
{
"id": "0f8f4bed7a12472e",
"type": "debug",
"z": "1ab3bd40d14573ed",
"name": "",
"active": false,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 1310,
"y": 380,
"wires": []
},
{
"id": "d26639cda9cc46fb",
"type": "debug",
"z": "1ab3bd40d14573ed",
"name": "",
"active": false,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 1110,
"y": 200,
"wires": []
},
{
"id": "6f51716ebffcbe6a",
"type": "split",
"z": "1ab3bd40d14573ed",
"name": "",
"splt": "P",
"spltType": "str",
"arraySplt": 1,
"arraySpltType": "len",
"stream": false,
"addname": "",
"x": 1320,
"y": 280,
"wires": [
[
"05e66712e76b09f5",
"81c9a0927cc47837"
]
]
}
]