Hello why in python3 function this program run only one time, outside node-red he run as per expected.
rom rpiplc_lib import rpiplc
if valore == 0:
msg['payload'] = True
msg['payload'] = False
in the debug I would expect to get a continuous change between true and false or a continuous false or true, but it runs only once a time for injection then i have to inject it again.
What is wrong?
Well part of the problem is that you didn't actually respond to my question which was about how you are running your Python code. Please take care to respond to forum responses with the information asked because it gets very tiring and difficult for people to help otherwise.
However, inadvertently, you've PARTIALLY shared the information anyway. You are using one of the contributed Python function nodes. But which one? There are at least 2, one of which hasn't been updated for over 3 years.
You probably should either have a final return msg outside the loop or you would use node.send(msg) inside the loop if you wanted to send the output as it arrives.
But then again, you don't normally do an endless loop in a function node since it will probably block your flows (at least it would in a standard function I think).
Hello and thanks for your reply
With the node.send(msg) i never solve, but i use the repeat interval of the inject and i delete the while in the function, i don know if is the best solution but it works
Well, the main point is that the return msg is not doing what you think it is and it does not send a msg because it is returning from the loop not returning from the function node. You either have to use node.send - assuming the Python function node has implemented it - or you need to do another return msg outside the loop at the end.