# HTML request / handle of data

**URL:** https://discourse.nodered.org/t/html-request-handle-of-data/3191
**Category:** General
**Created:** [16 September 2018 17:05 UTC](https://discourse.nodered.org/t/html-request-handle-of-data/3191 "2018-09-16T17:05:15Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![maxmueller50](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxmueller50/32/2621_2.png) [@maxmueller50](https://discourse.nodered.org/u/maxmueller50)
#### Post date: [16 September 2018 17:05 UTC](https://discourse.nodered.org/t/html-request-handle-of-data/3191/1 "2018-09-16T17:05:15Z")

</div>

my garden-irrigation is now working, very fine thing - but I have a "big" problem, where I can't fine the way in Node-Red Flow for receiving data from the Water-pump. there are water-pressure and two level-switches and the ESP8266 send me the the data  
Water = 1019  
Level 1 = 0  
Level 2 = 1  
now I have to handle first of all:  
Level 1 = 0 means pump and water is ok / Level 1 = 1 means no water or pump is off (topic Pump to ON or STOPP)  
Level 2 = ... the same as above for the water supply (topic supply-pump ON or OFF)

how I can divide this html-phrase to use this two argument as "true/false" or 1/0 in the flow of node-red

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [16 September 2018 18:15 UTC](https://discourse.nodered.org/t/html-request-handle-of-data/3191/2 "2018-09-16T18:15:14Z")

</div>

If you are just trying to change a 0 or 1 to boolean true/false, just use a change node.

![change](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2609f12206b19a43ae11a3379fd4f369e2624c98.png)

Paul

---

<div class="post-metadata">

### Author: ![maxmueller50](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxmueller50/32/2621_2.png) [@maxmueller50](https://discourse.nodered.org/u/maxmueller50)
#### Post date: [17 September 2018 07:24 UTC](https://discourse.nodered.org/t/html-request-handle-of-data/3191/3 "2018-09-17T07:24:57Z")

</div>

thank you but this I have already done  
my problem is to separate the payload:

 Water = 1019  
Level 1 = 0  
Level 2 = 1

in:  
Water = 1019  
Level 1 = 0  
Level 2 = 1  
so in a function I can find out by if "Level 1 = 1" then / else; or if "Level = 1" then / else  
I do not want to succeed

Max

---

<div class="post-metadata">

### Author: ![michaelblight](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/michaelblight/32/445_2.png) [@michaelblight](https://discourse.nodered.org/u/michaelblight)
#### Post date: [17 September 2018 08:55 UTC](https://discourse.nodered.org/t/html-request-handle-of-data/3191/4 "2018-09-17T08:55:30Z")

</div>

Are you saying the payload is the string below (for example):

```
Water = 1019
Level 1 = 0
Level 2 = 1

```

And you want to pull out the separate parts? One way to do this would be to use a `change node` to replace all the "=" characters with ":", and then pass the payload into a `yaml node`.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/6325db172f77c21403ac91c189ad9f9058f9fb57.png)

`[{"id":"7f22ef57.d3278","type":"yaml","z":"f6747993.c9b448","property":"payload","name":"","x":570,"y":100,"wires":[["c46ecbf4.b416a8"]]},{"id":"c06a49fd.f9a6b8","type":"change","z":"f6747993.c9b448","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"=","fromt":"str","to":":","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":100,"wires":[["7f22ef57.d3278"]]}]`

Then your payload will be an object with properties "Water", "Level 1" and "Level 2". Is that what you're after?

Although if the only thing you wanted to do was an if-test based on "Level 1 = 0", it would probably be easiest to just look for this whole string. For example:

```
if (msg.payload.indexOf("Level 1 = 0") >= 0) {
    msg.level1 = "It's zero";
} else {
    msg.level1 = "It's not";
}
return msg;
```

---

<div class="post-metadata">

### Author: ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)
#### Post date: [17 September 2018 09:41 UTC](https://discourse.nodered.org/t/html-request-handle-of-data/3191/5 "2018-09-17T09:41:44Z")

</div>

Max, it's maybe too late now, but using MQTT to pass messages from the ESP to node-RED is much simpler, because you could create different topics to handle different identifiers, such as;

| Topic | Value |
| --- | --- |
| irrigation/water | 1019 |
| irrigation/level/1 | 1 |
| irrigation/level/2 | 0 |

And you would read those values in node-RED by simply subscribing to the particular topic;

![mqtt](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1b0877ca2f57ad4229ed3a8d13fda05ce100c867.png)

It's also much more reliable as you can use QoS to ensure that the messages are received.

Paul

---

<div class="post-metadata">

### Author: ![maxmueller50](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxmueller50/32/2621_2.png) [@maxmueller50](https://discourse.nodered.org/u/maxmueller50)
#### Post date: [17 September 2018 10:39 UTC](https://discourse.nodered.org/t/html-request-handle-of-data/3191/6 "2018-09-17T10:39:07Z")

</div>

many thanks Michael

the second way help!  
I didn't think on this: msg.payload.index0f  
now for booth Level 1 and Level 2 I can test 0 or 1

thank you again

---

<div class="post-metadata">

### Author: ![maxmueller50](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/maxmueller50/32/2621_2.png) [@maxmueller50](https://discourse.nodered.org/u/maxmueller50)
#### Post date: [17 September 2018 10:41 UTC](https://discourse.nodered.org/t/html-request-handle-of-data/3191/7 "2018-09-17T10:41:50Z")

</div>

thank you Paul

now I could find the solution

for MQTT - later when the project is finished, then I will try as the net step

thank you again for helping

Max
