das "Problem" könnte sein, dass der WR sehr oft zwischen be- und entladen wechselt...häufig, innerhalb das Intevalls für die Mittelwertbildung.
Code: Alles auswählen
[{"id":"e348726b.2a4ec","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"48c3e30b.0b676c","type":"inject","z":"e348726b.2a4ec","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"5","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":280,"wires":[["489adf85.c5485"]]},{"id":"489adf85.c5485","type":"random","z":"e348726b.2a4ec","name":"","low":"-2500","high":"2500","inte":"false","property":"payload","x":300,"y":280,"wires":[["92e8a1ef.c0319"]]},{"id":"92e8a1ef.c0319","type":"change","z":"e348726b.2a4ec","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"PAC3","tot":"msg"},{"t":"move","p":"PAC3","pt":"msg","to":"payload.PAC3","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"PAC3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":280,"wires":[["b6efc276.3b37"]]},{"id":"b6efc276.3b37","type":"switch","z":"e348726b.2a4ec","name":"","property":"payload.PAC3","propertyType":"msg","rules":[{"t":"gte","v":"0","vt":"num"},{"t":"lt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":670,"y":280,"wires":[["4d18ea91.fe6d24"],["fbb45a39.7ca4d8"]]},{"id":"4d18ea91.fe6d24","type":"function","z":"e348726b.2a4ec","name":"Entladen","func":"msg.payload = msg.payload.PAC3;\nmsg.topic = \"Entladen\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":800,"y":260,"wires":[["b028ac79.76d8a"]]},{"id":"fbb45a39.7ca4d8","type":"function","z":"e348726b.2a4ec","name":"Beladen","func":"msg.payload = (msg.payload.PAC3 * -1);\nmsg.topic = \"Beladen\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":800,"y":300,"wires":[["b028ac79.76d8a"]]},{"id":"b028ac79.76d8a","type":"calculate","z":"e348726b.2a4ec","name":"Durchschnitt pro Minute","pauseType":"timed","calculation":"average","timeout":"10","timeoutUnits":"seconds","rate":"10","x":1010,"y":280,"wires":[["f01d2ea8.e59cb"]]},{"id":"f01d2ea8.e59cb","type":"function","z":"e348726b.2a4ec","name":"runden","func":"var temp = msg.payload\nmsg.payload = parseFloat(temp.toFixed(0));\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1200,"y":280,"wires":[["e2b13662.528b18"]]},{"id":"e2b13662.528b18","type":"join","z":"e348726b.2a4ec","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"1","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1190,"y":220,"wires":[["6d1bb8c1.0a8278"]]},{"id":"6d1bb8c1.0a8278","type":"debug","z":"e348726b.2a4ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1190,"y":160,"wires":[]}]
Edit: wenn Du es so machst, bekommst Du die Mittelwerte für be- und entladen getrennt.
Code: Alles auswählen
[{"id":"b028ac79.76d8a","type":"calculate","z":"e348726b.2a4ec","name":"Durchschnitt pro Minute","pauseType":"timed","calculation":"average","timeout":"10","timeoutUnits":"seconds","rate":"10","x":1010,"y":220,"wires":[["f01d2ea8.e59cb"]]},{"id":"f01d2ea8.e59cb","type":"function","z":"e348726b.2a4ec","name":"runden","func":"var temp = msg.payload\nmsg.payload = parseFloat(temp.toFixed(0));\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1200,"y":220,"wires":[["e2b13662.528b18"]]},{"id":"e2b13662.528b18","type":"join","z":"e348726b.2a4ec","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"1","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1190,"y":160,"wires":[["6d1bb8c1.0a8278"]]},{"id":"6d1bb8c1.0a8278","type":"debug","z":"e348726b.2a4ec","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1190,"y":100,"wires":[]}]