Hello @MeAlbert,
You wrote:
I want to get the 928,942,107514 part from the string.
I try to split the string to fetch part 6 ,7 and 8 (eg the previous mentioned numbers) but do not have the knowledge to fiddle it out.
How should the function be written? Or can I do it with standard nodes? I have not figured it out yet.
I do not know what the values 928, 942 and 107514 represents, but it is quite simple to parse them.
Although, I use the "Function" node quite often I have chosen this time for more or less the "Node-Red way" to solve this issue.
The complete string itself has 3694 characters and only a part is visible here. I do not hope, that the invisible part interferes with the solution.
For now I will test with the string below:
Code: Select all
"var version="H4.01.36Y2.0.03W1.0.04";var m2mMid="613448090";var wlanMac="AC:CF:23:18:6B:68";var m2mRssi="20%";var wanIp="192.xxx.xxx.xx";var nmac="ACCF23186B6B";var fephy="off";var webData="A0415D0056,V1.10,V1.10,SolarSmart 2.5KW, 2500,928,942,107514,F1f,3"
This string is injected by the "Inject" node. You should replace this "Inject" node with your node that has as output this complete string.
The flow is as follows:

- Screenshot_parse string.png (33.66 KiB) Viewed 536 times
The explanation.
1. "Inject" node in order to inject the string into the flow. This node should be replaced by the output of the node that provides the complete string.
2. If we zoom closer into the received string we see multiple elements, starting with "var" and separated by a semicolon (;)
So the next node is a default "core" node of Node Red, which will split the string in multiple messages. As separator in the "Split" node, we will use the semicolon (;)
3. At the output we receive a lot of messages, but actually we are only interested in the message that starts with var webData, so we filter this one out. The next node is the "Switch" node and as selection criterion, we will use "contains" and "webData".
4. Now as we have only left the message, we are interested in, we will need to split it again. This is the same as the second node, except that as separator, we will use a comma (,) and the result will be ten messages.
5. We will put these ten messages in an array. Therefor we need a non default node, called buffer-array.
This node has to be installed using the Palette or from the command line.
See:
https://flows.nodered.org/node/node-red ... ffer-array
This will give you the output, as shown in the picture above.
6. From there it is quite easy to pickup the desired values as they are available as msg.payload[5], msg.payload[6] and msg.payload[7]
To push it to Domoticz, you can use as "svalue" : msg.payload[5]
7. If the buffer of the "buffer array" node is not empty, every incoming message results in an output message. If that is not desired you can use a RBE node, that outputs only a changed value. In order to test, I wanted to be able to reset the RBE node, so an "Inject" node that resets the RBE node has been added as well, but is not necessary.
Please find the complete flow below:
Code: Select all
[{"id":"36978604.a93072","type":"tab","label":"Test","disabled":false,"info":""},{"id":"59bc29e6.8c5428","type":"inject","z":"36978604.a93072","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"var version=\"H4.01.36Y2.0.03W1.0.04\";var m2mMid=\"613448090\";var wlanMac=\"AC:CF:23:18:6B:68\";var m2mRssi=\"20%\";var wanIp=\"192.xxx.xxx.xx\";var nmac=\"ACCF23186B6B\";var fephy=\"off\";var webData=\"A0415D0056,V1.10,V1.10,SolarSmart 2.5KW, 2500,928,942,107514,F1f,3","payloadType":"str","x":250,"y":80,"wires":[["ee915aef.e4b19"]]},{"id":"ee915aef.e4b19","type":"split","z":"36978604.a93072","name":"","splt":";","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":410,"y":80,"wires":[["f43f31d9.7e8348"]]},{"id":"f43f31d9.7e8348","type":"switch","z":"36978604.a93072","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"webData","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":570,"y":80,"wires":[["2b0e3b0c.d6dc1c"]]},{"id":"2b0e3b0c.d6dc1c","type":"split","z":"36978604.a93072","name":"","splt":",","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":730,"y":80,"wires":[["6c83e2d0.80eda4"]]},{"id":"6c83e2d0.80eda4","type":"buffer-array","z":"36978604.a93072","name":"","bufferLen":"10","startWhenFilled":true,"x":910,"y":80,"wires":[["75f8a165.5d781"]]},{"id":"7200c4d1.703654","type":"debug","z":"36978604.a93072","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1270,"y":80,"wires":[]},{"id":"75f8a165.5d781","type":"rbe","z":"36978604.a93072","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":1090,"y":80,"wires":[["7200c4d1.703654"]]},{"id":"2f11dae8.bdea9e","type":"inject","z":"36978604.a93072","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"reset","payloadType":"str","x":910,"y":140,"wires":[["75f8a165.5d781"]]}]
Good luck and best regards.