Lifecycle
Signal the end of a run and classify failures.
D.errorType
Section titled “D.errorType”Known Domotz Context Error types. Pass one of these as the argument to D.failure(...) so the portal can classify the failure in dashboards.
Signature
D.errorTypeProperties
RESOURCE_UNAVAILABLE· `string`- Device unreachable, endpoint times out, DNS resolution fails.
AUTHENTICATION_ERROR· `string`- Credentials rejected (HTTP 401/403, bad SSH key, wrong SNMP community).
PARSING_ERROR· `string`- Response returned but its structure is not what the driver expects.
TIMEOUT_ERROR· `string`- Operation took longer than its configured timeout.
MISSING_DEVICE_ERROR· `string`- The target device is no longer in the collector's managed set.
IMPORT_NOT_ALLOWED· `string`- Driver tried to `import` — sandbox forbids it.
REQUIRE_NOT_ALLOWED· `string`- Driver tried to `require` — sandbox forbids it.
METRIC_VALIDATION_ERROR· `string`- A metric payload failed validation (bad UID, wrong value type, …).
TABLE_VALIDATION_ERROR· `string`- A table payload failed validation (missing column, bad row UID, …).
GENERIC_ERROR· `string`- None of the above fit. Prefer one of the specific types when possible.
Returns
object— A map of error-type constants, passed toD.failure(...).
Example
D.failure(D.errorType.AUTHENTICATION_ERROR)D.failure
Section titled “D.failure”Failure callback in D (D.failure). It can be present in any function in order to indicate a failure in the execution
Signature
D.failure([errorType])Parameters
errorType· `ErrorType` · optional- The type of error that caused the failure callback. Must be a member of D.errorType
Returns
void
Example
D.failure(D.errorType.AUTHENTICATION_ERROR)D.success
Section titled “D.success”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
Signature
D.success([metrics], [table])Parameters
metrics· `Array.<(Variable|Metric)>` · optional- The metrics to return (dry run) or store
table· `Table` · optional- The custom driver table to return (dry run) or store
Returns
void
Example
D.success()D.success(table)D.success(variables)D.success(metrics)D.success(variables, table)D.success (backup / restore)
Section titled “D.success (backup / restore)”Success callback in D (D.success). It must be present in the validate and backup functions (or their callbacks) in order to indicate their successful execution
Signature
D.success([configuration])Parameters
configuration· `ConfigurationBackup` · optional- The configuration to return (dry run) or store for backup
Returns
void
Example
D.success()D.success(configuration)D.valueType
Section titled “D.valueType”Domotz Variable Value Types. Pass one of these as the last argument to D.createVariable(...) / D.createMetric(...) so the portal knows how to render and chart the value.
Signature
D.valueTypeProperties
STRING· `string`- Free-form text. Portal renders as a text field.
NUMBER· `string`- Numeric scalar. Portal renders as a chart.
DATETIME· `string`- ISO-8601 timestamp.
RATE· `string`- Per-second rate computed from consecutive samples.
MONOTONE_RATE· `string`- Per-second rate from a strictly-increasing counter (wraps/resets handled for you).
Returns
object— A map of value-type constants, passed toD.createVariable(...).
Example
D.createVariable('1a', 'CPU Temp', 60, 'C', D.valueType.NUMBER)