Database not receive the data when one sensor stops

I set the all columns to VARCHAR (255)

In that case put a Function node after the Join node that checks the values and adds in any missing ones with whatever value you want.

I make this, but the sensor is always ON, how make when the sensor not count meters pass to OFF state?

[{"id":"9c5ae5dc.8b7f08","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"1f6e701c.af967","type":"function","z":"9c5ae5dc.8b7f08","name":"","func":"if (msg.payload[\"n=2;s=SensorIndutivo\"] === msg.payload[\"n=2;s=SensorIndutivo\"]-1){\n    msg.color = \"OFF\";\n\n}\nelse{\n    msg.color = \"ON\";\n}\nreturn msg;","outputs":1,"noerr":0,"x":308,"y":91.00000190734863,"wires":[["d037f44c.7ee6c8"]]},{"id":"d037f44c.7ee6c8","type":"ui_text","z":"9c5ae5dc.8b7f08","group":"3f8269da.fa4936","order":2,"width":0,"height":0,"name":"","label":"Sensor State","format":"{{msg.color}} ","layout":"row-spread","x":644.0000076293945,"y":92.00000095367432,"wires":[]},{"id":"9d8e7de6.bb29d","type":"link in","z":"9c5ae5dc.8b7f08","name":"Sensor Status In Indutive Sensor","links":["9b2b6965.f7a918"],"x":124.30000400543213,"y":89.00000190734863,"wires":[["1f6e701c.af967"]]},{"id":"3f8269da.fa4936","type":"ui_group","z":"","name":"Station1","tab":"d59368e5.9adfe8","disp":true,"width":"6","collapse":false},{"id":"d59368e5.9adfe8","type":"ui_tab","z":"","name":"Monitoring Sensors Dasboard","icon":"dashboard","disabled":false,"hidden":false}]

Can you explain in words what the function is supposed to do? I thought you were wanting to write to the database.

What I want to do is to have an ON and OFF message on the dashboard that indicates that the sensor is active or inactive I want the function to do, but I think I'm not programming the function well

OK, I thought you wanted to get that information into the database. In that case put a debug node showing what is coming in through the link node in the flow.

in the inject or the subscribe?

I put a debug in each one and the result is this:

12/02/2019, 16:20:28[node: Metros](http://10.6.4.101:1880/#)ns=2;s=SensorIndutivo : msg : Object
   { topic: "ns=2;s=SensorIndutivo", payload: 246.61502330679875, _msgid: "a370e17d.7df2b", serverTimestamp: "2019-02-12T16:08:22.474Z", serverPicoseconds: 481300000 … }
 
12/02/2019, 16:20:28[node: 51c28584.261b8c](http://10.6.4.101:1880/#)ns=2;s=SensorIndutivo : msg.payload : number
 0

Has this question got anything to do with the title of this thread? It might be better to start a new thread. You can use a Trigger node configured to send ON each time a value comes in, but if no input occurs for a certain time then it sends OFF.

I tried to use the trigger but it is not using well, maybe it is better to start another topic

The trigger needs to go before the join node, one on each signal you want to check is still coming in.

Can you make a schematic with the connection, now i´m confuse, because yesterday you tells me that:
The trigger needs to go before the join node, one on each signal you want to check is still coming in.

The trigger is in the right place. The join and the trigger must both come from the sensor.

Also can you decide which thread you are using please.

I use this thread. I testing another way for my problem but i still in the same, the way i´m used is this:

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.

Moved to Show if sensor is ative or inactive

1 Like