Skip to content

Profinity Scripting

Profinity scripting automates tasks, processes CAN messages and creates custom operations in C#, Python or Lua.

Licence required

Scripting requires the Scripting licensed feature, included in the Desktop, Server, and Enterprise editions. An unlicensed instance cannot add or run scripts. Refer to Licensing for what each edition includes.

Rule actions respond to alerts (Webhook, Slack, MQTT, Email), scripts in Python, Lua, or C# read and write tags like any other component, and Tag Relay links Profinity instances together over HTTPS or MQTT

Rule actions, scripts, and Tag Relay, all built in

Scripts run with the permissions of Profinity

Profinity scripts execute with the same security permissions as Profinity itself

Profinity Scripting runs inside the Profinity engine, so any script executes with the same operating system security permissions as Profinity itself. An administrator must review what each script does before it is enabled.

To keep the Profinity environment secure, scripting is disabled until it is explicitly enabled. To enable Profinity Scripting, open Application Config and turn on Enable Scripting.

Profinity System Configuration page, where the Enable Scripting setting turns scripting on

Profinity System Configuration

Script types

Profinity has five script types, which between them cover seven values of the Script Mode setting:

  • Run scripts cover manual and scheduled operations, in the Run On Demand, Run On Time Interval, and Run On CRON Schedule modes.
  • Receive scripts handle incoming CAN messages, in the Run On Receipt of CAN Message mode.
  • Service scripts run continuously, in the Run as Service mode.
  • Tag change scripts react when a watched tag changes, in the Run On Tag Change mode.
  • Rule scripts handle a rule firing, in the Run On Alert mode.

For each mode and when to use it, refer to Script types. For the rule actions that call a rule script, refer to Rule actions.

Supported languages

A script can be written in C#, Python or Lua, and each language supports the same set of script types (Run, Receive, Service, Tag Change and Rule Script). C# suits complex, type-safe operations, Python suits data handling and quick edits, and Lua suits lightweight scripts. Refer to Supported Languages for the comparison.

Operations

Profinity provides five built-in operations to every script through the Profinity object:

  • CAN bus for CAN communication.
  • DBC for message and signal handling.
  • State for data that survives between runs.
  • Console for output and logging.
  • Tags for reading and writing tag values.

Scripts that belong to a Custom Component can also read and write Component and firmware settings. A script that a Custom Component runs from a firmware action also receives an action context, with the action name, any uploaded file, and progress reporting. For more detail on each, refer to Supported operations.

Next steps

To write and test a script on a developer machine before it is copied into a profile, refer to Test a script outside Profinity. To choose a language, refer to Supported Languages. To choose a script style, refer to Script types. For what a script can do, refer to Supported operations. To build a first script, refer to How to write your first script.