I read them already. The problem seemed to be Python3. BUT:
The test script from Python (Hello World) was running from the shell.
Vice versa: The same Pi4, the same Sensehat board, a new Micro-SD card with PiOS Bullseye, the same NR 4.0.3 and again Python3 are running flawlessly!
BTW: My flow is a snake-like demo:
[
{
"id": "1ee6c70d.db7dc9",
"type": "tab",
"label": "4Snakes",
"disabled": false,
"info": ""
},
{
"id": "f11e7cc7.903c18",
"type": "rpi-sensehat in",
"z": "1ee6c70d.db7dc9",
"name": "Joystick",
"motion": false,
"env": false,
"stick": true,
"x": 70,
"y": 200,
"wires": [
[
"7797264.1122758"
]
]
},
{
"id": "64d622a8.6628ec",
"type": "inject",
"z": "1ee6c70d.db7dc9",
"name": "Init",
"repeat": "",
"crontab": "",
"once": true,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 120,
"wires": [
[
"46df4e58.7b521"
]
]
},
{
"id": "46df4e58.7b521",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Variablen 1",
"func": "\nflow.set(\"Spur\",true);\nflow.set(\"Shutdown\",false);\nflow.set(\"Joystick\",true);\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 510,
"y": 120,
"wires": [
[
"1f5eee13.28c082"
]
]
},
{
"id": "9f3c018.ca8d8",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Reset Display",
"func": "return {\n payload: \"*,*,off\"\n\n}\n",
"outputs": 1,
"noerr": 0,
"x": 1020,
"y": 120,
"wires": [
[
"e1d5b8e6.fdc06",
"1c613d46.f07333"
]
]
},
{
"id": "a397b650.2f4b1",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Enter",
"func": "\nvar Pixel = flow.get(\"Pixel\");\nPixel++;\nif (Pixel === 4) { Pixel = 0}\nflow.set(\"Pixel\", Pixel);\n\nmsg.payload = Pixel;\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 610,
"y": 420,
"wires": [
[
"cf3a0b88.e5e2b"
]
]
},
{
"id": "9a487c3.1355a8",
"type": "switch",
"z": "1ee6c70d.db7dc9",
"name": "Taste",
"property": "payload.key",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "ENTER",
"vt": "str"
},
{
"t": "eq",
"v": "UP",
"vt": "str"
},
{
"t": "eq",
"v": "DOWN",
"vt": "str"
},
{
"t": "eq",
"v": "LEFT",
"vt": "str"
},
{
"t": "eq",
"v": "RIGHT",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 5,
"x": 370,
"y": 580,
"wires": [
[
"5a9abf13.16397"
],
[
"a9178747.86ca98"
],
[
"91a34a51.0f5208"
],
[
"9220ea6f.88a3a8"
],
[
"b8c2bb28.fabb58"
]
],
"outputLabels": [
"Enter",
"Up",
"Down",
"Left",
"Right"
]
},
{
"id": "2c663e14.6c29d2",
"type": "switch",
"z": "1ee6c70d.db7dc9",
"name": "Losgelassen",
"property": "payload.state",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "2",
"vt": "str"
},
{
"t": "eq",
"v": "0",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 350,
"y": 200,
"wires": [
[
"1108bc5e.be50b4"
],
[
"9a487c3.1355a8"
]
]
},
{
"id": "a9178747.86ca98",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Up",
"func": "var Pixels = flow.get(\"Pixels\");\nvar Pixel = flow.get(\"Pixel\");\n\nif (Pixels.Pix[Pixel].y > 0)\n {\n Pixels.Pix[Pixel].y--;\n flow.set(\"Pixels\", Pixels);\n }\n\nflow.set(\"Shutdown\",false);\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 530,
"y": 560,
"wires": [
[
"868106d9.88e6"
]
]
},
{
"id": "868106d9.88e6",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Matrix",
"func": "var Pixels = flow.get(\"Pixels\");\n\n// Einzelpixel:\nvar coll =\"*,*,off,\"\n\nif (flow.get(\"Spur\"))\n{\n//Pixelspur:\ncoll =\"\"\n}\n\nfor (let i = 0; i < 4; i++) {\n coll = coll + Pixels.Pix[i].x+\",\";\n coll = coll + Pixels.Pix[i].y+\",\";\n coll = coll + Pixels.Pix[i].farbe+\",\";\n \n}\n\nmsg.payload = coll.substring(0, coll.length-1);\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 930,
"y": 640,
"wires": [
[
"e1d5b8e6.fdc06",
"7afbdd39.bf67c4"
]
]
},
{
"id": "e1d5b8e6.fdc06",
"type": "rpi-sensehat out",
"z": "1ee6c70d.db7dc9",
"name": "",
"x": 1250,
"y": 460,
"wires": []
},
{
"id": "cf3a0b88.e5e2b",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Matrix white",
"func": "var Pixels = flow.get(\"Pixels\");\n\nvar Pixel = flow.get(\"Pixel\");\n\n// Einzelpixel:\nvar coll =\"*,*,off,\"\n\nif (flow.get(\"Spur\"))\n{\n//Pixelspur:\ncoll =\"\"\n}\n\n\nfor (let i = 0; i < 4; i++) {\n coll = coll + Pixels.Pix[i].x+\",\";\n coll = coll + Pixels.Pix[i].y+\",\";\n if (Pixel === i) {\n coll = coll + \"white,\";\n } else\n {\n coll = coll + Pixels.Pix[i].farbe+\",\";\n } \n}\n\nmsg.payload = coll.substring(0, coll.length-1);\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 970,
"y": 420,
"wires": [
[
"8e87a570.b1505",
"e1d5b8e6.fdc06"
]
]
},
{
"id": "8e87a570.b1505",
"type": "delay",
"z": "1ee6c70d.db7dc9",
"name": "500 Msek",
"pauseType": "delay",
"timeout": "500",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"outputs": 1,
"x": 960,
"y": 540,
"wires": [
[
"868106d9.88e6"
]
],
"info": "Solange bleibt der aktive Pixel weiß, bis er wieder die ursprüngliche Farbe erhält.\n"
},
{
"id": "91a34a51.0f5208",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Down",
"func": "var Pixels = flow.get(\"Pixels\");\nvar Pixel = flow.get(\"Pixel\");\n\nif (Pixels.Pix[Pixel].y < 7)\n {\n Pixels.Pix[Pixel].y++;\n flow.set(\"Pixels\", Pixels);\n }\n\nflow.set(\"Shutdown\",false);\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 530,
"y": 600,
"wires": [
[
"868106d9.88e6"
]
]
},
{
"id": "9220ea6f.88a3a8",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Left",
"func": "var Pixels = flow.get(\"Pixels\");\nvar Pixel = flow.get(\"Pixel\");\n\nif (Pixels.Pix[Pixel].x > 0)\n {\n Pixels.Pix[Pixel].x--;\n flow.set(\"Pixels\", Pixels);\n }\n\nflow.set(\"Shutdown\",false);\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 530,
"y": 640,
"wires": [
[
"868106d9.88e6"
]
]
},
{
"id": "b8c2bb28.fabb58",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Right",
"func": "var Pixels = flow.get(\"Pixels\");\nvar Pixel = flow.get(\"Pixel\");\n\nif (Pixels.Pix[Pixel].x < 7)\n {\n Pixels.Pix[Pixel].x++;\n flow.set(\"Pixels\", Pixels);\n }\n\nflow.set(\"Shutdown\",false);\n\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 530,
"y": 680,
"wires": [
[
"868106d9.88e6"
]
]
},
{
"id": "1108bc5e.be50b4",
"type": "switch",
"z": "1ee6c70d.db7dc9",
"name": "lang Taste",
"property": "payload.key",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "ENTER",
"vt": "str"
},
{
"t": "eq",
"v": "UP",
"vt": "str"
},
{
"t": "eq",
"v": "DOWN",
"vt": "str"
},
{
"t": "eq",
"v": "LEFT",
"vt": "str"
},
{
"t": "eq",
"v": "RIGHT",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 5,
"x": 570,
"y": 220,
"wires": [
[
"46df4e58.7b521"
],
[
"1d7b9b2c.83e99d"
],
[
"1f5eee13.28c082",
"54037e1f.7a5c"
],
[
"1d1d137e.25e085"
],
[]
],
"outputLabels": [
"Enter",
"Up",
"Down",
"Left",
"Right"
]
},
{
"id": "3f90715a.600436",
"type": "comment",
"z": "1ee6c70d.db7dc9",
"name": "4Snakes V 0.97 / 07.10.2024)",
"info": "** Steuere 4 farbige Schlangen auf dem Sense Hat! **\n\nDurch kurzes Drücken von Enter wählt man den aktiven Pixel aus. Dieser wird kurz weiß.\nDurch die Bewegungen des Joysticks wird der aktive Pixel gesteuert.\nDurch langes Drücken von Enter wird das Display zurück gesetzt.\nDurch langes Drücken von Up wird die Spur umgeschaltet.\nDurch langes Drücken von links wird die Bedienung zwischen Joystick und Bewegungssensor umgeschaltet.\n\nDurch langes Drücken von Down wird nach erneutem kurzen Druck von Enter der Pi herunter gefahren.\n\n** move 4 colored snakes on the Sense Hat! **\n\nshort press Enter: select the pixel, which turns white for a fraction of a second.\njoystick: move the pixel\nlong press Enter: resets the Display\nlong press up: enable/disable a trail\nlong press down + short press Enter: shutdown the Raspi\nlong press left: switch between joystick and motion sensor\n\n_(c) 2020-2024 Stefan Braunstein, stefan@braunstein.de_\n",
"x": 170,
"y": 60,
"wires": []
},
{
"id": "1d7b9b2c.83e99d",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Spurwechsel",
"func": "\nif (flow.get(\"Spur\"))\n{\n flow.set(\"Spur\",false)\n}\nelse\n{\n flow.set(\"Spur\",true)\n}\n\nmsg.payload = flow.get(\"Spur\");\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 830,
"y": 200,
"wires": [
[
"1f5eee13.28c082"
]
]
},
{
"id": "1f5eee13.28c082",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Variablen 2",
"func": "var Pixels = { \n Pix: [\n { x: 0, y: 0, farbe: \"red\" },\n { x: 0, y: 7, farbe: \"green\"},\n { x: 7, y: 7, farbe: \"blue\"},\n { x: 7, y: 0, farbe: \"yellow\"}\n ]\n}\n\nflow.set(\"Pixels\",Pixels);\nflow.set(\"Pixel\",1);\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 810,
"y": 120,
"wires": [
[
"9f3c018.ca8d8"
]
]
},
{
"id": "1c613d46.f07333",
"type": "delay",
"z": "1ee6c70d.db7dc9",
"name": "100 Msek",
"pauseType": "delay",
"timeout": "100",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"outputs": 1,
"x": 1220,
"y": 120,
"wires": [
[
"cf3a0b88.e5e2b"
]
]
},
{
"id": "7797264.1122758",
"type": "rbe",
"z": "1ee6c70d.db7dc9",
"name": "",
"func": "rbe",
"gap": "",
"start": "",
"inout": "out",
"property": "payload",
"x": 210,
"y": 200,
"wires": [
[
"2c663e14.6c29d2"
]
]
},
{
"id": "7249dfd2.5af27",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Matrix off",
"func": "\nflow.set(\"Spur\",false);\n\nvar Pixels = flow.get(\"Pixels\");\n\nPixels.Pix[0].x++;\nPixels.Pix[0].y++;\nPixels.Pix[1].x++;\nPixels.Pix[1].y--;\nPixels.Pix[2].x--;\nPixels.Pix[2].y--;\nPixels.Pix[3].x--;\nPixels.Pix[3].y++;\n\nflow.set(\"Pixels\", Pixels);\n\n\nflow.set(\"Shutdown\",true);\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 1160,
"y": 760,
"wires": [
[
"868106d9.88e6"
]
]
},
{
"id": "69f7afc0.523a38",
"type": "delay",
"z": "1ee6c70d.db7dc9",
"name": "",
"pauseType": "delay",
"timeout": "500",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"outputs": 1,
"x": 720,
"y": 760,
"wires": [
[
"7249dfd2.5af27"
]
]
},
{
"id": "1716c070.44dcd",
"type": "debug",
"z": "1ee6c70d.db7dc9",
"name": "",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"x": 1270,
"y": 640,
"wires": []
},
{
"id": "93066940.1c329",
"type": "delay",
"z": "1ee6c70d.db7dc9",
"name": "",
"pauseType": "delay",
"timeout": "750",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"outputs": 1,
"x": 720,
"y": 820,
"wires": [
[
"7249dfd2.5af27"
]
]
},
{
"id": "588ae072.5a16c8",
"type": "delay",
"z": "1ee6c70d.db7dc9",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"outputs": 1,
"x": 700,
"y": 880,
"wires": [
[
"7249dfd2.5af27"
]
]
},
{
"id": "54037e1f.7a5c",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Reset Pixels",
"func": "var Pixels = { \n Pix: [\n { x: 0, y: 0, farbe: \"red\" },\n { x: 0, y: 7, farbe: \"green\"},\n { x: 7, y: 7, farbe: \"blue\"},\n { x: 7, y: 0, farbe: \"yellow\"}\n ]\n}\n\nflow.set(\"Pixels\",Pixels);\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 790,
"y": 320,
"wires": [
[
"69f7afc0.523a38",
"93066940.1c329",
"588ae072.5a16c8"
]
]
},
{
"id": "5a9abf13.16397",
"type": "switch",
"z": "1ee6c70d.db7dc9",
"name": "",
"property": "Shutdown",
"propertyType": "flow",
"rules": [
{
"t": "false"
},
{
"t": "true"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 450,
"y": 460,
"wires": [
[
"a397b650.2f4b1"
],
[
"99773fdc.a4a4a",
"fe8eb4d0.41144"
]
]
},
{
"id": "37a842ab.2647b6",
"type": "exec",
"z": "1ee6c70d.db7dc9",
"command": "sudo",
"addpay": false,
"append": "init 0",
"useSpawn": "false",
"timer": "",
"winHide": false,
"oldrc": false,
"name": "Shutdown",
"x": 1220,
"y": 840,
"wires": [
[],
[],
[]
]
},
{
"id": "fe8eb4d0.41144",
"type": "delay",
"z": "1ee6c70d.db7dc9",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"outputs": 1,
"x": 1040,
"y": 840,
"wires": [
[
"37a842ab.2647b6"
]
]
},
{
"id": "99773fdc.a4a4a",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Reset Display",
"func": "return {\n payload: \"*,*,off\"\n\n}\n",
"outputs": 1,
"noerr": 0,
"x": 640,
"y": 460,
"wires": [
[
"e1d5b8e6.fdc06"
]
]
},
{
"id": "7bfb2244.9418cc",
"type": "rpi-sensehat in",
"z": "1ee6c70d.db7dc9",
"name": "Gyroskop",
"motion": true,
"env": false,
"stick": false,
"x": 80,
"y": 300,
"wires": [
[
"4095335d.a98e84",
"dc479121.0600c"
]
]
},
{
"id": "4095335d.a98e84",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Roll",
"func": "var taste = \"\";\nvar mm = {\n \"payload\": {\n \"key\": \"\"\n }\n}\n\nif (msg.payload.orientation.roll <340 && msg.payload.orientation.roll >310)\n{taste = \"UP\";}\n\nif (msg.payload.orientation.roll <50 && msg.payload.orientation.roll >20)\n{taste = \"DOWN\";}\n\nmm.payload.key = taste;\n\nif (taste === \"\" || flow.get(\"Joystick\") === true )\n{return [null,mm];}\nelse\n{return [mm,null];}\n\n",
"outputs": 2,
"noerr": 0,
"x": 270,
"y": 320,
"wires": [
[
"77fd816d.0ae62"
],
[]
]
},
{
"id": "dc479121.0600c",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Pitch",
"func": "var taste = \"\";\nvar mm = {\n \"payload\": {\n \"key\": \"\"\n }\n}\n\nif (msg.payload.orientation.pitch <340 && msg.payload.orientation.pitch >310)\n{taste = \"RIGHT\";}\n\nif (msg.payload.orientation.pitch <40 && msg.payload.orientation.pitch >10)\n{taste = \"LEFT\";}\n\nmm.payload.key = taste;\n\nif (taste === \"\" || flow.get(\"Joystick\") === true)\n{return [null,mm];}\nelse\n{return [mm,null];}\n\n",
"outputs": 2,
"noerr": 0,
"x": 270,
"y": 280,
"wires": [
[
"77fd816d.0ae62"
],
[]
]
},
{
"id": "77fd816d.0ae62",
"type": "delay",
"z": "1ee6c70d.db7dc9",
"name": "",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "3",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"outputs": 1,
"x": 190,
"y": 580,
"wires": [
[
"9a487c3.1355a8"
]
]
},
{
"id": "1d1d137e.25e085",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "Joystickwechsel",
"func": "if (flow.get(\"Joystick\"))\n{\n flow.set(\"Joystick\",false)\n}\nelse\n{\n flow.set(\"Joystick\",true)\n}\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 840,
"y": 240,
"wires": [
[
"1f5eee13.28c082"
]
]
},
{
"id": "7afbdd39.bf67c4",
"type": "function",
"z": "1ee6c70d.db7dc9",
"name": "",
"func": "\n\nmsg.payload = flow.get(\"Joystick\");\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 1090,
"y": 640,
"wires": [
[
"1716c070.44dcd"
]
]
}
]