Skip to main content
Version: 1.0

Voltmeter

The Voltmeter component handles the monitoring of device's voltmeter sensors. Voltmeter components are identified with voltmeter:<id> in objects containing multiple component payloads.

The Voltmeter component uses Voltmeter as RPC namespace and implements the minimal component interface:

Methods

Voltmeter.SetConfig

Properties:

PropertyTypeDescription

id

number

Id of the Voltmeter component instance

config

object

Configuration that the method takes

Find more about the config properties in config section

Voltmeter.GetConfig

Properties:

PropertyTypeDescription

id

number

Id of the Voltmeter component instance

Find the Voltmeter.GetConfig response properties in config section

Voltmeter.GetStatus

Properties:

PropertyTypeDescription

id

number

Id of the Voltmeter component instance

Find more about the status response properties in status section

Voltmeter.CheckExpression

Request

PropertyTypeDescription

expr

string

JS expression to evaluate

inputs

array

Input values on which to apply expr. Elements are allowed to be null

Response

results or error if any of the request parameters is missing or of the wrong type

PropertyTypeDescription

results

array

Array of 2-tuples, each containing an input and an output value: [input, output]. Input values are those from the request, but after processing into a number internally and back to string. Outputs are corresponding results of the evaluated expression, and can be null. If the JS interperter fails to parse or evaluate the expression a third element is added to the array, so it becomes [input, output, error message]

Configuration

The configuration of the Voltmeter component allows to adjust the voltage report threshold value. To Get/Set the configuration of the Voltmeter component its id must be specified.

Properties:

PropertyTypeDescription

id

number

Id of the Voltmeter component instance

name

string or null

Name of the Voltmeter instance. name length should not exceed 64 chars

report_thr

number

Voltmeter report threshold in volts. Accepted range is device-specific

range

number

Input range, which is device-specific. See the table below.

xvoltage

object

Value transformation config for status.voltage

PropertyTypeDescription

expr

string or null

JS expression containg x, where x is the raw value to be transformed (status.voltage), for example "x+1". Accepted range: null or [0..100] chars. Both null and "" mean value transformation is disabled.

unit

string or null

Unit of the transformed value (status.xvoltage), for example "m/s". Accepted range: null or [0..20] chars. Both null and "" mean value transformation is disabled.

Valid range values depend of device.

range01
PlusUni0-15VDC (default)0-30VDC

Status

The status of the Voltmeter component represents the measurement of the associated voltmeter sensor. To obtain the status of the Voltmeter component its id must be specified.

PropertyTypeDescription

id

number

Id of the Voltmeter component instance

voltage

number or null

Voltage in volts (null if valid value could not be obtained)

xvoltage

number or null

voltage transformed with config.xvoltage.expr. Present only when both config.xvoltage.expr and config.xvoltage.unit are set to non-empty values. null if config.xvoltage.expr can not be evaluated.

errors

array of type string

Shown only if at least one error is present. May contain out_of_range, read when there is problem reading sensor

Webhook Events

There are two events related to the Voltmeter component that can trigger webhooks:

  • voltmeter.change - produced when voltage delta between two measurements is greater than report_thr
  • voltmeter.measurement - produced on a monotonic measurement period (60s)

voltmeter.change and voltmeter.measurement support two attributes, that can be used to compose conditional webhooks:

PropertyTypeDescription

voltage

number

New voltage

xvoltage

number

voltage transformed with config.xvoltage.expr

Examples

Voltmeter.SetConfig example

http://192.168.33.1/rpc/Voltmeter.SetConfig?id=0&config={"name":"Voltmeter0","report_thr":2.5,"range":0,"xvoltage":{"expr":"x+1","unit":"m/s"}}

Response

{
"restart_required": false
}

Voltmeter.GetConfig example

http://192.168.33.1/rpc/Voltmeter.GetConfig?id=0

Response

{
"id": 0,
"name": null,
"report_thr": 2.5,
"range": 0,
"xvoltage": {
"expr": "x+1",
"unit": "m/s"
}
}

Voltmeter.GetStatus example

http://192.168.33.1/rpc/Voltmeter.GetStatus?id=0

Response

{
"id": 0,
"voltage": 3.5,
"xvoltage": 4.5
}

Voltmeter.CheckExpression example

http://192.168.33.1/rpc/Voltmeter.CheckExpression?expr="(x/3)+4"&inputs=[1,2,3]

Response

{
"results": [
[
1,
4.333333
],
[
2,
4.666667
],
[
3,
5
]
]
}