calc_last_message

To get a sensor value from the last message, use the unit/calc_last_message method:

Copied!
svc=unit/calc_last_message&params={"unitId":<long>,
				   "sensors":[<long>],
				   "flags":<uint>}

Parameters

The required parameters are marked with an asterisk (*).

Parameter Description
unitId* Unit ID.
sensors Array of sensor IDs. If this parameter is not specified or empty, the values of all sensors are returned.
flags Flags. If this parameter is set to 1, the sensor value is calculated using the last valid parameter value.

Response

If the request is completed successfully, the sensor value is returned.

Copied!
{
	<text>:<double|text>,	/* sensor ID: sensor value */
	...
}

If a sensor value can’t be calculated (for example, the last message doesn’t contain the parameter used by the sensor), -348201.3876 is returned for this sensor.

Otherwise, an error code is returned.

Error codes

Error code Description
4 Invalid input parameters or failed to fetch the unit sensors.
7 The unit doesn’t exist, or the user doesn’t have the View object and its basic properties access right to it.

If you find a mistake in the text, please select it and press Ctrl+Enter.