# Script Engine

The script engine gives you the ability to edit data in Eliona using Python and SQL scripts.

The special thing about scripts is that scripts are applied repeatedly and at regular intervals to the data.

{% hint style="info" %}
For simple data manipulations, e.g. adding values, the ↗ Calculator can be used.
{% endhint %}

## Application scenarios

Here are some typical and advanced use cases in which scripts can be used effectively:

* #### Evaluate and reset counters

  Counters, such as people counters, must be reset regularly to ensure accurate values. Scripts can be programmed to automatically reset these counters at specified times.
* #### Determine maximum values

  Scripts can be used to determine the highest value from a series of values and highlight it or process it further.
* #### Machine learning models and predictions

  An advanced use case involves the integration of machine learning models. Scripts can be used to make predictions based on historical data, perform optimizations, or identify correlations between different datasets.
* #### Processing attachments

  Scripts can be programmed to automatically scan attachments when they are uploaded and write the extracted data directly into the corresponding asset.
* #### Plausibility checks

  Another application is the plausibility check of data. A script can verify whether the data lies within certain limits. If the data is plausible, the value 0 is set; otherwise 1.

## Accepted languages

Scripts can be written in *Python* or *SQL* written.

## Open script overview

<div data-full-width="true"><figure><img src="https://content.gitbook.com/content/Nyvwhz1kEMXcHf4HLuZ8/blobs/imImeb474XcgH2XZECYj/Docs%20ScriptEngine%201.png" alt=""><figcaption></figcaption></figure></div>

1. Click on **Engineering** **\[A]**
2. Click on **Script Engine** **\[B]** \
   ▷The script overview opens

{% hint style="info" %}
Eliona comes with built-in scripts, known as *system scripts*.&#x20;

These scripts are exclusively visible to [system owner](https://docs.buildings.ability.abb/collection/english-v14/roles#systemrollen) .&#x20;

For all other users, these system scripts do not appear in the script overview. System scripts can be recognized by the fact that the edit option **\[Q]** is greyed out and not available.
{% endhint %}

### Details

In the script engine, you have the following options:

<table data-full-width="true"><thead><tr><th>Element</th><th>Title</th><th>Details</th></tr></thead><tbody><tr><td><strong>[C]</strong></td><td>Scripts section</td><td>Shows an overview of all scripts already created</td></tr><tr><td><strong>[D]</strong></td><td>Search</td><td>Opens the “Search” sidebar. There you can search specifically for individual scripts</td></tr><tr><td><strong>[E]</strong></td><td>Create new script</td><td>Click to create a new script</td></tr><tr><td><strong>[F]</strong></td><td>Pause/activate script</td><td>Click to pause a running script or reactivate a paused script</td></tr><tr><td><strong>[G]</strong></td><td>Script status</td><td>Shows whether a script is activated (“Active”) or paused (“Inactive”)</td></tr><tr><td><strong>[H]</strong></td><td>Name</td><td>Shows the name of the script. The name of the script is assigned by the user when the script is created. The name can be changed later.</td></tr><tr><td><strong>[I]</strong></td><td>Shows the description of the script.</td><td>The designation of the script is assigned by the user when they create the script. The name can be changed later.</td></tr><tr><td><strong>[J]</strong></td><td>Type</td><td>Shows whether the script was created in SQL or Python.</td></tr><tr><td><strong>[K]</strong></td><td>errors</td><td>Indicates whether there are errors in the script</td></tr><tr><td><strong>[L]</strong></td><td>Repeat</td><td>Shows the <a href="configure-scripts#raster">↗ grid</a> that was selected for this script.</td></tr><tr><td><strong>[M]</strong></td><td>Last run</td><td>Shows when the script ran last.</td></tr><tr><td><strong>[N]</strong></td><td>Next run</td><td>Shows when the script will run next.</td></tr><tr><td><strong>[O]</strong></td><td>Duration</td><td>Shows how long the last run took.</td></tr><tr><td><strong>[P]</strong></td><td>Delete</td><td>Delete the selected script.</td></tr><tr><td><strong>[Q]</strong></td><td>Edit</td><td>Click to edit the script. Opens the menu <a href="script-engine/configure-scripts">↗ Configure script</a> page.</td></tr><tr><td><strong>[R]</strong></td><td>errors</td><td>Indicates that there is an error with the script.</td></tr></tbody></table>

## Create new script

1. Open the script overview as in [↗ Open script overview](#skript-uebersicht-oeffnen) described
2. Click on **\[E]** \
   ▷ The window **\[S]** opens
3. Give the script a name in field **\[T]** .\
   ◈ This name will later appear in field **\[H]** displayed
4. Select in field **\[U]**&#x77;hether the script is written in Python or SQL
5. Click on **\[V]**, to create the script \
   ▷The “Configure script” menu opens
6. Continue as in chapter [↗ Configure scripts](https://docs.buildings.ability.abb/collection/english-v14/documentation/engineering/script-engine/configure-scripts) described
