VAN PI Core System

Hey Arno

Habe das Core halt in den Oberschrank an die seite “Stehend” montiert (Raspi Oben, USB Links) und da macht er das dann aber wenn man es später wählen könnte wäre es super.

Von der Größe passt es nun perfekt in den Schrank und ist so noch etwas besser verbaut als in meiner E-Box.

Ist sicher möglich, das zu drehen.
Das Problem werden bestimmt noch mehr haben.
Must du halt erstmal noch umdenken wo die Keile hinlegst :joy: bis der Wagen fertig ist, gibts bestimmt ne Lösung
Gruß Arno

Hallo Sascha
was du vorab testen könntest, wenn du 2 Range Nodes in den Flow einbaust.


wenn du im unteren Bereich -45 bis 45 eingibst verändert sich nichts,
wenn du da aber 45 bis -45 eingibst, invertierst du die Werte.
Den Modus auf Skalierung.
Gruß
Arno

Gute Morgen Arno

Werde das heute mal nach Feierabend testen und Berichten ob es geklappt hat :+1:t2:

Gruß Sascha

@SaschaKorn
ich hab da mal was vorbereitet

[{"id":"699fc08149c77597","type":"ui_template","z":"3739bebe6c778cd3","d":true,"group":"f89e1392760d829e","name":"IMG NICK","order":1,"width":6,"height":4,"format":"<div style='width:100%; height:100%; display:flex; justify-content:center; align-items:center;'>\n    <div id='image-container' style='position: relative;'>\n        <img id='image-to-rotate' src='http://pekaway.local/images/van_side' style='width:230px; height:173px; transform: rotate({{msg.deg}}deg);' />\n        <div id='line'\n            style='position: absolute; width: 100%; height: 3px; background-color: grey; top: 96%; transform: translateY(-50%); z-index: 0;'>\n        </div>\n    </div>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":2560,"y":360,"wires":[[]]},{"id":"32227694b6da15c7","type":"group","z":"3739bebe6c778cd3","name":"VAN PI Core - MPU6050","style":{"label":true},"nodes":["f50f27a0bc038b47","99c6d65d1486302f","e46980325aa122bc","02a45f9f766e8ed7","dba3eb11dced800d","7689c36c4b4dc602","736e6e74dd4099c1","7625b64c194676df","e1981fc3d5bd5dcd","ea251b4e38d7ad0e","3fbb529e13212092","e661be93174a3c06","d793139abfd73467","b5902b221bf2671b","de3b646ac20702e7","9405f0312e7b530c","295e95de4318d1b8","8d6625f941a1734f","ef2c0086391012ae","2f39cbd1b882b3e5","e3cd1d26208cb692","2c56fd6e65d34c56","28d29a321847e02c","e88f4ba0f4d1d09e","0123f1a21f90df33","526759393f6f5f68","339615045b1bfa7f","c645aa409e021565","a25b0d3ed530fb58","c72e374c3e18cf30","6619f21f66ccc3a3","be30fa7396b2172a","4845fbb606ccbbb6","91b91b7cc974da25","1f9e364f2c365707","7b0d6cce040ff728","e7b8b47f1654f01f","eb0e4d09392a8a43","4f3b8fba418c2d7d","5fc2a31f4d9810ef","eb2be90032ddbb37","b834a73edcc9df3a","4c75eab53d356616","8d848d0e113ab89e","a674e27aa3a674b7","8efd01a8cc1df5c1","c237ca3c3d06f36d","9c8fa4b038815cd0","a32a3d5947c57eb9","024bfacc0d8c1801","114d553e0f28d537","315d8bb09e74599b","dfdafd0c8a8edc14","e89bd5a498300906","d10b39878b9bc1a9","72a4fa5d117124fc","eaf79c9ddd746cfb","1f78a9c366e84c7e","e66325ce5055968a","bcfa893e5261b31f","47d8c28be53b7704","9087ebaa39cbbbfa","bfeb39c8cda7b75d","e84dac9590c81505","e255aaa0c9933f07","27230b28b20256a9","85a6d423449be08c","882ae1f332f62fea","763f8575bd4912d8","0741ee34e3059137","894fb0e03e254cf3","6f5f2789ea655fd0","bb2ebb27405d5636","a69003b2fc0e3014","575754770ef50592","dac68d377d2889aa","5cf9a486546453bc","2c23b6bd703456ef","b47b6300f24829e1","bd292e4c7dd2ee73","1abd42eb43b86290","e4bad569302ab4f6"],"x":14,"y":19,"w":2832,"h":582},{"id":"f50f27a0bc038b47","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"add Offset","func":"// Erhalten der Eingangsdaten\nvar eingangsdaten = msg.payload;\n\n// Kalibrierungswert aus der globalen Variable verwenden\nvar kalibrierungswert = global.get(\"calibration_value_x\") || 0; // Standardwert ist 0, falls nicht gesetzt\n\n// Anpassen der Daten um den Kalibrierungswert\nvar datenMitKalibrierung = eingangsdaten - kalibrierungswert;\n\n// Auf eine Dezimalstelle runden\nvar gerundeteDaten = datenMitKalibrierung.toFixed(1); // 1 steht für eine Dezimalstelle\n\n// Wenn der gerundete Wert 0 ist, auf 0.0 ändern\nif (Number(gerundeteDaten) === 0) {\n    gerundeteDaten = \"0.0\";\n}\n\n// Weiterleiten der modifizierten und gerundeten Daten\nmsg.payload = parseFloat(gerundeteDaten); // Als Zahl statt String zurückgeben\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1310,"y":240,"wires":[["e66325ce5055968a","894fb0e03e254cf3"]]},{"id":"99c6d65d1486302f","type":"smooth","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","property":"payload","action":"mean","count":"3","round":"1","mult":"single","reduce":true,"x":1160,"y":240,"wires":[["f50f27a0bc038b47"]]},{"id":"e46980325aa122bc","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"add Offset","func":"// Erhalten der Eingangsdaten\nvar eingangsdaten = msg.payload;\n\n// Kalibrierungswert aus der globalen Variable verwenden\nvar kalibrierungswert = global.get(\"calibration_value_y\") || 0; // Standardwert ist 0, falls nicht gesetzt\n\n// Anpassen der Daten um den Kalibrierungswert\nvar datenMitKalibrierung = eingangsdaten - kalibrierungswert;\n\n// Auf eine Dezimalstelle runden\nvar gerundeteDaten = datenMitKalibrierung.toFixed(1); // 1 steht für eine Dezimalstelle\n\n// Wenn der gerundete Wert 0 ist, auf \"0.0\" ändern\nif (Number(gerundeteDaten) === 0) {\n    gerundeteDaten = \"0.0\";\n}\n\n// Weiterleiten der modifizierten und gerundeten Daten\nmsg.payload = parseFloat(gerundeteDaten); // Als Zahl statt String zurückgeben\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1310,"y":320,"wires":[["bcfa893e5261b31f","bb2ebb27405d5636"]]},{"id":"02a45f9f766e8ed7","type":"smooth","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","property":"payload","action":"mean","count":"3","round":"1","mult":"single","reduce":true,"x":1160,"y":320,"wires":[["e46980325aa122bc"]]},{"id":"dba3eb11dced800d","type":"ui_text","z":"3739bebe6c778cd3","g":"32227694b6da15c7","group":"f89e1392760d829e","order":2,"width":6,"height":1,"name":"Winkel Nick","label":"","format":"{{msg.value}}","layout":"row-center","className":"mpu6050","x":2350,"y":300,"wires":[]},{"id":"7689c36c4b4dc602","type":"ui_button","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"Start Calibration","group":"f89e1392760d829e","order":5,"width":6,"height":1,"passthru":true,"label":"Calibrate position sensor","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"start_calibration","payloadType":"str","topic":"start_calibration","topicType":"str","x":240,"y":140,"wires":[["736e6e74dd4099c1","7625b64c194676df","ea251b4e38d7ad0e","295e95de4318d1b8","8d6625f941a1734f"]]},{"id":"736e6e74dd4099c1","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"Kalibrierungsfunktion X","func":"// Variablen für die Kalibrierung\nlet calibrationDatax = context.get(\"calibrationData_x\") || [];\nlet timer = context.get(\"timer\") || null;\n\n// Startet die Kalibrierung bei einer Nachricht vom Button\nif (msg.topic === \"start_calibration\" && !timer) {\n    calibrationDatax = [];\n    context.set(\"calibrationData_x\", calibrationDatax);\n\n    timer = setTimeout(() => {\n        let sum = calibrationDatax.reduce((a, b) => a + b, 0);\n        let avg = calibrationDatax.length > 0 ? sum / calibrationDatax.length : 0;\n        global.set(\"calibration_value_x\", avg); // Speichert das Ergebnis in der globalen Variable\n        context.set(\"timer\", null);\n        node.send({ payload: avg });\n    }, 5000); // Kalibrierungszeitraum: 5 Sekunden\n\n    context.set(\"timer\", timer);\n    return;\n}\n\n// Sammelt Daten, wenn eine Nachricht vom Sensor empfangen wird\nif (msg.topic === \"x_angle\"&& timer) {\n    let value = parseFloat(msg.payload);\n    if (!isNaN(value)) {\n        calibrationDatax.push(value);\n        context.set(\"calibrationData_x\", calibrationDatax);\n    }\n}\n\nreturn null; // Sendet keine Nachricht, bis der Timer abläuft","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1210,"y":100,"wires":[[]]},{"id":"7625b64c194676df","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"Kalibrierungsfunktion Y","func":"// Variablen für die Kalibrierung\nlet calibrationData = context.get(\"calibrationData_y\") || [];\nlet timer = context.get(\"timer\") || null;\n\n// Startet die Kalibrierung bei einer Nachricht vom Button\nif (msg.topic === \"start_calibration\" && !timer) {\n    calibrationData = [];\n    context.set(\"calibrationData_y\", calibrationData);\n\n    timer = setTimeout(() => {\n        let sum = calibrationData.reduce((a, b) => a + b, 0);\n        let avg = calibrationData.length > 0 ? sum / calibrationData.length : 0;\n        global.set(\"calibration_value_y\", avg); // Speichert das Ergebnis in der globalen Variable\n        context.set(\"timer\", null);\n        node.send({ payload: avg });\n    }, 30000); // Kalibrierungszeitraum: 5 Sekunden\n\n    context.set(\"timer\", timer);\n    return;\n}\n\n// Sammelt Daten, wenn eine Nachricht vom Sensor empfangen wird\nif (msg.topic === \"y_angle\" && timer) {\n    let value = parseFloat(msg.payload);\n    if (!isNaN(value)) {\n        calibrationData.push(value);\n        context.set(\"calibrationData_y\", calibrationData);\n    }\n}\n\nreturn null; // Sendet keine Nachricht, bis der Timer abläuft","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1210,"y":140,"wires":[["de3b646ac20702e7"]]},{"id":"e1981fc3d5bd5dcd","type":"ui_toast","z":"3739bebe6c778cd3","g":"32227694b6da15c7","position":"top right","displayTime":"5","highlight":"","sendall":false,"outputs":0,"ok":"OK","cancel":"","raw":false,"className":"","topic":"","name":"","x":690,"y":60,"wires":[]},{"id":"ea251b4e38d7ad0e","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"calibrating...","func":"msg.payload = \"Calibrating position sensor...\"\ndelete msg.topic\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":100,"wires":[["e1981fc3d5bd5dcd"]]},{"id":"3fbb529e13212092","type":"ui_text","z":"3739bebe6c778cd3","g":"32227694b6da15c7","group":"f89e1392760d829e","order":4,"width":6,"height":1,"name":"Winkel ROLL","label":"","format":"{{msg.value}}","layout":"row-center","className":"mpu6050","x":2350,"y":260,"wires":[]},{"id":"e661be93174a3c06","type":"exec","z":"3739bebe6c778cd3","g":"32227694b6da15c7","command":"python3 pekaway/mpu_py/mpuAngle.py","addpay":"payload","append":"","useSpawn":"true","timer":"","winHide":false,"oldrc":false,"name":"mpuAngle.py","x":670,"y":240,"wires":[["d793139abfd73467","72a4fa5d117124fc"],[],[]]},{"id":"d793139abfd73467","type":"json","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","property":"payload","action":"","pretty":false,"x":810,"y":240,"wires":[["b5902b221bf2671b"]]},{"id":"b5902b221bf2671b","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"filter values","func":"let msgX = {}\nlet msgY = {}\nlet msgT = {}\nmsgX.payload = Number(msg.payload.x_angle);\nmsgX.topic = \"x_angle\";\n//node.send([msg, null, null])\nmsgY.payload = Number(msg.payload.y_angle);\nmsgY.topic = \"y_angle\";\n//node.send([null, msg, null])\nmsgT.payload = msg.payload.mpu_temp.toFixed(1);\n//node.send([null, null, msg])\nreturn [msgX, msgY, msgT]","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":950,"y":240,"wires":[["99c6d65d1486302f","736e6e74dd4099c1"],["02a45f9f766e8ed7","7625b64c194676df"],["114d553e0f28d537"]]},{"id":"de3b646ac20702e7","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"kill then => time 2","func":"msg.kill = \"SIGKILL\";\nnode.send(msg);\n\nsetTimeout(function () {\n    delete msg.kill;\n    msg.payload = \"--time 2\";\n    node.send(msg);\n}, 500);  // milliseconds delay","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1430,"y":140,"wires":[["e661be93174a3c06","d10b39878b9bc1a9"]]},{"id":"9405f0312e7b530c","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"time 5","func":"delete msg.kill\nmsg.payload = \"--time 5\"\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1130,"y":480,"wires":[["c72e374c3e18cf30"]]},{"id":"295e95de4318d1b8","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"kill then => time 0.25","func":"msg.kill = \"SIGKILL\";\nnode.send(msg);\n\nsetTimeout(function () {\n    delete msg.kill;\n    msg.payload = \"--time 0.25\";\n    node.send(msg);\n}, 1000);  // milliseconds delay","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":160,"wires":[["e661be93174a3c06"]]},{"id":"8d6625f941a1734f","type":"delay","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"5.3s","pauseType":"delay","timeout":"5.3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":390,"y":60,"wires":[["ef2c0086391012ae"]]},{"id":"ef2c0086391012ae","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"done","func":"msg.payload = \"Calibration done\"\ndelete msg.topic\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":60,"wires":[["e1981fc3d5bd5dcd"]]},{"id":"2f39cbd1b882b3e5","type":"inject","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","props":[{"p":"payload"},{"p":"name","v":"Position Sensor","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"15","topic":"","payload":"","payloadType":"date","x":130,"y":500,"wires":[["2c56fd6e65d34c56","1abd42eb43b86290"]]},{"id":"e3cd1d26208cb692","type":"exec","z":"3739bebe6c778cd3","g":"32227694b6da15c7","command":"","addpay":"payload","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":510,"y":500,"wires":[["28d29a321847e02c"],[],[]]},{"id":"2c56fd6e65d34c56","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"check processes","func":"delete msg.reset\nmsg.payload = \"ps aux | grep mpuAngle\"\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":500,"wires":[["e3cd1d26208cb692"]]},{"id":"28d29a321847e02c","type":"split","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":630,"y":500,"wires":[["e88f4ba0f4d1d09e"]]},{"id":"e88f4ba0f4d1d09e","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"kill?","func":"if (msg.payload.includes(\"mpuAngle.py --time\")) {\n    const match = msg.payload.match(/\\b\\w+\\s+(\\d+)/)\n    msg.pid = match ? parseInt(match[1], 10) : null\n    if (msg.pid == null) {\n        return [msg, null]\n    }\n    else {\n        msg.kill = \"SIGKILL\";\n        // msg.payload = \"sudo pkill -f 'python3.*mpuAngle.py.*'\"\n        return [msg, msg]\n    }\n}\nelse return [msg, null ]","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":500,"wires":[["0123f1a21f90df33"],["8efd01a8cc1df5c1"]]},{"id":"0123f1a21f90df33","type":"delay","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","pauseType":"rate","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":940,"y":480,"wires":[["9405f0312e7b530c"]]},{"id":"526759393f6f5f68","type":"ui_button","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"Start reading","group":"f89e1392760d829e","order":5,"width":6,"height":1,"passthru":true,"label":"Start reading values","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"start_fast_read","payloadType":"str","topic":"","topicType":"str","x":230,"y":240,"wires":[["339615045b1bfa7f","8d848d0e113ab89e"]]},{"id":"339615045b1bfa7f","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"kill then => time 0.25","func":"msg.kill = \"SIGKILL\";\nnode.send(msg);\n\nsetTimeout(function () {\n    delete msg.kill;\n    msg.payload = \"--time 0.25\";\n    node.send(msg);\n}, 500);  // milliseconds delay","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":240,"wires":[["e661be93174a3c06"]]},{"id":"c645aa409e021565","type":"ui_button","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"Stop reading","group":"f89e1392760d829e","order":5,"width":6,"height":1,"passthru":true,"label":"Stop reading values","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"stop_fast_read","payloadType":"str","topic":"","topicType":"str","x":230,"y":340,"wires":[["a25b0d3ed530fb58"]]},{"id":"a25b0d3ed530fb58","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"reset","func":"\nmsg.reset = true\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":390,"y":340,"wires":[["2c56fd6e65d34c56","8d848d0e113ab89e"]]},{"id":"c72e374c3e18cf30","type":"delay","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"2s","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1290,"y":480,"wires":[["e661be93174a3c06"]]},{"id":"6619f21f66ccc3a3","type":"link in","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"positionSensor start","links":["44b78f2a6ec1dafb"],"x":115,"y":240,"wires":[["526759393f6f5f68"]]},{"id":"be30fa7396b2172a","type":"link in","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"positionSensor stop","links":["ebdf10e1d4ee8666"],"x":115,"y":340,"wires":[["c645aa409e021565"]]},{"id":"4845fbb606ccbbb6","type":"ui_ui_control","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","events":"all","x":220,"y":380,"wires":[["91b91b7cc974da25","1f9e364f2c365707"]]},{"id":"91b91b7cc974da25","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"check tab","func":"if (msg.name != \"Position Sensor\" && flow.get(\"tabname\") == \"Position Sensor\") {\n    node.send(msg);\n}\nflow.set(\"tabname\", msg.name);","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":380,"wires":[["2c56fd6e65d34c56"]]},{"id":"1f9e364f2c365707","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"check tab","func":"if (msg.payload == \"change\" && msg.name == \"Position Sensor\") {\n    msg.reset = true\n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":240,"y":280,"wires":[["339615045b1bfa7f"]]},{"id":"7b0d6cce040ff728","type":"comment","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"mpuAngle.py running with 5s when tab not opened","info":"","x":230,"y":460,"wires":[]},{"id":"e7b8b47f1654f01f","type":"comment","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"mpuAngle.py running with 0.5s when tab active","info":"","x":320,"y":200,"wires":[]},{"id":"eb0e4d09392a8a43","type":"range","z":"3739bebe6c778cd3","g":"32227694b6da15c7","minin":"-45","maxin":"45","minout":"-9","maxout":"9","action":"scale","round":false,"property":"payload","name":"","x":1850,"y":320,"wires":[["4f3b8fba418c2d7d"]]},{"id":"4f3b8fba418c2d7d","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"save global","func":"msg.payload = Number(msg.payload.toFixed(1))*-1;\nglobal.set(\"y_angle\", msg.payload)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1990,"y":320,"wires":[["5fc2a31f4d9810ef"]]},{"id":"5fc2a31f4d9810ef","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"Rotate Image","func":"// Erhalten der Winkelinformation (z. B. über MQTT)\nvar angle = msg.payload; // Der Rotationswinkel in Grad\n\n// Wert des Payloads vervielfachen\nmsg.deg = msg.payload * 5;//*10 would mean to use the actual angle, but looks weird in the dashboard\n\n// CSS-Transformation zur Rotation des Bilds\nvar transformation = \"rotate(\" + msg.deg + \"deg)\";\n\n// Senden Sie die Transformation zurück\nmsg.ui_control = {\n    \"angular\": true,\n    \"rotate\": transformation\n};\n\n\n// reduce the flickering (when values change for 0.1 or less in a timeframe of 1S, then do not update the images)\nlet lastValueTime = flow.get(\"y_lastValueTime\") ?? Date.now()\nlet lastValue = flow.get(\"y_value\") ?? 0\nif (Math.abs(lastValue - msg.payload) <= 0.1 && Math.abs(lastValueTime - Date.now()) < 1000) {\n    //flow.set(\"y_value\", msg.payload)\n    flow.set(\"y_lastValueTime\", Date.now())\n    return null\n}\nflow.set(\"y_lastValueTime\", Date.now())\nflow.set(\"y_value\", msg.payload)\nmsg.value = msg.payload < 0 ? \"← \" + msg.payload : msg.payload > 0 ? msg.payload + \" →\" : msg.payload\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2160,"y":320,"wires":[["dba3eb11dced800d","1f78a9c366e84c7e","699fc08149c77597"]]},{"id":"eb2be90032ddbb37","type":"range","z":"3739bebe6c778cd3","g":"32227694b6da15c7","minin":"-45","maxin":"45","minout":"-9","maxout":"9","action":"scale","round":false,"property":"payload","name":"","x":1850,"y":240,"wires":[["b834a73edcc9df3a"]]},{"id":"b834a73edcc9df3a","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"save global","func":"msg.payload = Number(msg.payload.toFixed(1));\nglobal.set(\"x_angle\", msg.payload)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1990,"y":240,"wires":[["4c75eab53d356616"]]},{"id":"4c75eab53d356616","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"Rotate Image","func":"// Erhalten der Winkelinformation (z. B. über MQTT)\nvar angle = msg.payload; // Der Rotationswinkel in Grad\n\n// Wert des Payloads vervielfachen\nmsg.deg = msg.payload * 5; //*10 would mean to use the actual angle, but looks weird in the dashboard\n\n// CSS-Transformation zur Rotation des Bilds\nvar transformation = \"rotate(\" + msg.deg + \"deg)\";\n\n// Senden Sie die Transformation zurück\nmsg.ui_control = {\n    \"angular\": true,\n    \"rotate\": transformation\n};\n\n// reduce the flickering (when values change for 0.1 or less in a timeframe of 1S, then do not update the images)\nlet lastValueTime = flow.get(\"x_lastValueTime\") ?? Date.now()\nlet lastValue = flow.get(\"x_value\") ?? 0\nif (Math.abs(lastValue - msg.payload) <= 0.1 && Math.abs(lastValueTime - Date.now()) < 1000) {\n    //flow.set(\"x_value\", msg.payload)\n    flow.set(\"x_lastValueTime\", Date.now())\n    return null\n}\nflow.set(\"x_lastValueTime\", Date.now())\nflow.set(\"x_value\", msg.payload)\nmsg.value = msg.payload < 0 ? \"← \" + msg.payload : msg.payload > 0 ? msg.payload + \" →\" : msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2160,"y":240,"wires":[["3fbb529e13212092","eaf79c9ddd746cfb","9087ebaa39cbbbfa","47d8c28be53b7704"]]},{"id":"8d848d0e113ab89e","type":"delay","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"5m","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":390,"y":280,"wires":[["a674e27aa3a674b7"]]},{"id":"a674e27aa3a674b7","type":"delay","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"1msg/5m","pauseType":"rate","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":520,"y":280,"wires":[["2c56fd6e65d34c56"]]},{"id":"8efd01a8cc1df5c1","type":"delay","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"1msg/0.3s","pauseType":"rate","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.3","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":910,"y":520,"wires":[["c237ca3c3d06f36d"]]},{"id":"c237ca3c3d06f36d","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"set cmd","func":"delete msg.kill\ndelete msg.pid\nmsg.payload = \"/usr/bin/sudo pkill -f \\'python3.\\*mpuAngle.py\\'\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1140,"y":520,"wires":[["9c8fa4b038815cd0"]]},{"id":"9c8fa4b038815cd0","type":"exec","z":"3739bebe6c778cd3","g":"32227694b6da15c7","command":"","addpay":"payload","append":"","useSpawn":"false","timer":"2.5","winHide":false,"oldrc":false,"name":"kill mpuAngle.py","x":1320,"y":520,"wires":[[],[],[]]},{"id":"a32a3d5947c57eb9","type":"link in","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"positionSensor calibrate","links":["46505864c3d9e739"],"x":115,"y":140,"wires":[["7689c36c4b4dc602"]]},{"id":"024bfacc0d8c1801","type":"inject","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":80,"wires":[["526759393f6f5f68"]]},{"id":"114d553e0f28d537","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"get mpu temp","func":"global.set(\"mpu6050_temp\", Number(msg.payload))","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1180,"y":360,"wires":[[]]},{"id":"315d8bb09e74599b","type":"file","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","filename":"pekaway/calibration_value_x","filenameType":"str","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":2000,"y":120,"wires":[[]]},{"id":"dfdafd0c8a8edc14","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"save calibration","func":"let newMsg = {}\nmsg.payload = global.get(\"calibration_value_x\")\nnewMsg.payload = global.get(\"calibration_value_y\")\nreturn [msg, newMsg];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1780,"y":140,"wires":[["315d8bb09e74599b"],["e89bd5a498300906"]]},{"id":"e89bd5a498300906","type":"file","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","filename":"pekaway/calibration_value_y","filenameType":"str","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":2000,"y":160,"wires":[[]]},{"id":"d10b39878b9bc1a9","type":"delay","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"2s","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1630,"y":140,"wires":[["dfdafd0c8a8edc14"]]},{"id":"72a4fa5d117124fc","type":"debug","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"debug 177","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":910,"y":80,"wires":[]},{"id":"eaf79c9ddd746cfb","type":"ui_template","z":"3739bebe6c778cd3","d":true,"g":"32227694b6da15c7","group":"f89e1392760d829e","name":"IMG ROLL","order":3,"width":6,"height":4,"format":"<div style='width:100%; height:100%; display:flex; justify-content:center; align-items:center;'>\n    <div id='image-container' style='position: relative;'>\n        <img id='image-to-rotate' src='http://pekaway.local/images/van_back' style=' transform: rotate({{msg.deg}}deg);' />\n        <div id='line'\n            style='position: absolute; width: 100%; height: 3px; background-color: grey; top: 96%; transform: translateY(-50%); z-index: 0;'>\n        </div>\n    </div>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":2360,"y":220,"wires":[[]]},{"id":"1f78a9c366e84c7e","type":"ui_template","z":"3739bebe6c778cd3","g":"32227694b6da15c7","group":"f89e1392760d829e","name":"IMG NICK","order":1,"width":6,"height":4,"format":"<div style='width:100%; height:100%; display:flex; justify-content:center; align-items:center;'>\n    <div id='image-container' style='position: relative;'>\n        <img id='image-to-rotate' src='http://pekaway.local/images/van_side' style=' transform: rotate({{msg.deg}}deg);' />\n        <div id='line'\n            style='position: absolute; width: 100%; height: 3px; background-color: grey; top: 96%; transform: translateY(-50%); z-index: 0;'>\n        </div>\n    </div>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":2360,"y":340,"wires":[[]]},{"id":"e66325ce5055968a","type":"range","z":"3739bebe6c778cd3","g":"32227694b6da15c7","minin":"-45","maxin":"45","minout":"45","maxout":"-45","action":"scale","round":false,"property":"payload","name":"","x":1460,"y":200,"wires":[["6f5f2789ea655fd0"]]},{"id":"bcfa893e5261b31f","type":"range","z":"3739bebe6c778cd3","g":"32227694b6da15c7","minin":"-45","maxin":"45","minout":"45","maxout":"-45","action":"scale","round":false,"property":"payload","name":"","x":1460,"y":380,"wires":[["a69003b2fc0e3014"]]},{"id":"47d8c28be53b7704","type":"ui_template","z":"3739bebe6c778cd3","g":"32227694b6da15c7","group":"f89e1392760d829e","name":"IMG ROLL","order":3,"width":6,"height":4,"format":"<div style='width:100%; height:100%; display:flex; justify-content:center; align-items:center;'>\n    <div id='image-container' style='position: relative;'>\n        <img id='image-to-rotate' src='http://pekaway.local/images/van_back' style='width:176px; height:190px; transform: rotate({{msg.deg}}deg);' />\n        <div id='line'\n            style='position: absolute; width: 100%; height: 3px; background-color: grey; top: 96%; transform: translateY(-50%); z-index: 0;'>\n        </div>\n    </div>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":2750,"y":180,"wires":[[]]},{"id":"9087ebaa39cbbbfa","type":"ui_template","z":"3739bebe6c778cd3","d":true,"g":"32227694b6da15c7","group":"f89e1392760d829e","name":"IMG ROLL","order":3,"width":6,"height":4,"format":"<div style='width:100%; height:100%; display:flex; justify-content:center; align-items:center;'>\n    <div id='image-container' style='position: relative;'>\n        <img id='image-to-rotate' src='http://pekaway.local/images/van_back' style='width:230px; height:173px; transform: rotate({{msg.deg}}deg);' />\n        <div id='line'\n            style='position: absolute; width: 100%; height: 3px; background-color: grey; top: 96%; transform: translateY(-50%); z-index: 0;'>\n        </div>\n    </div>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":2570,"y":240,"wires":[[]]},{"id":"bfeb39c8cda7b75d","type":"comment","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"231x260 Pixel","info":"","x":2310,"y":140,"wires":[]},{"id":"e84dac9590c81505","type":"comment","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"Hinten ","info":"","x":2290,"y":100,"wires":[]},{"id":"e255aaa0c9933f07","type":"comment","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"Seite","info":"","x":2470,"y":280,"wires":[]},{"id":"27230b28b20256a9","type":"ui_switch","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","label":"Hinten invert","tooltip":"","group":"f89e1392760d829e","order":10,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":1810,"y":420,"wires":[["575754770ef50592"]]},{"id":"85a6d423449be08c","type":"ui_switch","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","label":"Seite invert","tooltip":"","group":"f89e1392760d829e","order":10,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":1810,"y":460,"wires":[["dac68d377d2889aa"]]},{"id":"882ae1f332f62fea","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"Invert Hinten","func":"var normal= flow.get(\"hintennormal\");\nvar invert= flow.get(\"hinteninvert\")\nvar umsch = flow.get(\"hinten\")\n\nif (umsch==false){\n    msg.payload=normal\n}\nif (umsch==true){\n    msg.payload=invert\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1710,"y":240,"wires":[["eb2be90032ddbb37"]]},{"id":"763f8575bd4912d8","type":"comment","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"275x140. Pixel","info":"","x":2500,"y":380,"wires":[]},{"id":"0741ee34e3059137","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"Invert Seite","func":"var normal= flow.get(\"seitenormal\");\nvar invert= flow.get(\"seiteinvert\")\nvar umsch = flow.get(\"seite\")\n\nif (umsch==false){\n    msg.payload=normal\n}\nif (umsch==true){\n    msg.payload=invert\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1710,"y":320,"wires":[["eb0e4d09392a8a43"]]},{"id":"894fb0e03e254cf3","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"set normal","func":"flow.set(\"hintennormal\", msg.payload) \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1470,"y":240,"wires":[["882ae1f332f62fea"]]},{"id":"6f5f2789ea655fd0","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"set invert","func":"flow.set(\"hinteninvert\", msg.payload) \n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1600,"y":200,"wires":[[]]},{"id":"bb2ebb27405d5636","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"set normal","func":"flow.set(\"seitenormal\", msg.payload) \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1490,"y":320,"wires":[["0741ee34e3059137"]]},{"id":"a69003b2fc0e3014","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"set invert","func":"flow.set(\"seiteinvert\", msg.payload) \n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1620,"y":380,"wires":[[]]},{"id":"575754770ef50592","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"set hinten","func":"flow.set(\"hinten\", msg.payload) \nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1960,"y":420,"wires":[["5cf9a486546453bc"]]},{"id":"dac68d377d2889aa","type":"function","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"set hinten","func":"flow.set(\"seite\", msg.payload) \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1960,"y":460,"wires":[["2c23b6bd703456ef"]]},{"id":"5cf9a486546453bc","type":"file","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","filename":"pekaway/invert_hinten","filenameType":"str","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":2140,"y":420,"wires":[[]]},{"id":"2c23b6bd703456ef","type":"file","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","filename":"pekaway/invert_seite","filenameType":"str","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":2140,"y":460,"wires":[[]]},{"id":"b47b6300f24829e1","type":"file in","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","filename":"pekaway/invert_hinten","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":1620,"y":420,"wires":[["27230b28b20256a9","575754770ef50592"]]},{"id":"bd292e4c7dd2ee73","type":"file in","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"","filename":"pekaway/invert_seite","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":1620,"y":460,"wires":[["85a6d423449be08c","dac68d377d2889aa"]]},{"id":"1abd42eb43b86290","type":"link out","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"link out 10","mode":"link","links":["e4bad569302ab4f6"],"x":235,"y":560,"wires":[]},{"id":"e4bad569302ab4f6","type":"link in","z":"3739bebe6c778cd3","g":"32227694b6da15c7","name":"link in 15","links":["1abd42eb43b86290"],"x":1455,"y":440,"wires":[["b47b6300f24829e1","bd292e4c7dd2ee73"]]},{"id":"f89e1392760d829e","type":"ui_group","name":"NICK","tab":"44c44161193a7be6","order":1,"disp":false,"width":"6","collapse":false,"className":""},{"id":"44c44161193a7be6","type":"ui_tab","name":"Position Sensor","icon":"fa-arrows","order":6,"disabled":false,"hidden":false}]



Gruß
Arno

@SaschaKorn
Ich habe den Lagesensor noch mals überarbeitet.
Je nach Einbau kann es sein das dass Fahrzeug seitlich höher steht aber vorne wird angezeigt, dann muss die X und Y-Achse getauscht werden, das ist jetzt auch möglich.

  1. X-Y Achse invertieren
  2. Vorne, Hinten invertieren
  3. Rechts, Links invertieren.
    So sollte alles abgedeckt sein, ausser der diagonale Einbau.

Und das wäre der passende Code dazu.

[{"id":"412b3e2d021f7a33","type":"tab","label":"MPU6050","disabled":false,"info":"","env":[]},{"id":"28317a609d1f9088","type":"group","z":"412b3e2d021f7a33","name":"VAN PI Core - MPU6050","style":{"label":true},"nodes":["1b9dc0867cb661f6","8451a751463042c9","bf691c714efcade5","63932da30bffb350","08f4acda39a4fd6c","2b92b4b12adfccf8","4294f39433a1201e","e3d30d7e6b010e61","341ed83f050b4803","ea94790d60088f2b","a0bd49a36478db9f","637fdd8edec530ae","c97d2c6e65d6499a","d3d9c7466b1faf2c","228c6725131385d2","4adb66e17d7380d5","c10a77ef742fb80f","2ae3ad321e0b44bc","2033121e09c18d1a","b7a28cb45375548b","f64370c6a37789c5","3ee52b191ff24358","254c4f4303ed77b0","b042109c12b7f3b7","c617af9cb6a3b2b4","c9304231b5b20487","d863d973a195d5f6","c778b5405259afc5","7f20562a77a7db67","db0fcaab3d04ed3e","3fccd69a2a2628e5","586bed5703f1717c","552e407cf1f05637","30adc535cd1b68af","cc98ba65fee8da86","c05b625079ee9c2d","0d3490bb463acc4f","ce423c89e0568529","70b602981d1c6584","08a1c99e47e29820","9c4b434f6a44ba9b","12d296f580a42546","8b714b8778ad30c0","1c9000fc4312308c","62869401d8254fb0","234058333abc0a0c","5e93ce02866b5228","be71a52074c8f338","8c7279fb74ea0146","f9cfecfe6a075524","8b8983f75c50716d","47f04cab6865df70","8049bb636c4d60b2","6640573b4e9ea752","724f78382ff2ea37","2124ead5251b0e33","938f4f7de9551140","b8280def883e01c8","1bf5ce9417d5b4c5","e618d524b8fb1a5d","25e422eec5038057","e84865bfbbf9b6c8","967eddca69fe0a4d","08cee44e0f40f602","4edd0f665c2aff42","0eef0b5eda0bb504","4b5ff93a116364e6","c899a9070ea9364e","84145618729de136","b6748802ee2f89a8","78d150ddae56107b","c7a16d287311788c","b16b8dc5d8ac537e","05579560f10f95f2","dbb8c0d6c6194afc","ef8a22e6bcb221da","95b153b4f0114ca2","72f3f52265ea74fb","6b481701f9c1297f","26bc12977899ca94","6a4aa317707d4cfb","8e2d5c85106235a8","c6ee8b69b8f88b3a","1d13fff3ca3e30ad","8321cefa88554e56","e5db32434873bf02","a9d489fc39a88f63","058a657c42cb14c0","98fb66ad79c0f7b4","0782a2000c24fc48","058998d6c8af7c34","bd0426ee910a4d73","7ef14a1b10c7def0"],"x":14,"y":119,"w":3002,"h":582},{"id":"1b9dc0867cb661f6","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"add Offset","func":"// Erhalten der Eingangsdaten\nvar eingangsdaten = msg.payload;\n\n// Kalibrierungswert aus der globalen Variable verwenden\nvar kalibrierungswert = global.get(\"calibration_value_x\") || 0; // Standardwert ist 0, falls nicht gesetzt\n\n// Anpassen der Daten um den Kalibrierungswert\nvar datenMitKalibrierung = eingangsdaten - kalibrierungswert;\n\n// Auf eine Dezimalstelle runden\nvar gerundeteDaten = datenMitKalibrierung.toFixed(1); // 1 steht für eine Dezimalstelle\n\n// Wenn der gerundete Wert 0 ist, auf 0.0 ändern\nif (Number(gerundeteDaten) === 0) {\n    gerundeteDaten = \"0.0\";\n}\n\n// Weiterleiten der modifizierten und gerundeten Daten\nmsg.payload = parseFloat(gerundeteDaten); // Als Zahl statt String zurückgeben\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1310,"y":320,"wires":[["1d13fff3ca3e30ad","e5db32434873bf02"]]},{"id":"8451a751463042c9","type":"smooth","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","property":"payload","action":"mean","count":"3","round":"1","mult":"single","reduce":true,"x":1160,"y":320,"wires":[["1b9dc0867cb661f6"]]},{"id":"bf691c714efcade5","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"add Offset","func":"// Erhalten der Eingangsdaten\nvar eingangsdaten = msg.payload;\n\n// Kalibrierungswert aus der globalen Variable verwenden\nvar kalibrierungswert = global.get(\"calibration_value_y\") || 0; // Standardwert ist 0, falls nicht gesetzt\n\n// Anpassen der Daten um den Kalibrierungswert\nvar datenMitKalibrierung = eingangsdaten - kalibrierungswert;\n\n// Auf eine Dezimalstelle runden\nvar gerundeteDaten = datenMitKalibrierung.toFixed(1); // 1 steht für eine Dezimalstelle\n\n// Wenn der gerundete Wert 0 ist, auf \"0.0\" ändern\nif (Number(gerundeteDaten) === 0) {\n    gerundeteDaten = \"0.0\";\n}\n\n// Weiterleiten der modifizierten und gerundeten Daten\nmsg.payload = parseFloat(gerundeteDaten); // Als Zahl statt String zurückgeben\n\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1310,"y":400,"wires":[["8321cefa88554e56","98fb66ad79c0f7b4"]]},{"id":"63932da30bffb350","type":"smooth","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","property":"payload","action":"mean","count":"3","round":"1","mult":"single","reduce":true,"x":1160,"y":400,"wires":[["bf691c714efcade5"]]},{"id":"08f4acda39a4fd6c","type":"ui_text","z":"412b3e2d021f7a33","g":"28317a609d1f9088","group":"4d2dbbaac32d7d9a","order":2,"width":6,"height":1,"name":"Winkel Nick","label":"","format":"{{msg.value}}","layout":"row-center","className":"mpu6050","x":2750,"y":400,"wires":[]},{"id":"2b92b4b12adfccf8","type":"ui_button","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"Start Calibration","group":"4d2dbbaac32d7d9a","order":5,"width":6,"height":1,"passthru":true,"label":"Calibrate position sensor","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"start_calibration","payloadType":"str","topic":"start_calibration","topicType":"str","x":240,"y":240,"wires":[["4294f39433a1201e","e3d30d7e6b010e61","ea94790d60088f2b","c10a77ef742fb80f","2ae3ad321e0b44bc"]]},{"id":"4294f39433a1201e","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"Kalibrierungsfunktion X","func":"// Variablen für die Kalibrierung\nlet calibrationDatax = context.get(\"calibrationData_x\") || [];\nlet timer = context.get(\"timer\") || null;\n\n// Startet die Kalibrierung bei einer Nachricht vom Button\nif (msg.topic === \"start_calibration\" && !timer) {\n    calibrationDatax = [];\n    context.set(\"calibrationData_x\", calibrationDatax);\n\n    timer = setTimeout(() => {\n        let sum = calibrationDatax.reduce((a, b) => a + b, 0);\n        let avg = calibrationDatax.length > 0 ? sum / calibrationDatax.length : 0;\n        global.set(\"calibration_value_x\", avg); // Speichert das Ergebnis in der globalen Variable\n        context.set(\"timer\", null);\n        node.send({ payload: avg });\n    }, 5000); // Kalibrierungszeitraum: 5 Sekunden\n\n    context.set(\"timer\", timer);\n    return;\n}\n\n// Sammelt Daten, wenn eine Nachricht vom Sensor empfangen wird\nif (msg.topic === \"x_angle\"&& timer) {\n    let value = parseFloat(msg.payload);\n    if (!isNaN(value)) {\n        calibrationDatax.push(value);\n        context.set(\"calibrationData_x\", calibrationDatax);\n    }\n}\n\nreturn null; // Sendet keine Nachricht, bis der Timer abläuft","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1210,"y":200,"wires":[[]]},{"id":"e3d30d7e6b010e61","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"Kalibrierungsfunktion Y","func":"// Variablen für die Kalibrierung\nlet calibrationData = context.get(\"calibrationData_y\") || [];\nlet timer = context.get(\"timer\") || null;\n\n// Startet die Kalibrierung bei einer Nachricht vom Button\nif (msg.topic === \"start_calibration\" && !timer) {\n    calibrationData = [];\n    context.set(\"calibrationData_y\", calibrationData);\n\n    timer = setTimeout(() => {\n        let sum = calibrationData.reduce((a, b) => a + b, 0);\n        let avg = calibrationData.length > 0 ? sum / calibrationData.length : 0;\n        global.set(\"calibration_value_y\", avg); // Speichert das Ergebnis in der globalen Variable\n        context.set(\"timer\", null);\n        node.send({ payload: avg });\n    }, 30000); // Kalibrierungszeitraum: 5 Sekunden\n\n    context.set(\"timer\", timer);\n    return;\n}\n\n// Sammelt Daten, wenn eine Nachricht vom Sensor empfangen wird\nif (msg.topic === \"y_angle\" && timer) {\n    let value = parseFloat(msg.payload);\n    if (!isNaN(value)) {\n        calibrationData.push(value);\n        context.set(\"calibrationData_y\", calibrationData);\n    }\n}\n\nreturn null; // Sendet keine Nachricht, bis der Timer abläuft","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1210,"y":240,"wires":[["228c6725131385d2"]]},{"id":"341ed83f050b4803","type":"ui_toast","z":"412b3e2d021f7a33","g":"28317a609d1f9088","position":"top right","displayTime":"5","highlight":"","sendall":false,"outputs":0,"ok":"OK","cancel":"","raw":false,"className":"","topic":"","name":"","x":690,"y":160,"wires":[]},{"id":"ea94790d60088f2b","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"calibrating...","func":"msg.payload = \"Calibrating position sensor...\"\ndelete msg.topic\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":200,"wires":[["341ed83f050b4803"]]},{"id":"a0bd49a36478db9f","type":"ui_text","z":"412b3e2d021f7a33","g":"28317a609d1f9088","group":"4d2dbbaac32d7d9a","order":4,"width":6,"height":1,"name":"Winkel ROLL","label":"","format":"{{msg.value}}","layout":"row-center","className":"mpu6050","x":2750,"y":360,"wires":[]},{"id":"637fdd8edec530ae","type":"exec","z":"412b3e2d021f7a33","g":"28317a609d1f9088","command":"python3 pekaway/mpu_py/mpuAngle.py","addpay":"payload","append":"","useSpawn":"true","timer":"","winHide":false,"oldrc":false,"name":"mpuAngle.py","x":670,"y":340,"wires":[["c97d2c6e65d6499a","2124ead5251b0e33"],[],[]]},{"id":"c97d2c6e65d6499a","type":"json","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","property":"payload","action":"","pretty":false,"x":810,"y":340,"wires":[["d3d9c7466b1faf2c"]]},{"id":"d3d9c7466b1faf2c","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"filter values","func":"let msgX = {}\nlet msgY = {}\nlet msgT = {}\nmsgX.payload = Number(msg.payload.x_angle);\nmsgX.topic = \"x_angle\";\n//node.send([msg, null, null])\nmsgY.payload = Number(msg.payload.y_angle);\nmsgY.topic = \"y_angle\";\n//node.send([null, msg, null])\nmsgT.payload = msg.payload.mpu_temp.toFixed(1);\n//node.send([null, null, msg])\nreturn [msgX, msgY, msgT]","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":950,"y":340,"wires":[["8451a751463042c9","4294f39433a1201e"],["63932da30bffb350","e3d30d7e6b010e61"],["8b8983f75c50716d"]]},{"id":"228c6725131385d2","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"kill then => time 2","func":"msg.kill = \"SIGKILL\";\nnode.send(msg);\n\nsetTimeout(function () {\n    delete msg.kill;\n    msg.payload = \"--time 2\";\n    node.send(msg);\n}, 500);  // milliseconds delay","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1430,"y":240,"wires":[["637fdd8edec530ae","724f78382ff2ea37"]]},{"id":"4adb66e17d7380d5","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"time 5","func":"delete msg.kill\nmsg.payload = \"--time 5\"\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1130,"y":580,"wires":[["db0fcaab3d04ed3e"]]},{"id":"c10a77ef742fb80f","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"kill then => time 0.25","func":"msg.kill = \"SIGKILL\";\nnode.send(msg);\n\nsetTimeout(function () {\n    delete msg.kill;\n    msg.payload = \"--time 0.25\";\n    node.send(msg);\n}, 1000);  // milliseconds delay","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":260,"wires":[["637fdd8edec530ae"]]},{"id":"2ae3ad321e0b44bc","type":"delay","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"5.3s","pauseType":"delay","timeout":"5.3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":390,"y":160,"wires":[["2033121e09c18d1a"]]},{"id":"2033121e09c18d1a","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"done","func":"msg.payload = \"Calibration done\"\ndelete msg.topic\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":160,"wires":[["341ed83f050b4803"]]},{"id":"b7a28cb45375548b","type":"inject","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","props":[{"p":"payload"},{"p":"name","v":"Position Sensor","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"15","topic":"","payload":"","payloadType":"date","x":130,"y":600,"wires":[["3ee52b191ff24358","6a4aa317707d4cfb"]]},{"id":"f64370c6a37789c5","type":"exec","z":"412b3e2d021f7a33","g":"28317a609d1f9088","command":"","addpay":"payload","append":"","useSpawn":"false","timer":"","winHide":false,"oldrc":false,"name":"","x":510,"y":600,"wires":[["254c4f4303ed77b0"],[],[]]},{"id":"3ee52b191ff24358","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"check processes","func":"delete msg.reset\nmsg.payload = \"ps aux | grep mpuAngle\"\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":600,"wires":[["f64370c6a37789c5"]]},{"id":"254c4f4303ed77b0","type":"split","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":630,"y":600,"wires":[["b042109c12b7f3b7"]]},{"id":"b042109c12b7f3b7","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"kill?","func":"if (msg.payload.includes(\"mpuAngle.py --time\")) {\n    const match = msg.payload.match(/\\b\\w+\\s+(\\d+)/)\n    msg.pid = match ? parseInt(match[1], 10) : null\n    if (msg.pid == null) {\n        return [msg, null]\n    }\n    else {\n        msg.kill = \"SIGKILL\";\n        // msg.payload = \"sudo pkill -f 'python3.*mpuAngle.py.*'\"\n        return [msg, msg]\n    }\n}\nelse return [msg, null ]","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":750,"y":600,"wires":[["c617af9cb6a3b2b4"],["234058333abc0a0c"]]},{"id":"c617af9cb6a3b2b4","type":"delay","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","pauseType":"rate","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"2","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":940,"y":580,"wires":[["4adb66e17d7380d5"]]},{"id":"c9304231b5b20487","type":"ui_button","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"Start reading","group":"4d2dbbaac32d7d9a","order":6,"width":6,"height":1,"passthru":true,"label":"Start reading values","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"start_fast_read","payloadType":"str","topic":"","topicType":"str","x":230,"y":340,"wires":[["d863d973a195d5f6","1c9000fc4312308c"]]},{"id":"d863d973a195d5f6","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"kill then => time 0.25","func":"msg.kill = \"SIGKILL\";\nnode.send(msg);\n\nsetTimeout(function () {\n    delete msg.kill;\n    msg.payload = \"--time 0.25\";\n    node.send(msg);\n}, 500);  // milliseconds delay","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":340,"wires":[["637fdd8edec530ae"]]},{"id":"c778b5405259afc5","type":"ui_button","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"Stop reading","group":"4d2dbbaac32d7d9a","order":7,"width":6,"height":1,"passthru":true,"label":"Stop reading values","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"stop_fast_read","payloadType":"str","topic":"","topicType":"str","x":230,"y":440,"wires":[["7f20562a77a7db67"]]},{"id":"7f20562a77a7db67","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"reset","func":"\nmsg.reset = true\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":390,"y":440,"wires":[["3ee52b191ff24358","1c9000fc4312308c"]]},{"id":"db0fcaab3d04ed3e","type":"delay","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"2s","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1290,"y":580,"wires":[["637fdd8edec530ae"]]},{"id":"3fccd69a2a2628e5","type":"link in","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"positionSensor start","links":["44b78f2a6ec1dafb"],"x":115,"y":340,"wires":[["c9304231b5b20487"]]},{"id":"586bed5703f1717c","type":"link in","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"positionSensor stop","links":["ebdf10e1d4ee8666"],"x":115,"y":440,"wires":[["c778b5405259afc5"]]},{"id":"552e407cf1f05637","type":"ui_ui_control","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","events":"all","x":220,"y":480,"wires":[["30adc535cd1b68af","cc98ba65fee8da86"]]},{"id":"30adc535cd1b68af","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"check tab","func":"if (msg.name != \"Position Sensor\" && flow.get(\"tabname\") == \"Position Sensor\") {\n    node.send(msg);\n}\nflow.set(\"tabname\", msg.name);","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":480,"wires":[["3ee52b191ff24358"]]},{"id":"cc98ba65fee8da86","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"check tab","func":"if (msg.payload == \"change\" && msg.name == \"Position Sensor\") {\n    msg.reset = true\n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":240,"y":380,"wires":[["d863d973a195d5f6"]]},{"id":"c05b625079ee9c2d","type":"comment","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"mpuAngle.py running with 5s when tab not opened","info":"","x":230,"y":560,"wires":[]},{"id":"0d3490bb463acc4f","type":"comment","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"mpuAngle.py running with 0.5s when tab active","info":"","x":320,"y":300,"wires":[]},{"id":"ce423c89e0568529","type":"range","z":"412b3e2d021f7a33","g":"28317a609d1f9088","minin":"-45","maxin":"45","minout":"-9","maxout":"9","action":"scale","round":false,"property":"payload","name":"","x":2250,"y":400,"wires":[["70b602981d1c6584"]]},{"id":"70b602981d1c6584","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"save global","func":"msg.payload = Number(msg.payload.toFixed(1))*-1;\nglobal.set(\"y_angle\", msg.payload)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2390,"y":400,"wires":[["08a1c99e47e29820"]]},{"id":"08a1c99e47e29820","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"Rotate Image","func":"// Erhalten der Winkelinformation (z. B. über MQTT)\nvar angle = msg.payload; // Der Rotationswinkel in Grad\n\n// Wert des Payloads vervielfachen\nmsg.deg = msg.payload * 5;//*10 would mean to use the actual angle, but looks weird in the dashboard\n\n// CSS-Transformation zur Rotation des Bilds\nvar transformation = \"rotate(\" + msg.deg + \"deg)\";\n\n// Senden Sie die Transformation zurück\nmsg.ui_control = {\n    \"angular\": true,\n    \"rotate\": transformation\n};\n\n\n// reduce the flickering (when values change for 0.1 or less in a timeframe of 1S, then do not update the images)\nlet lastValueTime = flow.get(\"y_lastValueTime\") ?? Date.now()\nlet lastValue = flow.get(\"y_value\") ?? 0\nif (Math.abs(lastValue - msg.payload) <= 0.1 && Math.abs(lastValueTime - Date.now()) < 1000) {\n    //flow.set(\"y_value\", msg.payload)\n    flow.set(\"y_lastValueTime\", Date.now())\n    return null\n}\nflow.set(\"y_lastValueTime\", Date.now())\nflow.set(\"y_value\", msg.payload)\nmsg.value = msg.payload < 0 ? \"← \" + msg.payload : msg.payload > 0 ? msg.payload + \" →\" : msg.payload\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2560,"y":400,"wires":[["08f4acda39a4fd6c","b8280def883e01c8","c6ee8b69b8f88b3a"]]},{"id":"9c4b434f6a44ba9b","type":"range","z":"412b3e2d021f7a33","g":"28317a609d1f9088","minin":"-45","maxin":"45","minout":"-9","maxout":"9","action":"scale","round":false,"property":"payload","name":"","x":2250,"y":340,"wires":[["12d296f580a42546"]]},{"id":"12d296f580a42546","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"save global","func":"msg.payload = Number(msg.payload.toFixed(1));\nglobal.set(\"x_angle\", msg.payload)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2390,"y":340,"wires":[["8b714b8778ad30c0"]]},{"id":"8b714b8778ad30c0","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"Rotate Image","func":"// Erhalten der Winkelinformation (z. B. über MQTT)\nvar angle = msg.payload; // Der Rotationswinkel in Grad\n\n// Wert des Payloads vervielfachen\nmsg.deg = msg.payload * 5; //*10 would mean to use the actual angle, but looks weird in the dashboard\n\n// CSS-Transformation zur Rotation des Bilds\nvar transformation = \"rotate(\" + msg.deg + \"deg)\";\n\n// Senden Sie die Transformation zurück\nmsg.ui_control = {\n    \"angular\": true,\n    \"rotate\": transformation\n};\n\n// reduce the flickering (when values change for 0.1 or less in a timeframe of 1S, then do not update the images)\nlet lastValueTime = flow.get(\"x_lastValueTime\") ?? Date.now()\nlet lastValue = flow.get(\"x_value\") ?? 0\nif (Math.abs(lastValue - msg.payload) <= 0.1 && Math.abs(lastValueTime - Date.now()) < 1000) {\n    //flow.set(\"x_value\", msg.payload)\n    flow.set(\"x_lastValueTime\", Date.now())\n    return null\n}\nflow.set(\"x_lastValueTime\", Date.now())\nflow.set(\"x_value\", msg.payload)\nmsg.value = msg.payload < 0 ? \"← \" + msg.payload : msg.payload > 0 ? msg.payload + \" →\" : msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2560,"y":340,"wires":[["a0bd49a36478db9f","938f4f7de9551140","e84865bfbbf9b6c8","25e422eec5038057"]]},{"id":"1c9000fc4312308c","type":"delay","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"5m","pauseType":"delay","timeout":"5","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":390,"y":380,"wires":[["62869401d8254fb0"]]},{"id":"62869401d8254fb0","type":"delay","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"1msg/5m","pauseType":"rate","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":520,"y":380,"wires":[["3ee52b191ff24358"]]},{"id":"234058333abc0a0c","type":"delay","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"1msg/0.3s","pauseType":"rate","timeout":"0.1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"0.3","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":910,"y":620,"wires":[["5e93ce02866b5228"]]},{"id":"5e93ce02866b5228","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"set cmd","func":"delete msg.kill\ndelete msg.pid\nmsg.payload = \"/usr/bin/sudo pkill -f \\'python3.\\*mpuAngle.py\\'\"\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1140,"y":620,"wires":[["be71a52074c8f338"]]},{"id":"be71a52074c8f338","type":"exec","z":"412b3e2d021f7a33","g":"28317a609d1f9088","command":"","addpay":"payload","append":"","useSpawn":"false","timer":"2.5","winHide":false,"oldrc":false,"name":"kill mpuAngle.py","x":1320,"y":620,"wires":[[],[],[]]},{"id":"8c7279fb74ea0146","type":"link in","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"positionSensor calibrate","links":["46505864c3d9e739"],"x":115,"y":240,"wires":[["2b92b4b12adfccf8"]]},{"id":"f9cfecfe6a075524","type":"inject","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":180,"wires":[["c9304231b5b20487"]]},{"id":"8b8983f75c50716d","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"get mpu temp","func":"global.set(\"mpu6050_temp\", Number(msg.payload))","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1180,"y":440,"wires":[[]]},{"id":"47f04cab6865df70","type":"file","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","filename":"pekaway/calibration_value_x","filenameType":"str","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":2000,"y":220,"wires":[[]]},{"id":"8049bb636c4d60b2","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"save calibration","func":"let newMsg = {}\nmsg.payload = global.get(\"calibration_value_x\")\nnewMsg.payload = global.get(\"calibration_value_y\")\nreturn [msg, newMsg];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1780,"y":240,"wires":[["47f04cab6865df70"],["6640573b4e9ea752"]]},{"id":"6640573b4e9ea752","type":"file","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","filename":"pekaway/calibration_value_y","filenameType":"str","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":2000,"y":260,"wires":[[]]},{"id":"724f78382ff2ea37","type":"delay","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"2s","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1630,"y":240,"wires":[["8049bb636c4d60b2"]]},{"id":"2124ead5251b0e33","type":"debug","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"debug 177","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":910,"y":180,"wires":[]},{"id":"938f4f7de9551140","type":"ui_template","z":"412b3e2d021f7a33","d":true,"g":"28317a609d1f9088","group":"f89e1392760d829e","name":"IMG ROLL","order":8,"width":6,"height":4,"format":"<div style='width:100%; height:100%; display:flex; justify-content:center; align-items:center;'>\n    <div id='image-container' style='position: relative;'>\n        <img id='image-to-rotate' src='http://pekaway.local/images/van_back' style=' transform: rotate({{msg.deg}}deg);' />\n        <div id='line'\n            style='position: absolute; width: 100%; height: 3px; background-color: grey; top: 96%; transform: translateY(-50%); z-index: 0;'>\n        </div>\n    </div>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":2770,"y":320,"wires":[[]]},{"id":"b8280def883e01c8","type":"ui_template","z":"412b3e2d021f7a33","g":"28317a609d1f9088","group":"4d2dbbaac32d7d9a","name":"IMG NICK","order":1,"width":6,"height":4,"format":"<div style='width:100%; height:100%; display:flex; justify-content:center; align-items:center;'>\n    <div id='image-container' style='position: relative;'>\n        <img id='image-to-rotate' src='http://pekaway.local/images/van_side' style=' transform: rotate({{msg.deg}}deg);' />\n        <div id='line'\n            style='position: absolute; width: 100%; height: 3px; background-color: grey; top: 96%; transform: translateY(-50%); z-index: 0;'>\n        </div>\n    </div>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":2760,"y":440,"wires":[[]]},{"id":"1bf5ce9417d5b4c5","type":"range","z":"412b3e2d021f7a33","g":"28317a609d1f9088","minin":"-45","maxin":"45","minout":"45","maxout":"-45","action":"scale","round":false,"property":"payload","name":"","x":1860,"y":300,"wires":[["c7a16d287311788c"]]},{"id":"e618d524b8fb1a5d","type":"range","z":"412b3e2d021f7a33","g":"28317a609d1f9088","minin":"-45","maxin":"45","minout":"45","maxout":"-45","action":"scale","round":false,"property":"payload","name":"","x":1880,"y":440,"wires":[["05579560f10f95f2"]]},{"id":"25e422eec5038057","type":"ui_template","z":"412b3e2d021f7a33","g":"28317a609d1f9088","group":"4d2dbbaac32d7d9a","name":"IMG ROLL","order":3,"width":6,"height":4,"format":"<div style='width:100%; height:100%; display:flex; justify-content:center; align-items:center;'>\n    <div id='image-container' style='position: relative;'>\n        <img id='image-to-rotate' src='http://pekaway.local/images/van_back' style='width:176px; height:190px; transform: rotate({{msg.deg}}deg);' />\n        <div id='line'\n            style='position: absolute; width: 100%; height: 3px; background-color: grey; top: 96%; transform: translateY(-50%); z-index: 0;'>\n        </div>\n    </div>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":2770,"y":280,"wires":[[]]},{"id":"e84865bfbbf9b6c8","type":"ui_template","z":"412b3e2d021f7a33","d":true,"g":"28317a609d1f9088","group":"f89e1392760d829e","name":"IMG ROLL","order":9,"width":6,"height":4,"format":"<div style='width:100%; height:100%; display:flex; justify-content:center; align-items:center;'>\n    <div id='image-container' style='position: relative;'>\n        <img id='image-to-rotate' src='http://pekaway.local/images/van_back' style='width:230px; height:173px; transform: rotate({{msg.deg}}deg);' />\n        <div id='line'\n            style='position: absolute; width: 100%; height: 3px; background-color: grey; top: 96%; transform: translateY(-50%); z-index: 0;'>\n        </div>\n    </div>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":2930,"y":340,"wires":[[]]},{"id":"967eddca69fe0a4d","type":"comment","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"231x260 Pixel","info":"","x":2770,"y":240,"wires":[]},{"id":"08cee44e0f40f602","type":"comment","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"Hinten ","info":"","x":2750,"y":200,"wires":[]},{"id":"4edd0f665c2aff42","type":"comment","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"Seite","info":"","x":2770,"y":520,"wires":[]},{"id":"0eef0b5eda0bb504","type":"ui_switch","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","label":"Hinten invert","tooltip":"","group":"4d2dbbaac32d7d9a","order":8,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":1810,"y":520,"wires":[["dbb8c0d6c6194afc"]]},{"id":"4b5ff93a116364e6","type":"ui_switch","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","label":"Seite invert","tooltip":"","group":"4d2dbbaac32d7d9a","order":9,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":1810,"y":560,"wires":[["ef8a22e6bcb221da"]]},{"id":"c899a9070ea9364e","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"Invert Hinten","func":"var normal= flow.get(\"hintennormal\");\nvar invert= flow.get(\"hinteninvert\")\nvar umsch = flow.get(\"hinten\")\n\nif (umsch==false){\n    msg.payload=normal\n}\nif (umsch==true){\n    msg.payload=invert\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2110,"y":340,"wires":[["9c4b434f6a44ba9b"]]},{"id":"84145618729de136","type":"comment","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"275x140. Pixel","info":"","x":2770,"y":480,"wires":[]},{"id":"b6748802ee2f89a8","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"Invert Seite","func":"var normal= flow.get(\"seitenormal\");\nvar invert= flow.get(\"seiteinvert\")\nvar umsch = flow.get(\"seite\")\n\nif (umsch==false){\n    msg.payload=normal\n}\nif (umsch==true){\n    msg.payload=invert\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2110,"y":400,"wires":[["ce423c89e0568529"]]},{"id":"78d150ddae56107b","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"set normal","func":"flow.set(\"hintennormal\", msg.payload) \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1870,"y":340,"wires":[["c899a9070ea9364e"]]},{"id":"c7a16d287311788c","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"set invert","func":"flow.set(\"hinteninvert\", msg.payload) \n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2000,"y":300,"wires":[[]]},{"id":"b16b8dc5d8ac537e","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"set normal","func":"flow.set(\"seitenormal\", msg.payload) \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1890,"y":400,"wires":[["b6748802ee2f89a8"]]},{"id":"05579560f10f95f2","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"set invert","func":"flow.set(\"seiteinvert\", msg.payload) \n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2040,"y":440,"wires":[[]]},{"id":"dbb8c0d6c6194afc","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"set hinten","func":"flow.set(\"hinten\", msg.payload) \nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1960,"y":520,"wires":[["95b153b4f0114ca2"]]},{"id":"ef8a22e6bcb221da","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"set hinten","func":"flow.set(\"seite\", msg.payload) \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1960,"y":560,"wires":[["72f3f52265ea74fb"]]},{"id":"95b153b4f0114ca2","type":"file","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","filename":"pekaway/invert_hinten","filenameType":"str","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":2140,"y":520,"wires":[[]]},{"id":"72f3f52265ea74fb","type":"file","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","filename":"pekaway/invert_seite","filenameType":"str","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":2140,"y":560,"wires":[[]]},{"id":"6b481701f9c1297f","type":"file in","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","filename":"pekaway/invert_hinten","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":1620,"y":520,"wires":[["0eef0b5eda0bb504","dbb8c0d6c6194afc"]]},{"id":"26bc12977899ca94","type":"file in","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","filename":"pekaway/invert_seite","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":1620,"y":560,"wires":[["4b5ff93a116364e6","ef8a22e6bcb221da"]]},{"id":"6a4aa317707d4cfb","type":"link out","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"link out 10","mode":"link","links":["8e2d5c85106235a8"],"x":235,"y":660,"wires":[]},{"id":"8e2d5c85106235a8","type":"link in","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"link in 15","links":["6a4aa317707d4cfb"],"x":1455,"y":560,"wires":[["6b481701f9c1297f","26bc12977899ca94","0782a2000c24fc48"]]},{"id":"c6ee8b69b8f88b3a","type":"ui_template","z":"412b3e2d021f7a33","d":true,"g":"28317a609d1f9088","group":"f89e1392760d829e","name":"IMG NICK","order":3,"width":6,"height":4,"format":"<div style='width:100%; height:100%; display:flex; justify-content:center; align-items:center;'>\n    <div id='image-container' style='position: relative;'>\n        <img id='image-to-rotate' src='http://pekaway.local/images/van_side' style='width:230px; height:173px; transform: rotate({{msg.deg}}deg);' />\n        <div id='line'\n            style='position: absolute; width: 100%; height: 3px; background-color: grey; top: 96%; transform: translateY(-50%); z-index: 0;'>\n        </div>\n    </div>\n</div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":2930,"y":420,"wires":[[]]},{"id":"1d13fff3ca3e30ad","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"set X Achse","func":"flow.set(\"X_Achse\", msg.payload) \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1470,"y":320,"wires":[[]]},{"id":"8321cefa88554e56","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"set Y Achse","func":"flow.set(\"Y_Achse\", msg.payload) \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1470,"y":400,"wires":[[]]},{"id":"e5db32434873bf02","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"Invert_X-Y","func":"var normal= flow.get(\"X_Achse\");\nvar invert= flow.get(\"Y_Achse\")\nvar umsch = flow.get(\"invert_X-Y\")\n\nif (umsch==false){\n    msg.payload=normal\n}\nif (umsch==true){\n    msg.payload=invert\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1630,"y":320,"wires":[["1bf5ce9417d5b4c5","78d150ddae56107b"]]},{"id":"a9d489fc39a88f63","type":"inject","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"10","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"num","x":930,"y":400,"wires":[["8451a751463042c9"]]},{"id":"058a657c42cb14c0","type":"inject","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"5","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"5","payloadType":"num","x":930,"y":480,"wires":[["63932da30bffb350"]]},{"id":"98fb66ad79c0f7b4","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"Invert_Y-X","func":"var normal= flow.get(\"Y_Achse\");\nvar invert= flow.get(\"X_Achse\")\nvar umsch = flow.get(\"invert_X-Y\")\n\nif (umsch==false){\n    msg.payload=normal\n}\nif (umsch==true){\n    msg.payload=invert\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1620,"y":400,"wires":[["b16b8dc5d8ac537e","e618d524b8fb1a5d"]]},{"id":"0782a2000c24fc48","type":"file in","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","filename":"pekaway/invert_X-Y","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":1620,"y":600,"wires":[["058998d6c8af7c34","bd0426ee910a4d73"]]},{"id":"058998d6c8af7c34","type":"ui_switch","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","label":"Invert_X-Y","tooltip":"","group":"4d2dbbaac32d7d9a","order":10,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"topic","topicType":"msg","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","animate":false,"className":"","x":1810,"y":600,"wires":[["bd0426ee910a4d73"]]},{"id":"bd0426ee910a4d73","type":"function","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"set hinten","func":"flow.set(\"invert_X-Y\", msg.payload) \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1970,"y":600,"wires":[["7ef14a1b10c7def0"]]},{"id":"7ef14a1b10c7def0","type":"file","z":"412b3e2d021f7a33","g":"28317a609d1f9088","name":"","filename":"pekaway/invert_X-Y","filenameType":"str","appendNewline":false,"createDir":true,"overwriteFile":"true","encoding":"none","x":2160,"y":600,"wires":[[]]},{"id":"4d2dbbaac32d7d9a","type":"ui_group","name":"Roll","tab":"44c44161193a7be6","order":2,"disp":false,"width":"6","collapse":false,"className":""},{"id":"f89e1392760d829e","type":"ui_group","name":"NICK","tab":"44c44161193a7be6","order":1,"disp":false,"width":"6","collapse":false,"className":""},{"id":"44c44161193a7be6","type":"ui_tab","name":"Position Sensor","icon":"fa-arrows","order":6,"disabled":false,"hidden":false}]

@Vincent ist vieleicht was für das nächste Update
Gruß
Arno

2 Likes

Hallo

Gibt es evtl. Eine kleine Anleitung um bei dem Lagessensor das Standard Bild gegen ein eigenes Bild zu ersetzen.

Gruß michl

Moin Michl
Da gehst du mit einen Programm z.B. FileZilla auf deinen Pi.
Dort findest du im Ordner /home/pi/pekaway/mpu_py/.
2 png Dateien van_side, und van_back.
das sind die Bilder die angezeigt werden.
Am besten umbenenn der alten Dateien, und neue eingefügte Bilder wieder mit van_side.png und van_back.png benennen. (vermutlich musst du mit der Scalierung etwas rumspielen das es passt) Browser Cache löschen fals das alte Bild noch angezeigt wird. (Das Problem hatte ich mit Firefox.)
Gruß Arno

2 Likes

Bis auf ein paar Ausnahmen ( z.b. MPU 6050 ) und evtl. Anpassungen von I2C Adressen usw. , müsste doch die neue SW auch auf dem alten System laufen, oder ?

Ja, bis auf ein paar Ausnahmen läuft die neue Software auch auf dem alten Board. Es sind dann immer noch so gut wie alle Sachen vorhanden, werden aber deaktiviert in Node-RED, sodass man relativ einfach die Funktionen des alten Boards wieder übernehmen kann.

ist vieleicht was für das nächste Update Gruß Arno

Hab ich auch auf der Liste stehen, werd da bestimmt einiges von übernehmen :slight_smile:

Dort findest du im Ordner /home/pi/pekaway/mpu_py/.
2 png Dateien van_side, und van_back.

Wenn du im lokalen Netz bist, kannst du diese Bilder dann auch in die App laden.

Die Größen werden in Node-RED selber dann nochmal auf 230x173 Pixel festegelegt, da bedarf es noch etwas Feintuning. In der App werden die Bilder einfach auf eine Höhe von 170px skaliert. In dem Screenshot sieht man auch die Quelle aus der die Bilder geladen werden, über Nginx wird zum entsprechenden Bild geleitet.

Hallo Arno

Ich hatte es jetzt mal mit den Range Nodes Probiert und es geht also ist das für mich passend gewesen.

Noch eine Frage da ich weiter Probieren will wo trage ich die Codes ein die du Generiert hast damit ich auch die Schaltflächen bekomme ?

Gruß Sascha

In node red oben rechts 3 Striche = Menü
Auf importieren klicken kopierten code einfügen. Alles mit okay bestätigen. Dann ist der flow importiert
Viel Spaß :wink:
Gruß Arno

Dank @Maik und @ahtdf funktioniert der Mpu6050 bei mir Prima, euch beiden vielen Dank!

Einziges Problem ist, ich sehe keine Bilder auf der ui Oberfläche. In der App ist der Van, auf der ui sehe ich die Zahlen unten aber ohne Van, ein Platzhalter für das Bild ist zu sehen. Habe ich da etwas übersehen? Habe die Software noch mal neu aufgelegt, keine Änderung.

Moin Mikel,
danke für die Blumen ;-).
was für eine Version hast du denn verbaut??? bist du auf die neue 2.0.0 umgestiegen,
oder hast du noch die Version 1 ???
Gruss Arno

Guten Morgen Arno.
Ich bin auf 2.0 umgestiegen, die Sensoren funktionieren, wenn auch relativ zeitverzögert, in der App und in der UI, aber nur in der App sehe ich ein Bild des Van. Hatte auch schonmal eigens Bild vom Womo drin, aber auch da erscheint es nur in der Connect App.

Achso, das Bild ist im eigenen Womo-wlan nicht zu sehen, Maik hat mich gerade aufmerksam gemacht.

Hallo Mikel,
das hab ich bei Maik auch nicht verstanden, das er im eigenen Wlan das Bild nicht sieht…
ich habe meinen Pi mit Lan Kabel angebunden,
und den Pi als access point mit der Adresse 192.168.4.1 laufen.
Ich bekomme sowol über das W-Lan vom Router, über das W-Lan vom Pi, oder über Lan vom Router die Bilder. Liegt das vielleicht an Einstellungen Nginx Server???
Erklär das doch mal Vincent wie sich daas genau äußert, der hat bestimmt ne Lösung.
Gruß Arno

Ich habe das gerade mal mit VPN ausprobiert.
da sieht es genau so aus. Die Zahlen werden Angezeigt, die Bilder sind Platzhalter :frowning:

Danke fürs testen Arno! Am Nginx Server habe ich nix geändert, wüsste auch gar nicht wie oder was ich da tun könnte. Eben dachte ich es läge an dem noch nicht angelegten remote Zugriff, leider aber auch nicht, nach Aktivierung keine Änderung an den Bildern des Sensors

@Vincent hast du vielleicht eine Idee?

Das liegt daran, dass als Bildquelle in den Templates
src='http://pekaway.local/images/van_side'
angegeben ist.

Damit läuft das über Nginx und Nginx regelt dann die Auslieferung des Bildes. Jetzt wird allerdings das Script in der Template Node im Browser des Gerätes ausgeführt, mit dem ihr auf die Seite zugreift.

Wenn ihr im Access Point seid ist das kein Problem, weil dann automatisch alles über Nginx läuft. Wenn ihr allerdings in einem anderen Netzwerk seid, kommt es drauf an ob pekaway.local gefunden werden kann. Falls nicht, weiß Node-RED nicht woher es das Bild laden soll, bzw. kann die Route nicht finden. Wir müssten also vorher definieren, über welch Route ihr auf das System zugreift und dann in den Template Nodes, die die Bilder laden, dynamisch die Route eintragen.

Folgende Möglichkeit:

[{"id":"fb4b91b9.f38cf","type":"http in","z":"67973ee8.553c3","name":"Capture URL","url":"/capture-url","method":"post","upload":false,"swaggerDoc":"","x":970,"y":4880,"wires":[["5be07ac0b6a8ae2a","1e3b56151cdc225b"]]},{"id":"f75ed21c.9b708","type":"debug","z":"67973ee8.553c3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1410,"y":4880,"wires":[]},{"id":"7020560ec7f8b36c","type":"ui_template","z":"67973ee8.553c3","group":"dcfc4576570aad18","name":"","order":1,"width":0,"height":0,"format":"<script>\n    // Capture the current URL\n    var currentURL = window.location.href;\n\n    // Send the URL to the backend via an HTTP request\n    fetch('/capture-url', {\n        method: 'POST',\n        headers: {\n            'Content-Type': 'application/json'\n        },\n        body: JSON.stringify({ url: currentURL })\n    });\n</script>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"global","className":"","x":1160,"y":4820,"wires":[["f4ea20b5915c1016","7d2c72a25596ee4a"]]},{"id":"f4ea20b5915c1016","type":"debug","z":"67973ee8.553c3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1410,"y":4820,"wires":[]},{"id":"01fcef7f95181191","type":"ui_ui_control","z":"67973ee8.553c3","name":"","events":"connect","x":960,"y":4820,"wires":[["7020560ec7f8b36c"]]},{"id":"5be07ac0b6a8ae2a","type":"function","z":"67973ee8.553c3","name":"set access_url","func":"// Extract the URI from msg.payload\nconst uri = msg.req.headers.host.split(\":\");\n\nmsg.host = uri[0];\nmsg.port = uri[1];\n\nif (msg.host != \"127.0.0.1\") {\n    global.set(\"access_url\", msg.host)\n}\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"url","module":"url"}],"x":1180,"y":4880,"wires":[["f75ed21c.9b708"]]},{"id":"1e3b56151cdc225b","type":"debug","z":"67973ee8.553c3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1150,"y":4920,"wires":[]},{"id":"7d2c72a25596ee4a","type":"function","z":"67973ee8.553c3","name":"access_url","func":"if (msg.socketip == \"127.0.0.1\") {\n    global.set(\"access_url\", \"pekaway.local\")\n}","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1430,"y":4780,"wires":[[]]},{"id":"dcfc4576570aad18","type":"ui_group","name":"Time to Go","tab":"deee53a800de461d","order":1,"disp":true,"width":"6","collapse":true,"className":""},{"id":"deee53a800de461d","type":"ui_tab","name":"Info","icon":"mi-info","order":1,"disabled":false,"hidden":false}]

Über die oberen Nodes prüfen wir bei einer neuen Connection, ob die Socketip (also das System) die 127.0.0.1 (localhost) ist. Ist das der Fall, wissen wir dass das System über Nginx und damit zum Beispiel pekaway.local geladen wurde und erreichbar ist. Ist das nicht der Fall, holen wir uns die IP, die ihr eingegeben habt um das System zu erreichen über die untere HTTP Node. Dann wird die Route (also die IP-Adresse oder pekaway.local) in einer globalen Variable gespeichert.

Danach setzen wir in der Function Node direkt bevor das Bild geladen wird (Flow GPS & MPU6050) die Eigenschaften msg.imgsrc und laden die erfasste Route:

msg.imgsrc = global.get(“access_url”) ? ‘http://’+global.get(“access_url”)+‘/images/van_back’ : ‘http://pekaway.local/images/van_back

(Das in eine Zeile schreiben, wie im Bild)
Wir prüfen zuerst ob in der Variable etwas drinsteht und nehmen dann das als URL, wenn die Variable leer ist nehmen wir pekaway.local. Das obere Bild ist für das Bild der Rückansicht, das untere für das seitliche Bild. Damit greifen wir also immer direkt auf das System zu und Nginx kann uns dann die Bilder ausgeben.

Dann schreiben wir noch schnell die Template Node direkt dahinter um, sodass dort

src=‘{{msg.imgsrc}}’

drinsteht (bei beiden Bildern):

Wenn ihr jetzt die Seite neu ladet, sollte die Variable die passende Route bekommen. Hab das jetzt nicht sonderlich ausführlich getestet, aber könnte ein Lösungsweg sein.

3 Likes

@Vincent
Super Erklärung, da merkt man schon das du dein Handwerk verstehst :sweat_smile::clap: das werde ich morgen mal ausprobieren.
Schönen Feiertag
Gruß Arno