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

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.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.restart()

Restart the engine

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

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_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

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.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 (e.g. sensor:env/temp1, or sensor:env/*)

  • 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)

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 “*”) can have multiple watchers.

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

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

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

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