EspEasy Data filter

I use MQTT from domoticz afther this i put a filter on it to select the IDX fot the right data
When i debug it i got something like this.

{ idx: 350, RSSI: 7, nvalue: 0, svalue: "237.90;0.00;0.00;0.00" }

But now i onely want one value eg the first value.
In a function node i use this

msg.payload = msg.payload.svalue1;
return msg;

but, i get no result the debug window says "undefined"

Can someone please help me

Where does the 1 in svalue1 come from?
It does not exist in your example data. svalue1 is therefore undefined.

I can only assume that you want the first number in the list attached to svalue.

That can be achieved like this:

msg.payload = msg.payload.svalue.split(";")[0];
return msg;

Or in JSONata:

$split($.svalue,";")[0]

When i use this i dont get a result from the filter

When i use the next filter i got a result

image

This is the value what is sent via ESPEasy to MQTT

image

What number do you want?

"237.90;0.00;0.00;0.00"
or
"237.90;0.00;0.00;0.00"

Thanks man this did the job for me,i not a specialist in nod red but you just make my day, thank you very much

1 Like

The value between the ;

I got this here and this do the work for me

msg.payload = msg.payload.svalue.split(";")[2];
return msg;

Hey guys thanks for the fast help

you make me happy

thanks

1 Like

Here are two other methods to get to the string data of svalue and convert to numbers.

[{"id":"201db681adfdfa53","type":"inject","z":"bf622e623503117a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"idx\":350,\"RSSI\":7,\"nvalue\":0,\"svalue\":\"237.90;0.00;0.00;0.00\"}","payloadType":"json","x":310,"y":400,"wires":[["3ade2f7a493c697e","7ab80f2abcc19433"]]},{"id":"3ade2f7a493c697e","type":"change","z":"bf622e623503117a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.svalue","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":400,"wires":[["1e6fc38adb5cf6cf"]]},{"id":"7ab80f2abcc19433","type":"change","z":"bf622e623503117a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$number($substringBefore($$.payload.svalue, \";\"))","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":460,"wires":[["a54e479046a9a022"]]},{"id":"1e6fc38adb5cf6cf","type":"csv","z":"bf622e623503117a","name":"","sep":";","hdrin":"","hdrout":"none","multi":"one","ret":"\\n","temp":"name,another_anme,yet_another","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":610,"y":400,"wires":[["9fec9f2af5cfda9b"]]},{"id":"a54e479046a9a022","type":"debug","z":"bf622e623503117a","name":"debug 264","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":460,"wires":[]},{"id":"9fec9f2af5cfda9b","type":"debug","z":"bf622e623503117a","name":"debug 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":740,"y":400,"wires":[]}]

The csv method requires no coding.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.