I am trying to create a flow that will alert me of a sudden rise in temperature for my temperature sensors around the house.
He is what I have currently and suggestions or advice?
[{"id":"405f829e0a28b82e","type":"api-call-service","z":"892eaa13311e821a","name":"Notify John","server":"c33123cf.c144e","version":5,"debugenabled":false,"domain":"notify","service":"mobile_app_pixel_7_pro","areaId":[],"deviceId":[],"entityId":[],"data":"{ \"message\": payload }","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"queue":"none","x":1230,"y":2400,"wires":[[]]},{"id":"de1b06b9e93f77a9","type":"server-state-changed","z":"892eaa13311e821a","name":"Rapid Temp Increase","server":"c33123cf.c144e","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"temperature","entityidfiltertype":"substring","outputinitially":true,"state_type":"num","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":140,"y":2360,"wires":[["5050be2bd911b8eb"]]},{"id":"53898adb1b4cd249","type":"comment","z":"892eaa13311e821a","name":"Rapid Temp Alert for Fire","info":"","x":150,"y":2280,"wires":[]},{"id":"5050be2bd911b8eb","type":"switch","z":"892eaa13311e821a","name":"Allow Numbers Only","property":"payload","propertyType":"msg","rules":[{"t":"istype","v":"number","vt":"number"}],"checkall":"true","repair":false,"outputs":1,"x":380,"y":2360,"wires":[["5a7e3e9d47f5fe84","5e22ad2c0d3a084e"]]},{"id":"b801bf0cadd6db71","type":"debug","z":"892eaa13311e821a","name":"debug 24","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":940,"y":2460,"wires":[]},{"id":"5a7e3e9d47f5fe84","type":"smooth","z":"892eaa13311e821a","name":"","property":"payload","action":"mean","count":"20","round":"","mult":"multi","reduce":false,"x":580,"y":2320,"wires":[["7c790a11a863ba6b"]]},{"id":"7c790a11a863ba6b","type":"function","z":"892eaa13311e821a","name":"function 3","func":"var t = msg.topic\nmsg.topic = msg.topic.replace(/[^a-zA-Z0-9]/g, \" \")\nmsg.topic = msg.topic.replace(/(^\\w|\\s\\w)/g, m => m.toUpperCase())\nflow.set(t, msg.payload.toFixed(0))\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":880,"y":2320,"wires":[[]]},{"id":"5e22ad2c0d3a084e","type":"function","z":"892eaa13311e821a","name":"function 4","func":"var t = msg.topic // set topic variable\nvar avetemp = parseFloat(flow.get(t))// retrieve the value of the flow variable based on topic\nvar possibleTexts = [\"Bedroom\", \"Laundry\", \"Utility\", \"Garage\", \"Office\", \"Family\", \"Hallway\", \"Door\", \"Bathroom\", \"Kitchen\"]; // array of strings to check for in msg.topic\nvar delta = 10 // Different in Temp \nvar deltatemp = Math.round(avetemp+delta) // Calc Delta Temp\nvar curtemp = parseFloat(msg.payload.toFixed(0)) // Get Current Temp from Payload\nvar alert = \"Temperature High\" // Set Alert Text\nmsg.topic = msg.topic.replace(/[^a-zA-Z0-9]/g, \" \") // Change msg.topic replace non alphanumeric with \" \"\nmsg.topic = msg.topic.replace(/(^\\w|\\s\\w)/g, m => m.toUpperCase()) // Change msg.topic to First Letter Upper Case\n\n\n\n// Check if msg topic includes allowed areas and if current temp exceeds average temp + delta\nif (possibleTexts.some(topic => msg.topic.includes(topic)) && (curtemp > avetemp + delta)) {\n msg = { topic: msg.topic, payload: \"The \" + msg.topic + \" \" + alert + \" \" + curtemp, avetemp:avetemp, currenttemp: curtemp, deltatemp: deltatemp };\n node.status({\n text: msg.topic + \", \" + msg.payload + \" Average Temp: \" + avetemp + ' ' + \"Current Temp: \" + curtemp\n });\n\n return msg\n}\nelse\n\n node.status({\n text: msg.topic + \" Normal\"\n });\n\nflow.set(\"status\", msg)\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":2400,"wires":[["b801bf0cadd6db71","405f829e0a28b82e"]]},{"id":"9ad1cd94e76fe6c5","type":"comment","z":"892eaa13311e821a","name":"Averaging Mean Temps by Topic","info":"","x":590,"y":2260,"wires":[]},{"id":"c7fc45f4e2dbe4d8","type":"comment","z":"892eaa13311e821a","name":"Set Flow Variable Average Temp by Topic","info":"","x":920,"y":2260,"wires":[]},{"id":"695b806a96e554a9","type":"comment","z":"892eaa13311e821a","name":"Check if Current Temp rose high then 10 degrees over average","info":"","x":610,"y":2460,"wires":[]},{"id":"c33123cf.c144e","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]