Table of Contents

Sensors values

To get sensors values, use the command unit/calc_sensors:

svc=unit/calc_sensors&params={"source":<text>,
			      "indexFrom":<uint>,
			      "indexTo":<uint>,
			      "unitId":<long>,
			      "sensorId":<long>,
			      "width":<uint>}

Parameters

Name Description
source source of messages - layer name, if empty - messages loader will be used by default
indexFrom index of first message
indexTo index of last message
unitId unit ID
sensorId ID sensor: if 0 - return values of all sensors
width desired number of elements to respond, aggregation is used (see below), optional

:!: If source is defined then unitId must be defined too. If source is NOT defined then write down any value in unitId (it is not used) – messages are put from message loader directly.

Explanation of 'width' param

When you need fixed quantity of sensor values and aggregated (i.e. preprocessed), then you may use 'width' param. For example you may get preprocessed data to form and zoom charts.
Logics is as follows:
1. the system finds all messages within asked bounds;
2. then it splits all the interval into width subintervals;
3. in every subinterval it finds the very first sensor value (left), the last one (right), minimal one (bottom) maximal one (top). Described values will merge into final server response.

Response

[	/* array of messages data */
	{		/* value(s) of sensor(s) from one message */
		<text>:<double|text>,	/* sensor ID: sensor value */
		...
	}
]

If width is defined, then the response will be as follows:

[
	[
		{
			"name":<sensor_name>,
			"data":[
				   {
					"left":[<unix_time1>,<value1>],
					"right":[<unix_time2>,<value2>],
					"bottom":[<unix_time3>,<value3>],
					"top":[<unix_time4>,<value4>]
				   },
				...
				]
		},
		...
	]
]

где <sensor_name> – sensor name,
<unix_timeN> – message UNIX-time,
valueN – sensor value in a message,
left – the first sensor value in a subinterval and its time,
right – the last sensor value in a subinterval and its time,
bottom – minimal sensor value in a subinterval and its time,
top – maximal sensor value in a subinterval and its time.