Namespace: D

D

The Domotz Context Library Used for accessing the domotz context within a custom driver. Exposes the device namespace for any device related operations, utility libraries and driver callbacks

Namespaces

_unsafe
crypto
device
math

Members

(static, readonly) errorType :ErrorType

Known Domotz Context Error types
Type:
Example
D.errorType.AUTHENTICATION_ERROR

(static, readonly) valueType :ValueType

Domotz Variable Value Types
Type:
Example
D.valueType.MONOTONE_RATE

Methods

(static) createExternalDevice(deviceHost, deviceCredentialsopt) → {device}

Creates an External IP device object
Parameters:
Name Type Attributes Description
deviceHost string The IP or Hostname of the external device
deviceCredentials DeviceCredentials <optional>
The credentials for the external device
Returns:
- The External Device object
Type
device
Example
D.createExternalDevice("1.1.1.1", {"username": "root", "password": D.device.password()})

(static) createTable(label, columnHeaders) → {driverTable}

Creates a driver table for variable values visualization in a table format
Parameters:
Name Type Description
label string The Table Label
columnHeaders Array.<ColumnHeader> The List of column header definitions
Returns:
- The Custom Driver Table object
Type
driverTable
Example
D.createTable("My Table", [{"label": "Column A"}, {"label": "Column B", "unit": "%"}])

(static) createVariable(uid, name, value, unit, valueType) → {Variable}

Creates a custom driver variable to be sent in the D.success callback.
This variable is suited for tracking a single key-value pair, if you want to track tabular data, use D.createTable instead.
Parameters:
Name Type Description
uid string The identifier of the variable. Must be Unique. Max 50 characters
cannot be one of the following reserved words: "table", "column", "history"
name string The Name/Label of the variable. Max 100 characters
value string The Value of the variable. Max 500 characters
unit string The Unit of measurement of the variable (eg %). Max 10 characters
valueType ValueType The value type of the variable (used for display purposes)
Returns:
Type
Variable
Example
// returns {"uid": "1a", "unit": "C", "value": 60, "label": "CPU Temperature"}
D.createVariable('1a', 'CPU Temperature', 60, 'C', D.valueType.NUMBER)

(static) failure(errorTypeopt)

Failure callback in D (D.failure). It can be present in validate, get_status or all custom action functions code (or their callbacks) in order to indicate a failure in the execution
Parameters:
Name Type Attributes Description
errorType ErrorType <optional>
The type of error that caused the failure callback. Must be a member of D.errorType
Example
D.failure(D.errorType.AUTHENTICATION_ERROR)

(static) getParameter(parameterName) → {string|number|Object|undefined}

Get a predefined parameter during execution by its name. Returns undefined in case the parameter was not provided to the context.
Parameters:
Name Type Description
parameterName string Name of the parameter to get
Returns:
- the value associated with the provided parameter name
Type
string | number | Object | undefined
Example
D.getParameter("name")

(static) htmlParse(content, optionsopt, isDocumentopt) → {CheerioAPI}

Html Parser Library
Parameters:
Name Type Attributes Default Description
content string | Node | Array.<Node> | Buffer Markup to be loaded.
options CheerioOptions <optional>
Options for the created instance.
isDocument boolean <optional>
true Allows parser to be switched to fragment mode.
Returns:
- The loaded document
Type
CheerioAPI
Example
D.htmlParse()

(static) success(variablesopt, tableopt)

Success callback in D (D.success). It must be present in validate, get_status or all custom action functions code (or their callbacks) in order to indicate their successful execution
Parameters:
Name Type Attributes Description
variables Array.<Variable> <optional>
The variables to return (dry run) or store
table driverTable <optional>
The custom driver table to return (dry run) or store
Examples
D.success()
D.success(table)
D.success(variables)
D.success(variables, table)