Split the string and set to number

Hello,

0-1:24.2.3(201129181002W)(00050.845*m3)

I got this payload from my smart meter, i need only the m3 value.

How can i do that ?

Kind Regards

There are a few ways, heres one using the change node and regex.

[{"id":"e0597e54.0f3c18","type":"inject","z":"8d22ae29.7df6d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0-1:24.2.3(201129181002W)(00050.845*m3)","payloadType":"str","x":120,"y":2880,"wires":[["5cc60b28.f825bc"]]},{"id":"5cc60b28.f825bc","type":"change","z":"8d22ae29.7df6d","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":".*\\)\\((.*)\\*m3\\)","fromt":"re","to":"$1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":2880,"wires":[["39c1c718.e9731"]]},{"id":"39c1c718.e9731","type":"debug","z":"8d22ae29.7df6d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":590,"y":2860,"wires":[]}]

Fixed missing change node.

1 Like

This is not a robust solution, but regular expressions can extract this more "easily" (this will match 5 digits . 3 digits)

@E1cid at the same time :wink: you are missing the change node in your flow

1 Like

Thanks a lot !! :slight_smile: