Not sure if anyone is using Node-Red for Frigate/MQTT automation, but I’m having an issue with parsing out messages based on the top score of Frigate Data. See this section of Frigate’s Documentation.
What I want to do is similar to the above documentation, but in Node-Red. Right now Frigate triggers the flow from MQTT events, the JSON node parses and converts the data from string to objects, and then the change node separates all the messages. Without the following function node, it works perfectly. I get notifications and all is well.
But now I’d like to limit notifications based on the score of the data. I’ve set the change node to set msg.score
to the value of payload.after.top_score
. I’ve tried out a few function nodes to basically only return the message if the score is above a certain threshold, but nothing has worked so far. This is what the function node currently has:
if (msg.score > 0.8) {
return msg;
And here is my node-red flow if you want to test it out:
[{"id":"01af693ee023282e","type":"tab","label":"Test","disabled":false,"info":"","env":[]},{"id":"612da2b7db5b290f","type":"change","z":"01af693ee023282e","name":"Extract All Data + Snapshot","rules":[{"t":"set","p":"eventid","pt":"msg","to":"payload.after.id","tot":"jsonata"},{"t":"set","p":"camera","pt":"msg","to":"payload.after.camera","tot":"jsonata"},{"t":"set","p":"area","pt":"msg","to":"payload.after.entered_zones","tot":"jsonata"},{"t":"set","p":"object","pt":"msg","to":"payload.after.label","tot":"jsonata"},{"t":"set","p":"image","pt":"msg","to":"\"http://ip-address:port/api/events/\" & msg.eventid & \"/snapshot.jpg\"\t","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"\"String to be sent to phones\"","tot":"jsonata"},{"t":"set","p":"score","pt":"msg","to":"payload.after.top_score","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":495,"y":100,"wires":[["3ab601c6ed7f1234"]]},{"id":"c42d11c52d0ab405","type":"json","z":"01af693ee023282e","name":"","property":"payload","action":"","pretty":false,"x":250,"y":100,"wires":[["612da2b7db5b290f"]]},{"id":"00d8fd31b41c181d","type":"pushover api","z":"01af693ee023282e","keys":"","title":"Motion","name":"Notification","x":495,"y":180,"wires":[]},{"id":"3cd236b1cc275232","type":"mqtt in","z":"01af693ee023282e","name":"Frigate/Events","topic":"frigate/events","qos":"0","datatype":"auto","broker":"","nl":false,"rap":true,"rh":0,"inputs":0,"x":75,"y":100,"wires":[["c42d11c52d0ab405"]]},{"id":"bb051b2b6687aa4a","type":"delay","z":"01af693ee023282e","name":"1 msg/minute","pauseType":"timed","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":300,"y":180,"wires":[["00d8fd31b41c181d"]]},{"id":"3ab601c6ed7f1234","type":"function","z":"01af693ee023282e","name":"","func":"if (msg.score > 0.8) {\n return msg;\n} else {\n\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":115,"y":180,"wires":[["bb051b2b6687aa4a"]]}]
Any suggestions are greatly appreciated!