# EspEasy Data filter

**URL:** <https://discourse.nodered.org/t/espeasy-data-filter/77910>\
**Category:** General\
**Tags:** function-node\
**Created:** [25 April 2023 09:20 UTC](https://discourse.nodered.org/t/espeasy-data-filter/77910 "2023-04-25T09:20:50Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![spike318](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/spike318/32/79235_2.png) [@spike318](https://discourse.nodered.org/u/spike318)\
**Post date:** [25 April 2023 09:20 UTC](https://discourse.nodered.org/t/espeasy-data-filter/77910/1 "2023-04-25T09:20:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [25 April 2023 09:26 UTC](https://discourse.nodered.org/t/espeasy-data-filter/77910/2 "2023-04-25T09:26:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cameo69](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cameo69/32/66593_2.png) [@cameo69](https://discourse.nodered.org/u/cameo69)\
**Post date:** [25 April 2023 09:44 UTC](https://discourse.nodered.org/t/espeasy-data-filter/77910/3 "2023-04-25T09:44:19Z")

</div>

> [@spike318](#):
>
> **msg.payload = msg.payload.svalue1;**  
> **return msg;**

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

That can be achieved like this:

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

```

Or in JSONata:

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

```

---

<div class="post-metadata">

**Author:** ![spike318](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/spike318/32/79235_2.png) [@spike318](https://discourse.nodered.org/u/spike318)\
**Post date:** [25 April 2023 09:45 UTC](https://discourse.nodered.org/t/espeasy-data-filter/77910/4 "2023-04-25T09:45:56Z")

</div>

> [@spike318](#):
>
> { idx: 350, RSSI: 7, nvalue: 0, svalue: "237.90;0.00;0.00;0.00" }

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/0/40692bda9635fd2aef45e1cfa383190723cef21f.png)

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

When i use the next filter i got a result

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/3/a32649b2d8a2c4115a7a98fb07305c5a72104214.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/a/8aeb8446c45fde92bb1ec8279d420f8a778061cd.png)

This is the value what is sent via ESPEasy to MQTT

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/2/f25c9c1c8c02a797c34d7a297a27569056b09072.png)

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [25 April 2023 09:47 UTC](https://discourse.nodered.org/t/espeasy-data-filter/77910/5 "2023-04-25T09:47:35Z")

</div>

What number do you want?

" **237.90** ;0.00;0.00;0.00"  
or  
" **237**.90;0.00;0.00;0.00"

---

<div class="post-metadata">

**Author:** ![spike318](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/spike318/32/79235_2.png) [@spike318](https://discourse.nodered.org/u/spike318)\
**Post date:** [25 April 2023 09:48 UTC](https://discourse.nodered.org/t/espeasy-data-filter/77910/6 "2023-04-25T09:48:13Z")

</div>

> [@cameo69](#):
>
> ```auto
> msg.payload = msg.payload.svalue.split(";")[0];
> return msg;
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![spike318](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/spike318/32/79235_2.png) [@spike318](https://discourse.nodered.org/u/spike318)\
**Post date:** [25 April 2023 09:49 UTC](https://discourse.nodered.org/t/espeasy-data-filter/77910/7 "2023-04-25T09:49:14Z")

</div>

The value between the ;

I got this here and this do the work for me

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

---

<div class="post-metadata">

**Author:** ![spike318](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/spike318/32/79235_2.png) [@spike318](https://discourse.nodered.org/u/spike318)\
**Post date:** [25 April 2023 09:50 UTC](https://discourse.nodered.org/t/espeasy-data-filter/77910/8 "2023-04-25T09:50:34Z")

</div>

Hey guys thanks for the fast help

you make me happy

thanks

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [25 April 2023 09:56 UTC](https://discourse.nodered.org/t/espeasy-data-filter/77910/9 "2023-04-25T09:56:30Z")

</div>

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

```auto
[{"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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 June 2023 09:57 UTC](https://discourse.nodered.org/t/espeasy-data-filter/77910/10 "2023-06-24T09:57:22Z")

</div>

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