read()

Reads the current value of a Resource.

This function is available in firmware 3.1.0+.

Parameters

ParameterTypeRequiredDescription
pathStringYes Regular Resources:
- Actual resources; must begin with a /.
- These paths can be either absolute or relative. Absolute paths must begin with /app and are used without modification.
- Relative paths are assumed to be with respect to /app and have /app prepended to them internally before use (e.g. The relative path argument: /myapp/mysensor/period is converted to the full path: /app/myapp/mysensor/period).

Virtual Resources: Xreated from via the /virtual/config Resource. These are read using Datahub.read() and are written using the vr:// output tag in the return object. Each Virtual Resource behaves in a similar way to that of a global variable, and is accessible from all actions which belong to a particular device. These Resources are not visible between devices.
- Variable names which do not contain any slashes / (i.e. no sub-directories).
- When read, the terminating node /value is appended to the path.

Returns

FieldTypeDescription
value variableThe current value of the Resource.
timestamp IntegerThe time, in seconds, when the Resource was set to its current value.

Example

Request

var result = Resource.read('/redSensor/light/value');

Response

{
    "value": 1291,
    "timestamp": 1606159021.780723
}