Alerts/Notification

Hi everyone! I've some difficult to use "notification" on node-red.


When i use this method, i get nonstop notifications and as I use two mqtt's, the notifications end up on top of each other.
In this function (next photo), presents what the notification should warn:
image
p.s.: hum = humidity
Does anyone know how to fix this error?

Try using the filter/rbe node. It can filter out messages that have not changed.

Can u give me an example?

should be no need place filter/rbe node after function and before notification node.

I would of give an example but you did not supply a flow json of your flow, so i could attach one and show you, unless you want me to waste time constructing a flow that you should of supplied if you wanted an example in return.

I tried this method before asking for example and got no notification... :frowning:

Again you supply no info just an image which i can do nothing with.

how is filter node set? what is the output of the two function nodes? you will probably require one filter per function node, depending on their output.

Sorry... I explain!
In mqtt "temperatura" and "humidade", i use a broker where i receive values about the temperature and the humidity, basically i create a code on arduino that catch that values.
image
Result:
image
In "Grafico" and "Medidor" node, only graphically displays the values ​​it receives from mqtt, for example:
image
And in function, I did in this way:
image
And the final product, It's this one:


I hope you understand, thank you very much :slight_smile:

payload from mqtt is a string needs to be a number, as you are using < and >. So i fail to see you get the output you want from the function node.

Please export your flow, highlight the nodes to export, press control e, press copy and paste here using </> button in post editor.

I will try change payload from mqtt into a number!

[{"id":"586b0b1cae11d462","type":"tab","label":"Flow 10","disabled":false,"info":"","env":[]},{"id":"067ae491e9e74a98","type":"mqtt in","z":"586b0b1cae11d462","name":"Temperatura","topic":"IPB/IoT/Farm/AirQuality/Temperatura","qos":"2","datatype":"auto","broker":"0cf85d5ab020f8be","nl":false,"rap":true,"rh":0,"inputs":0,"x":410,"y":220,"wires":[["e47c57ab488506a2","dd58c64aa7242471","0457cb2fabce1801","6a978807825d513c"]]},{"id":"dd58c64aa7242471","type":"ui_gauge","z":"586b0b1cae11d462","name":"Medidor","group":"aedd66b9cb7dc5a6","order":1,"width":0,"height":0,"gtype":"gage","title":"Temperatura","label":"ºC","format":"{{value}}","min":"-10","max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"13","seg2":"20","className":"","x":720,"y":280,"wires":[]},{"id":"e47c57ab488506a2","type":"debug","z":"586b0b1cae11d462","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":160,"wires":[]},{"id":"0457cb2fabce1801","type":"ui_chart","z":"586b0b1cae11d462","name":"Grafico","group":"408f2e307a2c3dfb","order":1,"width":0,"height":0,"label":"Temperatura","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":720,"y":240,"wires":[[]]},{"id":"6a978807825d513c","type":"function","z":"586b0b1cae11d462","name":"","func":"let temp = msg.payload\n\nif (temp>=10 && temp<=26) {\n    msg.payload = \"O alimento pode ser transportado\"\n} else {\n    msg.payload = \"O alimento não pode ser transportado\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":200,"wires":[["7e6f1685b5aadcb5"]]},{"id":"77d730aa29c52479","type":"mqtt in","z":"586b0b1cae11d462","name":"Humidade","topic":"IPB/IoT/Farm/AirQuality/Humidade","qos":"2","datatype":"auto","broker":"0cf85d5ab020f8be","nl":false,"rap":true,"rh":0,"inputs":0,"x":400,"y":420,"wires":[["e82a0c767befca6b","ce8bc268a9b7dd2a","dd8f0cdbc52558e6","041b74cd768aaca6"]]},{"id":"e82a0c767befca6b","type":"ui_gauge","z":"586b0b1cae11d462","name":"Medidor","group":"aedd66b9cb7dc5a6","order":2,"width":0,"height":0,"gtype":"wave","title":"Humidade","label":"%","format":"{{value}}","min":0,"max":"100","colors":["#e543b2","#ffffff","#ffffff"],"seg1":"","seg2":"","className":"","x":720,"y":480,"wires":[]},{"id":"ce8bc268a9b7dd2a","type":"ui_chart","z":"586b0b1cae11d462","name":"Gráfico","group":"408f2e307a2c3dfb","order":2,"width":0,"height":0,"label":"Humidade","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":720,"y":440,"wires":[[]]},{"id":"dd8f0cdbc52558e6","type":"debug","z":"586b0b1cae11d462","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":360,"wires":[]},{"id":"041b74cd768aaca6","type":"function","z":"586b0b1cae11d462","name":"","func":"let hum = msg.payload\n\nif (hum>=40 && hum<=45) {\n    msg.payload = \"Food can be transported\"\n} else {\n    msg.payload = \"Food can't be transported\"\n}\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":400,"wires":[["7e6f1685b5aadcb5"]]},{"id":"7e6f1685b5aadcb5","type":"ui_toast","z":"586b0b1cae11d462","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"className":"","topic":"","name":"","x":1220,"y":320,"wires":[]},{"id":"0cf85d5ab020f8be","type":"mqtt-broker","name":"","broker":"broker.mqtt-dashboard.com","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"aedd66b9cb7dc5a6","type":"ui_group","name":"Medidor","tab":"3ca0c34b.d48204","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"408f2e307a2c3dfb","type":"ui_group","name":"Gráfico","tab":"3ca0c34b.d48204","order":2,"disp":true,"width":"6","collapse":false,"className":""},{"id":"3ca0c34b.d48204","type":"ui_tab","name":"Produção Primária","icon":"dashboard","disabled":false,"hidden":false}]

This works for me, i added a function to convert string to number. You can remove function if you can make the sensor send a number to mqtt. The notification only sends if the payload from the second function changes.

[{"id":"8c395d95.96a018","type":"inject","z":"586b0b1cae11d462","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"IPB/IoT/Farm/AirQuality/Temperatura","payload":"23%","payloadType":"str","x":280,"y":120,"wires":[["9c58799c.035f1"]]},{"id":"9c58799c.035f1","type":"function","z":"586b0b1cae11d462","name":"","func":"msg.payload=parseFloat(msg.payload)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":220,"wires":[["6a978807825d513c","0457cb2fabce1801","dd58c64aa7242471"]]},{"id":"067ae491e9e74a98","type":"mqtt in","z":"586b0b1cae11d462","name":"Temperatura","topic":"IPB/IoT/Farm/AirQuality/Temperatura","qos":"2","datatype":"auto","broker":"0cf85d5ab020f8be","nl":false,"rap":true,"rh":0,"x":280,"y":240,"wires":[["9c58799c.035f1","e47c57ab488506a2"]]},{"id":"cee724b.4e33b58","type":"inject","z":"586b0b1cae11d462","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"IPB/IoT/Farm/AirQuality/Temperatura","payload":"27%","payloadType":"str","x":270,"y":160,"wires":[["9c58799c.035f1"]]},{"id":"6a978807825d513c","type":"function","z":"586b0b1cae11d462","name":"","func":"let temp = msg.payload\n\nif (temp>=10 && temp<=26) {\n    msg.payload = \"O alimento pode ser transportado\"\n} else {\n    msg.payload = \"O alimento não pode ser transportado\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":200,"wires":[["1f8d9f58.8fbae1"]]},{"id":"0457cb2fabce1801","type":"ui_chart","z":"586b0b1cae11d462","name":"Grafico","group":"408f2e307a2c3dfb","order":1,"width":0,"height":0,"label":"Temperatura","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"86400","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"className":"","x":720,"y":240,"wires":[[]]},{"id":"dd58c64aa7242471","type":"ui_gauge","z":"586b0b1cae11d462","name":"Medidor","group":"aedd66b9cb7dc5a6","order":1,"width":0,"height":0,"gtype":"gage","title":"Temperatura","label":"ºC","format":"{{value}}","min":"-10","max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"13","seg2":"20","className":"","x":720,"y":280,"wires":[]},{"id":"e47c57ab488506a2","type":"debug","z":"586b0b1cae11d462","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":970,"y":120,"wires":[]},{"id":"1f8d9f58.8fbae1","type":"rbe","z":"586b0b1cae11d462","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":860,"y":220,"wires":[["7e6f1685b5aadcb5","e47c57ab488506a2"]]},{"id":"7e6f1685b5aadcb5","type":"ui_toast","z":"586b0b1cae11d462","position":"top right","displayTime":"3","highlight":"","sendall":true,"outputs":0,"ok":"OK","cancel":"","raw":false,"className":"","topic":"","name":"","x":1040,"y":220,"wires":[]},{"id":"0cf85d5ab020f8be","type":"mqtt-broker","name":"","broker":"broker.mqtt-dashboard.com","port":"1883","clientid":"","usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"408f2e307a2c3dfb","type":"ui_group","name":"Gráfico","tab":"3ca0c34b.d48204","order":2,"disp":true,"width":"6","collapse":false,"className":""},{"id":"aedd66b9cb7dc5a6","type":"ui_group","name":"Medidor","tab":"3ca0c34b.d48204","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"3ca0c34b.d48204","type":"ui_tab","name":"Produção Primária","icon":"dashboard","disabled":false,"hidden":false}]

i only did temp, but you can do similar with hum.

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