How to run Python-scripts on the ctrlX CORE via Node-RED

How can I run/activate a python script via node-red?

With the description above (YARC) it's possible for me. But I tried it with node-red and our ctrlx-datalayer-request node from node-red-contrib-ctrlx-automation. I try the following:

 

 

I did some tests with objects and with string as payload. But I always get the error message:

Any hint's? Thanks.

Additional question...

Do we have to run/activate a python script after every reboot of the control in this way? Or de we provide a mecanism to automaticly run a python script  inside the "active solution"? For me it make no sense to program python scripts, which I have to run/activate with another program/interface (REST, node-red, C++, ...).

 

Best reply by CodeShepherd

First you have to choose the payload as "value + type (json)" because you are trying to handle over an complex data type.

 

Second your payload including the object have to look like this:

 

var newMsg = {};
newMsg.payload = {};
newMsg.payload.value = {"name":"MyInstance3","language":"python"};
newMsg.payload.type = "object";
return newMsg;

 

EDIT:

At the moment script instances are not persistent and so get deleted while a reboot. Also there is no automatism to start and run a script. We are already aware of this topic and are working on it.

See also examples in "node-red-contrib-ctrlx-automation". They can be imported in Node-RED directly:

Node-RED import ctrlX AUTOMATION examples

View original
2 replies