Deploy Lua Script to Multiple Portals


Hi there, so I have a number of devices doing data acquisition at set intervals at different locations. I’m using the data and doing calculations via lua scripts in loops to continuously generate new datastreams for the portal. What if I want to roll out a new script to multiple portals, or make an edit to a script that is used by all the portals? Is there a functionality on the platform to call for a master script to use?
At the moment when I have a script change, I’m going through each portal, pasting my lua script, making portal unique edits, one by one. It’s not an efficient workflow, and more importantly it’s not scalable.
The flexibility of the lua scripts is convenient for customizing each portal, though am I going about this with the wrong approach by using lua scripts to write new data at set intervals?



Hi @vwyeung,

Thanks for posting!

How complex are the calculations that you are performing? Depending on the number of steps involved you may be able to use a feature called ‘preprocessing’ to do away with your Lua scripts.

“preprocess” is a list of [‘operation’, ‘value’ | ‘ResourceID’] pairs describing operations to be performed on incoming data.
‘operation’ may be “add”, “sub”, “mul”, “div”, “mod”, “gt”, “geq”, “lt”, “leq”, “eq”, “neq”, or “value”
‘value’ is the value to use in the operation.
‘ResourceID’ is a an resource identifier of any resource in this client, will use the value of that resource in this operation.

This array of operations that you can give to a dataport would allow you to combine datapoints and perform supported operations on them in ascending(by index) order.

There isn’t a way to call or hold a master script. But you can certainly create a script that uses our RPC API, or our command line tool called Exoline to update your scripts in a more convenient way.

I am out of time at the moment, and I will update this post with details on how to do either of these things at the soonest time I can.



Hi Martin, thanks for the help.

The calculations are more complex than standard arithmetic. I’ve broken down the relationship into a piecewise function of several parts so probably a script handles this best. I do use this ‘preprocess’ for some of my datastreams when they’re recorded from the device for stuff like converting sensor raw data to its representative value, etc.

I think I would fall under the latter of perhaps needing RPC API or Exoline. I’ve done a quick quick scan through the documents for these two… but I think I’m missing the connection of application - How can one apply it to update the lua scripts?

Thanks for the help!



Sounds like you have the right approach for both preprocessing and post-processing your data. I would recommend to keep doing what you described.


Exoline is a good tool for interacting with resources in the Exosite One Platform. It has some device deployment features that might come in handy for you to update your scripts. The ‘spec’ command can be used to create a specification file of your devices, and then iteratively apply that to other devices in your domain. I would recommend using the web interface to make the update to its Lua script by hand, and then use the spec command to create a local template and apply that template to the other devices in a given domain or portal. Rough usage should look like this:

  • Push your script change to one device.
  • Make a directory to hold your spec file, and in that directory make another dir to hold scripts.
  • Make a spec file of your update device using the --generate option.
  • Using RIDs, --portal, or --domain options roll your update to the other devices.

For more information type $ exo spec --help in your terminal.


Because Exoline is using the RPC API, you should be able to do what it does using a script or something else. The primary procedure that you would probably want to use, would be the update procedure. By encoding your updated Lua script as a string, you could iterate over a collection of RIDs or CIKs to roll out your updates.

Both of these methods will of course restart your scripts.

Let me know if you have questions about how to do this,