Hi everyone,
I have a python script running on the raspberry pi and I want certain code parts to only be executed if the value true comes from a Node Red Flow.
Red Node is already running on the raspberry pi
Does anyone have any tips on the easiest way to do this?
STDIN. Eg the running app is sitting there waiting for some keyboard input. When you run it normally from the command line. How do you tell it what to do (while it is running)?
The program monitors the cat flap and requires no user or keyboard actions.
At the moment the program continuously takes pictures that are checked in a Tflite model.
Now I would like to trigger the check via an external motion detector (no Pi Sensor) so that the program does not have to check every meaningless image.
Hence the idea of ​​using Red Node to send movement information to the program
@dceejay's suggestion was to use node-red-node-daemon
If you want to try this, you have to install the node via Manage Palette.
Whether you pick the daemon node, MQTT or some other option (for example named pipes), your Python script will most likely need modifying so that it listens for messages and responds when it receives one.
I think the usual approach to do this in Python is by a "callback", but that's ouside the scope of a Node-red forum.
There are several posting around on the forum with examples demonstrating this all in a python script using MQTT. To find it is sometimes like looking for a needle in a haystack but a search may be successful
Your python script has to "subscribe" to the message topic at the mosquito broker.
Node-red "publishes" to the same topic.
To find an example python program Google for "python mqtt callback"
A callback is the mechanism which allows the script to perform specific processing when a certain event occurs.