Front montant du signal

Bonjour ,
est il possible de faire un front montant du signal ?
c'est il lors de dépassement d'un seuil il envoi une alerte .

Hello ,
is it possible to make a rising edge of the signal?
it is when a threshold is exceeded, it sends an alert.

Yes, is possible in many ways. Here is one simple

image

[{"id":"70b9a257.cd03cc","type":"inject","z":"24335ed1.a655e2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":240,"y":130,"wires":[["fe81dad9.1f26d8"]]},{"id":"68af2b83.289984","type":"debug","z":"24335ed1.a655e2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":130,"wires":[]},{"id":"fe81dad9.1f26d8","type":"switch","z":"24335ed1.a655e2","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"2","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":420,"y":130,"wires":[["68af2b83.289984"]]},{"id":"709f22c4.b3955c","type":"inject","z":"24335ed1.a655e2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"2","payloadType":"num","x":240,"y":190,"wires":[["fe81dad9.1f26d8"]]},{"id":"2d29490f.03f7c6","type":"inject","z":"24335ed1.a655e2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"3","payloadType":"num","x":240,"y":250,"wires":[["fe81dad9.1f26d8"]]},{"id":"6a93206e.e037c","type":"inject","z":"24335ed1.a655e2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"4","payloadType":"num","x":240,"y":310,"wires":[["fe81dad9.1f26d8"]]}]

thanks for reply
but in this example , the system send notifications (infinity )
but I want send one nofication when a threshold is exceeded

You get what you specify

And I guess you would like the system to able to send you a notification again sometime...based on what conditions & rules?

You see, you have to make a better & more complete specification how you want the system to work

But I guess you now have a starting point, figure out how to inject the real signals into the flow, only send one and then...design rules...allow new notification to be sent

My concern is to send a notification (one nofication via mail) each time the threshold is exceeded.

Is this a perfect signal with no noise on it? If it is something like a temperature measurement what do you want to happen if it goes over the threshold then the next sample is on or just below the threshold and the next is above it again?

I want a notification user via mail when temperature ( for example ) exceed 40
one mail send when exceed value

You haven't answered the question. What happens if it goes to 40.1 then the next time you measure it it is 40 and the next 40.1 again? Do you want two messages? If you only want one then what is the criterion to know when to send another one, or do you mean you only ever want one in the life of the universe?

send mail on fisrt exceed only
this example ( value , action )
value =40
nothing
value= 40.1
send mail
value=40.1
nothing
value=42
nothing
value =40
nothing
value 40,1
send mail

[{"id":"70b9a257.cd03cc","type":"inject","z":"24335ed1.a655e2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"40","payloadType":"num","x":240,"y":130,"wires":[["fe81dad9.1f26d8"]]},{"id":"68af2b83.289984","type":"debug","z":"24335ed1.a655e2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":830,"y":190,"wires":[]},{"id":"fe81dad9.1f26d8","type":"switch","z":"24335ed1.a655e2","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"40","vt":"num"},{"t":"lte","v":"40","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":420,"y":130,"wires":[["9d9828b8.6c4858"],["49dedae8.20d2e4"]]},{"id":"709f22c4.b3955c","type":"inject","z":"24335ed1.a655e2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"40.1","payloadType":"num","x":240,"y":190,"wires":[["fe81dad9.1f26d8"]]},{"id":"2d29490f.03f7c6","type":"inject","z":"24335ed1.a655e2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"42","payloadType":"num","x":240,"y":250,"wires":[["fe81dad9.1f26d8"]]},{"id":"942c4ba2.5e5888","type":"change","z":"24335ed1.a655e2","name":"","rules":[{"t":"set","p":"block","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":310,"wires":[[]]},{"id":"49dedae8.20d2e4","type":"change","z":"24335ed1.a655e2","name":"","rules":[{"t":"set","p":"block","pt":"flow","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":370,"wires":[[]]},{"id":"36d07a3c.563b16","type":"delay","z":"24335ed1.a655e2","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":640,"y":250,"wires":[["942c4ba2.5e5888"]]},{"id":"9d9828b8.6c4858","type":"switch","z":"24335ed1.a655e2","name":"","property":"block","propertyType":"flow","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":640,"y":190,"wires":[["36d07a3c.563b16","68af2b83.289984"]]}]
1 Like

Well I just hope that your temperature sensor has zero noise on it.
If that is really what you want then I think I would use a Function node.

image

[{"id":"ab612703.807d98","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"40","payloadType":"num","x":110,"y":3240,"wires":[["aadac376.8cbbd8"]]},{"id":"35946c96.90a294","type":"debug","z":"bdd7be38.d3b55","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":450,"y":3300,"wires":[]},{"id":"96b968e5.d374b8","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"40.1","payloadType":"num","x":110,"y":3300,"wires":[["aadac376.8cbbd8"]]},{"id":"5031f9c4.5f209","type":"inject","z":"bdd7be38.d3b55","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"42","payloadType":"num","x":110,"y":3360,"wires":[["aadac376.8cbbd8"]]},{"id":"aadac376.8cbbd8","type":"function","z":"bdd7be38.d3b55","name":"Test threshold","func":"let previous = context.get(\"previous\") || 0\ncontext.set(\"previous\", msg.payload)\nif (msg.payload > 40  &&  previous <= 40) {\n    msg.payload = \"Threshold exceeded\"\n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":290,"y":3300,"wires":[["35946c96.90a294"]]}]
1 Like

thanks for reply , it is worked

thanks for reply ,worked

When you get round to using it with a real sensor and realise that it doesn't do what you want because the noise in the signal causes multiple notifications you could use one of the hysteresis nodes to achieve what you want. I have used node-red-contrib-ramp-thermostat for similar tasks (you can ignore the ramp bit and use it as a thermostat with hysteresis) then feed that through an RBE node so that you only get a message when it crosses or crosses back, then a Switch node to pass only the crossing message and use that to trigger your notification.

What Colin is trying to say is that when the value, let's say temperature reaches 40.0, it might vary between 39.9 and 40.0 for some time (hysteresis), sending multiple messages. To take hysteresis into account you might want to send the email at 40 and set a flag the temperate has been reached. The flag would be cleared at for example 39.5, to be send again when it reaches 40 again.

Alternatively you could just add a delay node before sending the email, adding an interval to how frequently at most you want to receive the email and skipping intermediate messages.

Personally think a plugin node might be overkill in your case.

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