Hi,
Im trying to calculate an average amount of counts each minute that the machine is on. I got the total amount of counts and the total time the machine is on. Now i tried to calculate the average of those to with a function deviding both payloads but this didn't work.
[{"id":"436ccf76.76ba9","type":"ui_text","z":"1f216cc0.281a93","group":"ef52ec43.10754","order":20,"width":"6","height":"1","name":"","label":"Aantal producten:","format":"{{msg.payload}}","layout":"row-spread","x":890,"y":1180,"wires":[]},{"id":"5724ec23.7bf4e4","type":"ui_text","z":"1f216cc0.281a93","group":"ef52ec43.10754","order":6,"width":"4","height":"2","name":"","label":"Aantal slagen","format":"{{msg.payload}}","layout":"row-spread","x":880,"y":1140,"wires":[]},{"id":"addd1c61.c2031","type":"debug","z":"1f216cc0.281a93","name":"Count","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":850,"y":1100,"wires":[]},{"id":"2fb3f952.f74bd6","type":"debug","z":"1f216cc0.281a93","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":850,"y":1220,"wires":[]},{"id":"6f27a22.1211f5c","type":"counter","z":"1f216cc0.281a93","name":"","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":2,"x":660,"y":1180,"wires":[["5724ec23.7bf4e4","addd1c61.c2031","436ccf76.76ba9"],["2fb3f952.f74bd6"]]},{"id":"c82113ff.98093","type":"debug","z":"1f216cc0.281a93","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":230,"y":1220,"wires":[]},{"id":"2e0cb0c6.2888a","type":"mqtt in","z":"1f216cc0.281a93","name":"","topic":"pers77_slag","qos":"2","broker":"d0e4f151.5ec18","x":70,"y":1180,"wires":[["6f27a22.1211f5c","c82113ff.98093"]]},{"id":"7d41b144.805ae","type":"inject","z":"1f216cc0.281a93","name":"","topic":"","payload":"","payloadType":"date","repeat":"60","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":1940,"wires":[["ec2b5a1.7dc6da8"]]},{"id":"ec2b5a1.7dc6da8","type":"function","z":"1f216cc0.281a93","name":"Select statement","func":"msg.topic = \"select SUM(`DATA_WAARDE`/1000/60) AS minuutaan FROM `IOT_DATA` WHERE (`DATA_SOORT`= 'AAN') AND (`DATA_TIJD` >= CURDATE())\";\nreturn msg;","outputs":1,"noerr":0,"x":310,"y":1940,"wires":[["dedb1be.784fde8"]]},{"id":"dedb1be.784fde8","type":"mysql","z":"1f216cc0.281a93","mydb":"23c1ad96.82d712","name":"","x":530,"y":1940,"wires":[["a117dd0.dafa62","7b757624.af06a8"]]},{"id":"7b757624.af06a8","type":"change","z":"1f216cc0.281a93","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0].minuutaan","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":1940,"wires":[["e247461.f78cab8"]]},{"id":"e247461.f78cab8","type":"ui_text","z":"1f216cc0.281a93","group":"ef52ec43.10754","order":12,"width":"6","height":"2","name":"","label":"Minuten aan:","format":"{{msg.payload}}","layout":"row-spread","x":950,"y":1940,"wires":[]},{"id":"a117dd0.dafa62","type":"debug","z":"1f216cc0.281a93","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":950,"y":1980,"wires":[]},{"id":"ef52ec43.10754","type":"ui_group","z":"","name":"Pers 77","tab":"6b96da3f.ce1c04","order":1,"disp":true,"width":"24","collapse":false},{"id":"d0e4f151.5ec18","type":"mqtt-broker","z":"","name":"MQTT_Broker","broker":"192.168.16.76","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"23c1ad96.82d712","type":"MySQLdatabase","z":"","host":"127.0.0.1","port":"3306","db":"VEKO_IOT","tz":""},{"id":"6b96da3f.ce1c04","type":"ui_tab","z":"","name":"Machine data","icon":"dashboard","order":1,"disabled":false,"hidden":false}]
Example: (text output) Aantal slagen text/ (text output) Minuten aan:
I also tried it with cont- average node but this didn't work aswell.
Any idea/ tips how i can do this?