# Threshold node will not output

**URL:** <https://discourse.nodered.org/t/threshold-node-will-not-output/19942>\
**Category:** General\
**Created:** [5 January 2020 19:19 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942 "2020-01-05T19:19:57Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Quanta](https://avatars.discourse-cdn.com/v4/letter/q/6de8d8/32.png) [@Quanta](https://discourse.nodered.org/u/Quanta)\
**Post date:** [5 January 2020 19:19 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/1 "2020-01-05T19:19:57Z")

</div>

Greetings all.

Still new to NR and having some trouble with something which is probably very basic. I have done the requisite search and study (hours not minutes) but to my shame, I can't seem to find the key.

The code below is intended to periodically ping an ip address and if the number of failed attempts rises above some number in some minutes time, trigger an output (power cycle router). The trouble is that the threshold node never produces an output. Debug node 1 gives me:

> Blockquote  
> {"payload":false,"topic":"192.168.2.3","\_msgid":"326f9f28.7032","checkValue":11}

Values configured in threshold less than checkValue (even 0) do not result in any output from threshold node appearing in debug node 2. Info for threshold node says:

> Blockquote  
> ...The node takes a single input. If that input value is higher than the threshold then the payload is delivered but only when the threshold is exceeded...  
> ...add an attribute to that payload: payload.checkValue. The checkValue will be compared to the Threshold defined in the node editor each time a new payload arrives....

What am I not understanding?

Flow is below.

Hope you can help.

Q

```auto
[
    {
        "id": "dceb6fb1.f4efc",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "606bf72e.c70588",
        "type": "switch",
        "z": "dceb6fb1.f4efc",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "else"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 310,
        "y": 100,
        "wires": [
            [],
            [
                "88aed5ce.230858"
            ]
        ]
    },
    {
        "id": "d060335f.b011a",
        "type": "ping",
        "z": "dceb6fb1.f4efc",
        "name": "",
        "host": "192.168.2.3",
        "timer": "1",
        "x": 130,
        "y": 100,
        "wires": [
            [
                "606bf72e.c70588"
            ]
        ]
    },
    {
        "id": "be1b0a1c.6311a8",
        "type": "debug",
        "z": "dceb6fb1.f4efc",
        "name": "1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 490,
        "y": 220,
        "wires": []
    },
    {
        "id": "88aed5ce.230858",
        "type": "timed-counter",
        "z": "dceb6fb1.f4efc",
        "name": "",
        "timelimit": "10",
        "timeunit": "1000",
        "withhold": true,
        "fixedtimeout": true,
        "pertopic": false,
        "x": 500,
        "y": 100,
        "wires": [
            [
                "f25dc855.8b1048"
            ]
        ]
    },
    {
        "id": "f68c3980.7d6e18",
        "type": "debug",
        "z": "dceb6fb1.f4efc",
        "name": "2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "x": 490,
        "y": 340,
        "wires": []
    },
    {
        "id": "2e6f2aa1.6d8456",
        "type": "threshold",
        "z": "dceb6fb1.f4efc",
        "name": "checkValue",
        "thresholdValue": "2",
        "x": 170,
        "y": 340,
        "wires": [
            [
                "f68c3980.7d6e18"
            ]
        ]
    },
    {
        "id": "f25dc855.8b1048",
        "type": "change",
        "z": "dceb6fb1.f4efc",
        "name": "",
        "rules": [
            {
                "t": "move",
                "p": "count",
                "pt": "msg",
                "to": "checkValue",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 180,
        "y": 220,
        "wires": [
            [
                "2e6f2aa1.6d8456",
                "be1b0a1c.6311a8"
            ]
        ]
    }
]

```

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [5 January 2020 19:40 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/2 "2020-01-05T19:40:48Z")

</div>

Hi.

One thing which is a _problem_:

- You are using non standard nodes. I thought I had some, but didn't.

When I went to install the `ping` node..... There are just a few from which to choose.  
Typically I chose the wrong one.

It would help if you wrote down the complete name of the node.

Say:  
`node-red-configurable-ping`

It would be appreciated.

---

<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:** [5 January 2020 20:14 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/3 "2020-01-05T20:14:41Z")

</div>

what does the debug message say the value of msg.payload.checkValue

---

<div class="post-metadata">

**Author:** ![Quanta](https://avatars.discourse-cdn.com/v4/letter/q/6de8d8/32.png) [@Quanta](https://discourse.nodered.org/u/Quanta)\
**Post date:** [5 January 2020 22:18 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/4 "2020-01-05T22:18:49Z")

</div>

To address your comment - node-red-node-ping. Please specify the appropriate _ **standard** _ nodes you think I should be using and why.

I don't believe it is pertinent actually because my trouble is with the change / threshold node interaction. The debug output of the ping has "count" which I re-labled checkValue in change node as shown. Some other ping might work better but for some 'reason' I picked this one.

Q

---

<div class="post-metadata">

**Author:** ![Quanta](https://avatars.discourse-cdn.com/v4/letter/q/6de8d8/32.png) [@Quanta](https://discourse.nodered.org/u/Quanta)\
**Post date:** [5 January 2020 22:23 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/5 "2020-01-05T22:23:52Z")

</div>

Perhaps this goes to the thing I am missing/don't get-

> [@E1cid](#):
>
> what does the debug message say the value of msg.payload.checkValue

Didn't I already provide this information in my OP?

> [@Quanta](#):
>
> Debug node 1 gives me:
> 
> > Blockquote  
> > {"payload":false,"topic":"192.168.2.3","\_msgid":"326f9f28.7032","checkValue":11}

Thanks for the attention.

Q

---

<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:** [5 January 2020 22:35 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/6 "2020-01-05T22:35:42Z")

</div>

i don't think youe checkValue is in the payload ie. msg.payload.checkValue  
its in msg.checkValue

I am new to node-red myself and do not have that node installed. but from reading your question it said "add an attribute to that payload: payload.checkValue. "

---

<div class="post-metadata">

**Author:** ![Quanta](https://avatars.discourse-cdn.com/v4/letter/q/6de8d8/32.png) [@Quanta](https://discourse.nodered.org/u/Quanta)\
**Post date:** [5 January 2020 22:38 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/7 "2020-01-05T22:38:06Z")

</div>

Thanks for the reply.

Isn't that what this

> [@Quanta](#):
>
> "checkValue":11

is?

Q

---

<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:** [5 January 2020 22:43 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/8 "2020-01-05T22:43:28Z")

</div>

As i am new i am not 100%

But i think, hopefully someone will jump in if im wrong.  
This is "payload":false," payload and it has a value as boolean :False

the whole thing between {} is msg.  
Topic,\_msgid and ChecValue are seperate properties of msg

How did you atempt add checkValue to Payload?

```auto
{"payload":{"checkValue":11},"topic":"192.168.2.3","_msgid":"326f9f28.7032"}

```

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [5 January 2020 22:56 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/9 "2020-01-05T22:56:32Z")

</div>

```auto
{"payload":false,"topic":"192.168.2.3","_msgid":"326f9f28.7032","checkValue":11}

```

You need to check for `msg.checkValue`, not `msg.payload.checkValue`

---

<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:** [5 January 2020 23:02 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/10 "2020-01-05T23:02:48Z")

</div>

I think the checkVakue has to be added to the payload as the documentation instructs.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [5 January 2020 23:05 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/11 "2020-01-05T23:05:44Z")

</div>

documentation for ?

---

<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:** [5 January 2020 23:07 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/12 "2020-01-05T23:07:16Z")

</div>

written in the quote from the first post, and in install pallete when you read the limited text information.

---

<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:** [5 January 2020 23:14 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/13 "2020-01-05T23:14:15Z")

</div>

> [@Quanta](#):
>
> Didn't I already provide this information in my OP?
> 
> > Debug node 1 gives me:
> > 
> > > Blockquote  
> > > {"payload":false,"topic":"192.168.2.3","\_msgid":"326f9f28.7032","checkValue":11}
> 
> Thanks for the attention.

Sorry, totally missed that info, but the snarky comment is noted.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [5 January 2020 23:24 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/14 "2020-01-05T23:24:21Z")

</div>

You can use this flow (no need for external nodes).

Replace the IP in the inject node, set the inject node to the interval you want to use and it will ping and keep track of the number of times it failed (it will be indicated underneath the function node), after 4 times failed it will generate a message.

Change the number in the function node to the number of times you want it to fail before sending the message.

```auto
[{"id":"1eb3f7f7.842728","type":"inject","z":"aa6ee791.99e188","name":"","topic":"","payload":" 10.0.0.1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":228,"y":192,"wires":[["a25119f7.a58648"]]},{"id":"a25119f7.a58648","type":"exec","z":"aa6ee791.99e188","command":"ping -c1","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":394,"y":192,"wires":[[],[],["1acb109e.6e93d7"]]},{"id":"3b30f993.426e9e","type":"debug","z":"aa6ee791.99e188","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":698,"y":192,"wires":[]},{"id":"1acb109e.6e93d7","type":"function","z":"aa6ee791.99e188","name":"","func":"m = msg.payload.code\nc = context.get(\"pingcount\") || 0\n\nif(m===0){\n node.status({fill:\"green\",shape:\"dot\",text:\"Connected\"});\n context.set(\"pingcount\",1)\n}\nif(m===1){\n context.set(\"pingcount\",c+1)\n node.status({fill:\"red\",shape:\"dot\",text:\"Failed:\"+(c+1)});\n if(c>3){\n node.status({fill:\"red\",shape:\"dot\",text:\"Unreachable\"});\n context.set(\"pingcount\",0)\n return {payload:\"ping failed, rebooting\"}\n \n }\n \n}","outputs":1,"noerr":0,"x":554,"y":192,"wires":[["3b30f993.426e9e"]]}]

```

---

<div class="post-metadata">

**Author:** ![Quanta](https://avatars.discourse-cdn.com/v4/letter/q/6de8d8/32.png) [@Quanta](https://discourse.nodered.org/u/Quanta)\
**Post date:** [6 January 2020 00:52 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/15 "2020-01-06T00:52:16Z")

</div>

Frustrating! Tried to provide necessary info. from start. My 'point' was "I thought that was what I did (( see original post)). If that isn't what I did then what do I need to do (Implied)?"

Wasn't intending to be offensive or inconsiderate. Apologies!

Q

---

<div class="post-metadata">

**Author:** ![Quanta](https://avatars.discourse-cdn.com/v4/letter/q/6de8d8/32.png) [@Quanta](https://discourse.nodered.org/u/Quanta)\
**Post date:** [6 January 2020 00:55 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/16 "2020-01-06T00:55:26Z")

</div>

Thanks for other input. Have some mundane tasks to do now. Comments raise a aquestion or two that I might need clarification on later...

I really appreciate the quick responses!

Q

---

<div class="post-metadata">

**Author:** ![Quanta](https://avatars.discourse-cdn.com/v4/letter/q/6de8d8/32.png) [@Quanta](https://discourse.nodered.org/u/Quanta)\
**Post date:** [6 January 2020 01:53 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/17 "2020-01-06T01:53:46Z")

</div>

Thanks bakman2.

Because of my newness, I was trying to avoid 'unnecessary' use of function nodes. I didn't want to get bogged down in 'the code' if it was possible to stay in 'the flow'. I imagine you can do just about anything with an inject, function and (probably optional) an output node but that isn't what NR is all about - though the function node is indeed a useful and important capability to have.

At any rate, I understand your function and right away I see how it could be expanded to watch over multiple IPs such as point to point links ( I could use this), APs and for failure of my dns, etc. I expect I will use this method. It is simple enough and gets the job done. That is the important part isn't it?

Also, I hadn't got as far as thinking about the ability to execute an external program (ping) which is hidden from view but undoubtedly how the ping node I was using works. Your example is helpful here as well. So more progress!

Regards and thanks again.

Q

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 January 2020 07:52 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/18 "2020-01-06T07:52:45Z")

</div>

> [@Quanta](#):
>
> I don't believe it is pertinent actually because my trouble is with the change / threshold node interaction. The debug output of the ping has "count" which I re-labled checkValue in change node as shown. Some other ping might work better but for some 'reason' I picked this one.

I am not interested in arguing semantics of what nodes should be used.

You posted a flow with non-standard nodes. If you want people to be able to load the flow you need to specify - exactly - the nodes needed.  
Otherwise help won't be as quick in coming.

---

<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:** [6 January 2020 08:30 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/19 "2020-01-06T08:30:08Z")

</div>

Ok apologie accepted.

You provided all info i needed to see your issue, but i missed the debug message info

Anyway akman2 flow is the best option and really neat. We have both learn somthing.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [6 January 2020 08:34 UTC](https://discourse.nodered.org/t/threshold-node-will-not-output/19942/20 "2020-01-06T08:34:43Z")

</div>

@trying_to_learn, The node-red-node-ping node is one of the default nodes on a raspberry Pi. So If you use our install script it is a standard node. If you don't use our script it isn't installed by default so would need to be added.

[Next page](https://discourse.nodered.org/t/threshold-node-will-not-output/19942.md?page=2)
