Show if sensor is ative or inactive

I´m testing if a sensor is active or inactive, i used the trigger but not resolved my problem, i´m tried use this way but the problem to be continue:

My function is programmed like this:

if (typeof msg.payload === 'number') {
    msg.payload = true;
} else {
    msg.payload= false;
}
return msg;

When I run the program this gives me the following values ​​of msg.payload:

14/02/2019, 09:45:01[node: test function](http://10.6.4.101:1880/#)ns=2;s=SensorIndutivo : msg.payload : boolean
true

14/02/2019, 09:45:01[node: value received](http://10.6.4.101:1880/#)ns=2;s=SensorIndutivo : msg.payload : number
32.82964323001333

in the dasboard the led when it is true is green but when the sensor stops sending data it does not turn red (value false). The msg.payload of value received when sensor stops not send any value and not turn to red.

You now have 3 threads all on the same topic....
tell me which one you want to use in preference and I will lock the others to stop others getting confused.

I prefere this thread, because is more explicit

can you help me, i´m working about two days in this and i'm not be capable of finding a solution works correctly

cut/paste the output from the first debug node - i.e. what is going into your function - and how often it goes in when working - and what is the time to say it is no longer arriving. (IE what is the repeat time on your inject node)
I should think a simple trigger node would work fine if it's just got to light up an led if configured correctly

This is the value of first debug , the value that is going to my function
image
and the injection node configuration is

and if for some reason the sensor stops sending data (as a sensor problem), the led should turn red to inform the person that the sensor has problems

[quote="smalhao, post:6, topic:7957"]
This is the value of first debug , the value that is going to my function
image
and the injection node configuration is

The OPC-UA Client configuration i forget show
image
and if for some reason the sensor stops sending data (as a sensor problem), the led should turn red to inform the person that the sensor has problems

so maybe replace your function with this

[{"id":"b49bd44b.b8ab38","type":"trigger","z":"82738787.0e0338","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"5000","extend":true,"units":"s","reset":"","bytopic":"all","name":"","x":430,"y":1000,"wires":[["3df4d920.b6d216"]]}]

as long as messages keep arriving the output will be true... if nothing is seen for 5 seconds it will go false

and i put the trigger in between the output of Subscribe Indutive sensor and function or in between function and led?

remove / replace your function node completely

so between inductive read - and led

Which is what I have been saying all along of course, @smalhao was nearly there but then went off at a tangent again instead of asking if he did not understand the suggestions.

I apologize, in fact I did not understand the suggestions, in particular the way the Trigger applied, the next time I do not understand the suggestions and how to apply them I will ask how the blocks apply, only recently I started programming in Node- Red and I have some difficulty understanding the functions of library blocks because I have little experience of programming with Node-Red.

No problem - we all had to start somewhere/sometime.
The http://noderedguide.com/ and the cookbook - https://cookbook.nodered.org/ are getting better - and are worth looking through when you get some time.

Thanks for the sugestion.

I wanted to ask about the dashboard, is that when it refresh alone the browser, "Connection Lost" appears, and i have the server connected. I would like to ask what could be this error and solutions? I've been looking and no see anything.

Best to start a new thread for that. When you do so give us more information about where the server is running, what you are running the browser on are they both on the same local network and so on.

Ok i iniciate a new thread