# Block value "null"?

**URL:** https://discourse.nodered.org/t/block-value-null/52566
**Category:** General
**Created:** [22 October 2021 10:26 UTC](https://discourse.nodered.org/t/block-value-null/52566 "2021-10-22T10:26:15Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![FSHelgeland](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fshelgeland/32/64260_2.png) [@FSHelgeland](https://discourse.nodered.org/u/FSHelgeland)
#### Post date: [22 October 2021 10:26 UTC](https://discourse.nodered.org/t/block-value-null/52566/1 "2021-10-22T10:26:15Z")

</div>

Node Red version 2.06 running on a RPI.

Hello. I am new to programming in Node Red. And now i need some help. I got a flow from "tibber pulse" which sends a feed with values from my main meter. I get watt consumption every 2.5 seconds. I also get voltage and ampere. Voltage and ampere values is presented in the feed every five minutes or at least more seldom. When the values from voltage and ampere isnt presented, they are presented with "null" in the feed. How can i block the value "null" and just let the correct values for Voltage and Ampere go through?

Best regards Freddy.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [22 October 2021 10:45 UTC](https://discourse.nodered.org/t/block-value-null/52566/2 "2021-10-22T10:45:58Z")

</div>

Welcome to the forum @FSHelgeland

Show us what the data looks like in a debug node so we can see exactly what you are getting. Null can mean a number of things. It could be a String "null", or an undefined value for example.

---

<div class="post-metadata">

### Author: ![FSHelgeland](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fshelgeland/32/64260_2.png) [@FSHelgeland](https://discourse.nodered.org/u/FSHelgeland)
#### Post date: [22 October 2021 12:39 UTC](https://discourse.nodered.org/t/block-value-null/52566/3 "2021-10-22T12:39:59Z")

</div>

payload.voltagePhase1  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/c/2c42e32e9f526305c091d0caa0db241cdaeef1d0.png)

payload.voltagePhase1  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/9/593a1d4e598a4ad359b381bb9053aebd1b7d78e3.png)

Is this any help? Thank you for your quick answer.

I need to pass this to a modbus write node btw.

---

<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: [22 October 2021 12:43 UTC](https://discourse.nodered.org/t/block-value-null/52566/4 "2021-10-22T12:43:17Z")

</div>

Would a switch node set to `is not null` work? or `is of type` number

---

<div class="post-metadata">

### Author: ![FSHelgeland](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fshelgeland/32/64260_2.png) [@FSHelgeland](https://discourse.nodered.org/u/FSHelgeland)
#### Post date: [22 October 2021 16:35 UTC](https://discourse.nodered.org/t/block-value-null/52566/5 "2021-10-22T16:35:30Z")

</div>

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

Like this? Am I missing something? Cant get any data out of the switch node as it is now.

---

<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: [22 October 2021 16:37 UTC](https://discourse.nodered.org/t/block-value-null/52566/6 "2021-10-22T16:37:30Z")

</div>

The data is in `msg.payload.voltagePhase1` not `msg.payload`

---

<div class="post-metadata">

### Author: ![FSHelgeland](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fshelgeland/32/64260_2.png) [@FSHelgeland](https://discourse.nodered.org/u/FSHelgeland)
#### Post date: [22 October 2021 16:40 UTC](https://discourse.nodered.org/t/block-value-null/52566/7 "2021-10-22T16:40:40Z")

</div>

I got several payloads. I put them in a function in front of the switch node.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/8/0873a08aa2262162c846d6bd2cc48f0a95c36a86.png)  
I cant do it like that?

---

<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: [22 October 2021 16:57 UTC](https://discourse.nodered.org/t/block-value-null/52566/8 "2021-10-22T16:57:46Z")

</div>

Yes and if any one is null you don't want to proceed.  
As said You set the switch node to look a msg.payload, when you need to set it to msg.payload.voltagePhase1, that should work.  
But if you want to test all three use a JSONata expression as below

```auto
[{"id":"a999b7f9.565c2","type":"inject","z":"b779de97.b1b46","name":"correct payloads","props":[{"p":"payload.volt1","v":"1","vt":"num"},{"p":"payload.volt2","v":"2","vt":"num"},{"p":"payload.volt3","v":"3","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":180,"y":4800,"wires":[["1313f93b.d0b027"]]},{"id":"1313f93b.d0b027","type":"switch","z":"b779de97.b1b46","name":"","property":"payload.volt1 != null and payload.volt2 != null and payload.volt3 != null","propertyType":"jsonata","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":350,"y":4880,"wires":[["2154a993.49803e"]]},{"id":"2154a993.49803e","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":4840,"wires":[]},{"id":"df7a7f43.076728","type":"change","z":"b779de97.b1b46","name":"","rules":[{"t":"set","p":"payload.volt1","pt":"msg","to":"null","tot":"jsonata"},{"t":"set","p":"payload.volt2","pt":"msg","to":"null","tot":"jsonata"},{"t":"set","p":"payload.volt3","pt":"msg","to":"null","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":4940,"wires":[["1313f93b.d0b027"]]},{"id":"49eead0a.7f7534","type":"inject","z":"b779de97.b1b46","name":"null payloads","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{}","payloadType":"json","x":120,"y":4940,"wires":[["df7a7f43.076728"]]}]

```

---

<div class="post-metadata">

### Author: ![FSHelgeland](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fshelgeland/32/64260_2.png) [@FSHelgeland](https://discourse.nodered.org/u/FSHelgeland)
#### Post date: [22 October 2021 17:21 UTC](https://discourse.nodered.org/t/block-value-null/52566/9 "2021-10-22T17:21:17Z")

</div>

> [@E1cid](#):
>
> `[{"id":"a999b7f9.565c2","type":"inject","z":"b779de97.b1b46","name":"correct payloads","props":[{"p":"payload.volt1","v":"1","vt":"num"},{"p":"payload.volt2","v":"2","vt":"num"},{"p":"payload.volt3","v":"3","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":180,"y":4800,"wires":[["1313f93b.d0b027"]]},{"id":"1313f93b.d0b027","type":"switch","z":"b779de97.b1b46","name":"","property":"payload.volt1 != null and payload.volt2 != null and payload.volt3 != null","propertyType":"jsonata","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":350,"y":4880,"wires":[["2154a993.49803e"]]},{"id":"2154a993.49803e","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":4840,"wires":[]},{"id":"df7a7f43.076728","type":"change","z":"b779de97.b1b46","name":"","rules":[{"t":"set","p":"payload.volt1","pt":"msg","to":"null","tot":"jsonata"},{"t":"set","p":"payload.volt2","pt":"msg","to":"null","tot":"jsonata"},{"t":"set","p":"payload.volt3","pt":"msg","to":"null","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":4940,"wires":[["1313f93b.d0b027"]]},{"id":"49eead0a.7f7534","type":"inject","z":"b779de97.b1b46","name":"null payloads","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"num","x":120,"y":4940,"wires":[["df7a7f43.076728"]]}]`

Where do i put that expression?

---

<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: [22 October 2021 17:24 UTC](https://discourse.nodered.org/t/block-value-null/52566/10 "2021-10-22T17:24:21Z")

</div>

it goes in the switch node, you will need to edit it, as i did not use your property names, as it is just an example.

---

<div class="post-metadata">

### Author: ![FSHelgeland](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fshelgeland/32/64260_2.png) [@FSHelgeland](https://discourse.nodered.org/u/FSHelgeland)
#### Post date: [22 October 2021 17:33 UTC](https://discourse.nodered.org/t/block-value-null/52566/11 "2021-10-22T17:33:41Z")

</div>

Thank you. I will try that.

---

<div class="post-metadata">

### Author: ![FSHelgeland](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fshelgeland/32/64260_2.png) [@FSHelgeland](https://discourse.nodered.org/u/FSHelgeland)
#### Post date: [22 October 2021 17:50 UTC](https://discourse.nodered.org/t/block-value-null/52566/12 "2021-10-22T17:50:01Z")

</div>

Hmmmm why didnt i listen the first time? I got it to work whith your first suggestion. Tnx again, owe you one.

---

<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: [5 November 2021 17:50 UTC](https://discourse.nodered.org/t/block-value-null/52566/13 "2021-11-05T17:50:07Z")

</div>

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