Scripts

Scripts are Javascript snippets which allow users to define complex logic to customize their Omnyvore configuration.

Scripts section

By clicking on the Scripts button on the sidebar, you will open the Script list view. In this view, you basically have a grimoire of all the Javascript functions available when processing data of any kind of Omnyvore, whether it is a measurement or an alarm.

In the script view you can find a collection of all the scripts available for your organization. To add a new script, click on the Add button in the top-right corner:

When adding a script, you can provide a name and a description for it in order to help you remember the purpose of this snippet. Then, just write the code in the Content text area: the functions you write here will be available . For instance, let us assume you want to define an operation add(a,b) which just performs a sum. In this case, you have to write a simple script:

function add(a,b) {
    return a + b;
}

The add function will then be available in each script you run.

Publishing scripts

Scripts are not included by default in Omnyvore: if you write a piece of code which is not working, you may jeopardize data processing for some amount of time. This is why you have to publish a script before being able to use it throughout your Omnyvore organization. To publish a script, just click on the PUBLISH button in the Script detail view, which can be accessed by clicking on a script in the Script list view. If you instead want to remove a script from the Javascript engine which processes your data, click on the DISABLE button in the Script detail view.

Tip: if a script is not published, it will be denoted as a draft, otherwise its status will be Published. In the former case, you will see only the PUBLISH button, whereas in the latter case you will see only the DISABLE button.

More low-level details on Omnyvore scripts can be found in a dedicated appendix.