I’m looking to minimize what is done “on hub” and move most “processing” to my NR computer. To that end I want to remove “Average All” (fine HE App, never had any trouble), and replace it with a couple NR sequences.
This took me longer than expected, and there is probably an easier/better way to do it so I want to post what I did and get some feedback. Here is what I came up with so far. I’d like to be able to limit the amount of digits to one decimal place, but I have focused on that yet probably a function node (which I’m not great at).
Big Kudos and Thanks to @LosinIt for providing and troubleshooting the function node, and greatly improving this sequence.
The two inject nodes get the data set correctly, after that the average will be updated every time any device reports.
Sequence
[{"id":"a29df9cd.d63af8","type":"hubitat device","z":"7442e075.dd28a","name":"Package Box Motion","server":"c0da6dea.8576a","deviceId":"2471","attribute":"temperature","sendEvent":true,"x":400,"y":740,"wires":[["ce533421.0170e8"]]},{"id":"3f19f6ca.bc61aa","type":"hubitat device","z":"7442e075.dd28a","name":"Package Box Button","server":"c0da6dea.8576a","deviceId":"2535","attribute":"temperature","sendEvent":true,"x":400,"y":680,"wires":[["ce533421.0170e8"]]},{"id":"ef121ce5.3da83","type":"hubitat device","z":"7442e075.dd28a","name":"Porch - Multi Sensor ","server":"b1088aaa.95e9e8","deviceId":"78","attribute":"temperature","sendEvent":true,"x":400,"y":800,"wires":[["ce533421.0170e8"]]},{"id":"3126a5c3.2928fa","type":"hubitat device","z":"7442e075.dd28a","name":"VD - NR - Average Outside Temp","server":"e03140c5.bed32","deviceId":"1480","attribute":"temperature","sendEvent":false,"x":700,"y":660,"wires":[[]]},{"id":"ce533421.0170e8","type":"function","z":"7442e075.dd28a","name":"Average","func":"if (msg.payload.deviceId == \"78\") context.set('78',msg.payload.value);\nif (msg.payload.deviceId == \"2535\") context.set('2535',msg.payload.value);\nif (msg.payload.deviceId == \"2471\") context.set('2471',msg.payload.value);\nmsg.payload.average = ((context.get('78') + context.get('2535') + context.get('2471')) / 3 );\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":620,"y":720,"wires":[["bf07739a.e1b43"]]},{"id":"16c597d4.4a2dd8","type":"hubitat command","z":"7442e075.dd28a","name":"VD - NR - Average Outside Temp","server":"e03140c5.bed32","deviceId":"1480","command":"setTemperature","commandArgs":"","x":760,"y":800,"wires":[[]]},{"id":"ab09b1.7ae1065","type":"change","z":"7442e075.dd28a","name":"limit decimal to 1 digit","rules":[{"t":"set","p":"payload","pt":"msg","to":"$round(payload, 1)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":760,"wires":[["72fc1ec9.b21b1"]]},{"id":"72fc1ec9.b21b1","type":"change","z":"7442e075.dd28a","name":"","rules":[{"t":"set","p":"arguments","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":870,"y":760,"wires":[["16c597d4.4a2dd8"]]},{"id":"bf07739a.e1b43","type":"change","z":"7442e075.dd28a","name":"set payload","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.average","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":720,"wires":[["ab09b1.7ae1065"]]},{"id":"2843d3cc.496cbc","type":"inject","z":"7442e075.dd28a","name":"set temps ","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":200,"y":700,"wires":[["a29df9cd.d63af8","3f19f6ca.bc61aa","ef121ce5.3da83"]]},{"id":"ae9aaa74.0de868","type":"inject","z":"7442e075.dd28a","name":"set Average Temp","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"0.5","topic":"","x":170,"y":760,"wires":[["a29df9cd.d63af8","ef121ce5.3da83"]]},{"id":"c0da6dea.8576a","type":"hubitat config","name":"ZigBee Hub","usetls":false,"host":"10.13.9.11","port":"80","appId":"2532","nodeRedServer":"http://10.13.9.28:1880","webhookPath":"/hubitat/webhook__","autoRefresh":true,"useWebsocket":false},{"id":"b1088aaa.95e9e8","type":"hubitat config","name":"Z-WaveHub","usetls":false,"host":"10.13.9.26","port":"80","appId":"5","nodeRedServer":"http://10.13.9.28:1880","webhookPath":"/hubitat/webhook_","autoRefresh":true,"useWebsocket":false},{"id":"e03140c5.bed32","type":"hubitat config","name":"Apps Hub","usetls":false,"host":"10.13.9.12","port":"80","appId":"899","nodeRedServer":"http://10.13.9.28:1880","webhookPath":"/hubitat/webhook___","autoRefresh":true,"useWebsocket":false}]
Important Update: The function node uses msg.payload.deviceId get and store data for the averaging. This data is specific to every device (mine will not work for yours). To use this method you will need to get your deviceId using a debug node (complete msg) and update the function node accordingly.
EDIT: Added a node to limit decimal reading to 1 digit (my preference for dashboards). It is not essential, and can be removed, or adjusted.