API reference

WebEngine

Eva.action.exec(oid, params, wait)

Call unit action

Arguments
  • oid (string()) – unit OID

  • params (object()) – action params

  • wait (boolean()) – wait until the action is completed (default: true)

Async

Async function/Promise

Eva.action.kill(oid)

Terminate all unit actions

Arguments
  • oid (string()) – unit OID

Async

Async function/Promise

Eva.action.run(oid, params, wait)

Run lmacro

Arguments
  • oid (string()) – lmacro oid

  • params (object()) – call params

  • wait (boolean()) – wait until completed (default: true)

Async

Async function/Promise

Eva.action.start(oid, wait)

Call unit action with value=1

Arguments
  • oid (string()) – unit OID

  • wait (boolean()) – wait until the action is completed (default: true)

Async

Async function/Promise

Eva.action.stop(oid, wait)

Call unit action with value=0

Arguments
  • oid (string()) – unit OID

  • wait (boolean()) – wait until the action is completed (default: true)

Async

Async function/Promise

Eva.action.terminate(uuid)

Terminate a unit action

Arguments
  • uuid (string()) – action uuid

Async

Async function/Promise

Eva.action.toggle(oid, wait)

Call unit action to toggle its value

Arguments
  • oid (string()) – unit OID

  • wait (boolean()) – wait until the action is completed (default: true)

Async

Async function/Promise

Eva.call(method, p1, p2)

Call API function

Calls any available SFA API function

Arguments
  • method (string()) – API method

  • p1 (object()) – call parameters. if specified as a string/object, transformed to i=val

  • p2 (object()) – additional call parameters if p1 is a string

Returns

Promise object

Async

Async function/Promise

Eva.clear_auth()

Clear engine authenication credentials

Erase auth token cookie

It is recommended to call this function when login form is displayed to prevent old token caching

Eva.get_mode()

Get engine mode

Returns

“js” or “wasm”

Eva.is_auth_set()

Is engine authentication set

Returns

true if auth is set

Eva.is_password_set()

Is engine password set

Returns

true if password is set

Eva.load_config(config_path)

Load JSON configuration

Arguments
  • config_path (string()) – config path (default: config.json)

Returns

Promise object

Async

Async function/Promise

Eva.log_start(log_level)

Start log processing

Starts log processing. The engine must be already logged in.

Arguments
  • log_level (number()) – log processing level (optional)

Eva.lvar.clear(oid)

Clear lvar (set status to 0)

Arguments
  • oid (string()) – lvar oid

Async

Async function/Promise

Eva.lvar.decr(oid)

Decrement lvar value

Arguments
  • oid (string()) – lvar oid

Returns

the new value

Async

Async function/Promise

Eva.lvar.expires(lvar_oid)

Get lvar expiration time left

Arguments
  • lvar_oid (string()) – lvar OID

Returns

seconds to expiration, -1 if expired, -2 if stopped

Eva.lvar.incr(oid)

Increment lvar value

Arguments
  • oid (string()) – lvar oid

Returns

the new value

Async

Async function/Promise

Eva.lvar.reset(oid)

Reset lvar (set status to 1)

Arguments
  • oid (string()) – lvar oid

Async

Async function/Promise

Eva.lvar.set(oid, status, value)

Set lvar state

Arguments
  • oid (string()) – lvar oid

  • status (numberr()) – lvar status

  • value – lvar value

Async

Async function/Promise

Eva.lvar.set_status(oid, status)

Set lvar status

Arguments
  • oid (string()) – lvar oid

  • status (number()) – lvar status

Async

Async function/Promise

Eva.lvar.set_value(oid, value)

Set lvar value

Arguments
  • oid (string()) – lvar oid

  • value – lvar value

Async

Async function/Promise

Eva.lvar.toggle(oid)

Toggle lvar status

Arguments
  • oid (string()) – lvar oid

Async

Async function/Promise

Eva.on(event, func)

Set event handler function

A single kind of event can have a single handler only

Arguments
  • event (EventKind()) – engine event kind

  • func (function()) – function called on event

Eva.register_globals()

Registers the global object window.$eva

Eva.register_legacy_globals()

Registers global objects + legacy globals

Eva.register_state_block(name, state_updates)

Register a state block

Arguments
  • name (string()) – block name

  • state_updates (boolean or Array.) – state updates

Eva.restart()

Restart the engine

e.g. used on heartbeat error or if subscription parameters are changed

Eva.set_api_key(apikey)

Set/clear engine API key

Arguments
  • apikey (string or null()) – API key

Eva.set_interval(interval_id, value)

Set intervals

Arguments
  • interval_id (IntervalKind()) – interval kind

  • value (number()) – interval value (in seconds)

Eva.set_log_level(log_level)

Change log processing level

Arguments
  • log_level (number()) – log processing level

Eva.set_login_password(login, password)

Set engine login credentials

Arguments
  • login (string or null()) – login

  • password (string or null()) – password

Eva.set_normal(user, password, xopts)

Ask server to return the token to normal mode

(EVA ICS 3.3.2+)

Arguments
  • u (string()) – login

  • p (string()) – password

  • xopts (object()) – extra options (e.g. OTP)

Async

Async function/Promise

Eva.set_readonly()

Ask server to set the token read-only (e.g. after idle)

(EVA ICS 3.3.2+)

the current mode can be obtained from $eva.server_info.aci.token_mode

Async

Async function/Promise

Eva.set_state_updates(state_updates, clear_existing)

Set state updates without restart required

Arguments
  • state_updates (boolean()) – true/false or a string array

  • clear_existing (boolean()) – clear existing states

Async

Async function/Promise

Eva.sleep(sec)

Sleep the number of seconds

Arguments
  • sec (number()) – seconds to sleep

Async

Async function/Promise

Eva.start()

Start the engine

After calling the function authenticates user, opens a WebSocket (in case of WS mode) or schedule AJAXs refresh interval.

Eva.state(oid)

Get item state

Arguments
  • oid (string()) – item OID or OID mask

Returns

state object or undefined if no item found

Eva.status(oid)

Get item status

Arguments
  • oid (string()) – item OID

Returns

item status(int) or undefined if no object found

Eva.stop(keep_auth)

Stop the engine

After calling the function closes open WebSocket if available, stops all workers then tries to close the server session

Arguments
  • keep_auth (boolean()) – keep authentication cookies and token

Returns

Promise object

Async

Async function/Promise

Eva.system_name()

Get system name

Returns

the system name or null if the engine is not logged in

Eva.unregister_state_block(name)

Unregister a state block

Arguments
  • name (string()) – block name

Eva.unwatch(oid, func)

Stop watching item state updates

If item oid or function is not specified, all watching functions are removed for a single oid (mask) or for all the items watched.

Arguments
  • oid (string()) – item OID or a mask

  • func (function()) – function to be removed

Eva.value(oid)

Get item value

Arguments
  • oid (string()) – item OID

Returns

item value or undefined if no item found

Eva.watch(oid, func, ignore_initial, prot)

Watch item state updates

Registers the function to be called in case of state change event (or at first state load).

If state is already loaded, function will be called immediately. One item (or item mask, set with “*” or a traditional OID mask) can have multiple watchers.

Arguments
  • oid (string()) – item oid (e.g. sensor:env/temp1, sensor:env/*, sensor:+/temp1)

  • func (function()) – function to be called

  • ignore_initial (boolean()) – skip initial state callback

  • prot (boolean()) – protected (not removed on global unwatch)

Eva.watch_action(uuid, func)

Watch action state by uuid

Registers the function to be called in case of action status change event (or at first state load).

If status is already loaded, function will be called immediately. Otherwise status is polled from the server with “action_watch” interval (default: 500ms).

There is no unwatch function as watching is stopped as soon as the action is completed (or server error is occurred)

Arguments
  • uuid (string()) – action uuid

  • func (function()) – function to be called

disableTabFreeze(keep_visible)

Disable tab freeze

Arguments
  • keep_visible (boolean()) – keep special elements visible