Describes the JSON object of a Variable.
A Variable in NanoView can store one or more data points. Variables are the most granular entity and can either be raw (sensor or manually sent data) or synthetic (computed from an expression using other variables).
| Property | Type | Description |
|---|---|---|
| id | String | ID of Variable |
| label | String | Label of Variable |
| name | String | Name of Variable |
| description | String | Description of Variable |
| device | Object | The Device this Variable belongs to. Contains id, label, name, url, and createdAt. |
| tags | String Array | Tags of Variable |
| properties | Object | Properties of Variable. See Properties object below. |
| type | String | Variable type. Can be raw or synthetic. See Variable Types below. |
| unit | String | Unit of measurement for the Variable (e.g. °C, m/s, %). Can be null. |
| syntheticExpression | String | Mathematical expression used to compute the variable's value. Only applicable when type is synthetic. Empty string for raw variables. |
| createdAt | String | Date the Variable was created (ISO 8601 format). |
| lastValue | Object | The most recent data point sent to the Variable. See lastValue object below. |
| lastActivity | Number | Unix timestamp (ms) of the Variable's last recorded activity. Can be null if no data has been received. |
| url | String | URL of Variable |
| valuesUrl | String | URL to access the Variable's historical data points via the v1.6 API. |
Variable
{
"url": "https://nanoview-api.wellairsolutions.com/api/v2.0/variables/67253b189bcbc904dc48cd4c",
"id": "67253b189bcbc904dc48cd4c",
"label": "temp",
"name": "Temperature",
"description": "",
"device": {
"url": "https://nanoview-api.wellairsolutions.com/api/v2.0/devices/67253b189bcbc904dc48cd4d",
"id": "67253b189bcbc904dc48cd4d",
"label": "614385e15e4b40df8ecba871629a3c08",
"name": "Itagüí",
"createdAt": "2024-11-01T20:33:28.202904Z"
},
"tags": [],
"properties": {
"_icon": "thermometer-half",
"_color": "#e9c46a",
"_previous_variable_label": "temp"
},
"type": "raw",
"unit": "°C",
"syntheticExpression": "",
"createdAt": "2024-11-01T20:33:28.319179Z",
"lastValue": {
"value": 17.84,
"timestamp": 1771878262000,
"context": {},
"created_at": 1771878563537
},
"lastActivity": 1771878563539,
"valuesUrl": "https://nanoview-api.wellairsolutions.com/api/v1.6/variables/67253b189bcbc904dc48cd4e/values"
}Variable Types
The type field determines how a variable receives its value:
raw: The variable stores data points sent directly from a device or external source (e.g. sensors, API calls). ThesyntheticExpressionfield will be an empty string.synthetic: The variable's value is automatically computed from a mathematical expression referencing other variables (indicated by{{variable_id}}placeholders insyntheticExpression). Synthetic variables do not receive raw data.
Synthetic variable example:
{
"type": "synthetic",
"syntheticExpression": "{{67253b189bcbc904dc48cd51}} * {{67253b189bcbc904dc48cd4f}}"
}Properties object
The properties key object describes the following about a Variable:
- Color.
- Icon.
- Timezone for data aggregation.
| Property | Type | Description |
|---|---|---|
_icon | String | Font Awesome v6.1.1 icon name assigned to the variable. For example, "thermometer-half". |
_color | String | Variable color in hexadecimal format. For example, "#e9c46a". |
timezone | String | Timezone used for data aggregation and display. Uses IANA timezone format. For example, "America/Bogota". |
_scale | Number | Factor every new value is multiplied by before it is stored. See Scaling. |
_offset | Number | Amount added to every new value (after _scale) before it is stored. See Scaling. |
_input_range | Array | Two input reference points, [input_1, input_2], used to compute _scale and _offset. |
_output_range | Array | The two values those inputs should become, [output_1, output_2]. |
Properties object example
{
"properties": {
"_icon": "thermometer-half",
"_color": "#e9c46a",
"timezone": "America/Bogota",
}
}Scaling (_scale and _offset)
_scale and _offset)Every new value the Variable receives is transformed before it is stored:
stored value = received value × _scale + _offset
- Both keys are optional: with only
_scalethe value is multiplied, with only_offsetit is shifted, and with neither (ornull) it is stored as received. - It is applied at ingestion and is not retroactive: changing or removing
_scaleor_offsetdoes not modify values already stored. - Values sent to
POST /api/v1.6/devices/<device_label>/_/bulk/valuesare not scaled.
Instead of _scale and _offset you can set two reference points: with _input_range: [4, 20] and _output_range: [0, 100], NanoView computes _scale: 6.25 and _offset: -25 when the Variable is saved.
The ranges take precedenceWhile
_input_rangeand_output_rangeare both set, they overwrite_scaleand_offseton every save. To set_scaleand_offsetdirectly, set the ranges tonullin the same request.
To set the scaling, update the Variable with PATCH. In a PATCH request the properties object is merged with the existing one: only the keys you send change and the rest are kept.
$ curl -X PATCH 'https://nanoview-api.wellairsolutions.com/api/v2.0/variables/67253b189bcbc904dc48cd4c/' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
-d '{"properties": {"_scale": 1.8, "_offset": 32}}'lastValue object
The lastValue object contains the most recent data point recorded for the Variable. It will be an empty object {} if no data has been received yet.
| Property | Type | Description |
|---|---|---|
| value | Number | The numeric value of the last data point. |
| timestamp | Number | Unix timestamp (ms) indicating when the value was measured or originated. |
| context | Object | Arbitrary key-value pairs sent alongside the value for additional metadata (e.g. cardinal direction, icon URLs). Can be an empty object {}. |
| created_at | Number | Unix timestamp (ms) indicating when the data point was stored in NanoView. |
lastValue object example
{
"lastValue": {
"value": 10.0,
"timestamp": 1771878262000,
"context": {
"cardinal_direction": "N"
},
"created_at": 1771878563540
}
}