Este endpoint crea una nueva Variable.
Solicitud HTTP
Para crear una sola Variable, haz una petición POST a la siguiente URL:
HTTP Method | URL |
---|---|
POST | https://api.netux.com/api/v2.0/variables/ |
Para crear una nueva Variable de un Device, haz una petición POST a la siguiente URL:
HTTP Method | URL |
---|---|
POST | https://api.netux.com/api/v2.0/devices/<device_key>/variables/ |
Parámetros de consulta
Parameter | Type | Use | Description |
---|---|---|---|
token | String | Authentication | Authentication Token can optionally be sent as a query parameter |
Parámetros de cuerpo
Parameter | Type | Required? | Default Value | Description |
---|---|---|---|---|
label | String | Yes | N/A (required) | API label of Variable |
name | String | No | Same as label | Name of Variable |
description | String | No | "" | Description of Variable |
device | <device_key> | Yes | N/A (required) | Key of Device (id or label) |
tags | String Array | No | [] | Variable tags |
properties | Object | No | {} | Variable properties. Allowed attributes: _icon , _color , minimum_value , maximum_value , isLocationVariable , _position , _scale , _offset |
type | String | No | raw | Variable type. Allowed values raw (default) and synthetic |
unit | String | No | "" | Variable unit |
syntheticExpression | String | No | "" | Synthetic Expression of Variable |
Atributo
properties
explicado
_icon
: Icon of Variable (FontAwesome)
_color
: HEX, RGB and RGBA
minimum_value
: Lowest value allowed (Dots posted with a value below the minimum_value will not be saved)
maximum_value
: Highest value allowed (Dots posted with a value above the maximum_value will not be saved)
isLocationVariable
: Boolean value if the Variable should be taken as location Variable (device location mode: specified)
_scale
: All incoming values will be multiplied with this value
_offset
: All incoming values will be summed with this value
Cabecera
Parameter | Required? | Description |
---|---|---|
X-Auth-Token | Yes | Authentication Token of account |
Content-Type | String (application/json) | Content type of body |
curl -X POST 'https://api.netux.com/api/v2.0/variables/' \
-H 'Content-Type: application/json' \
-H 'X-Auth-Token: oaXBo6ODhIjPsusNRPUGIK4d72bc73' \
-d '{
"label": "second-variable",
"name": "Second Variable",
"description": "my second variable",
"device": "~first-device",
"tags": ["blue", "yellow"],
"properties": {},
"icon": "pencil",
"unit": "meters"
}'
Respuesta
Devuelve un objeto Variable con la Variable solicitada.
{
"createdAt": "2019-12-18T14:38:38.354415Z",
"syntheticExpression": "",
"description": "my second variable",
"device": {
"id": "6e309da44fc8455a9cceb5aa",
"label": "first-device",
"name": "First Device",
"url": "https://api.netux.com/api/v2.0/devices/6e309da44fc8455a9cceb5aa"
},
"icon": "pencil",
"id": "5dfa39ee1a9ca53020c69391",
"label": "var0",
"lastActivity": null,
"lastValue": {},
"name": "var0",
"properties": {},
"tags": ["blue", "yellow"],
"type": "raw",
"unit": "meters",
"url": "https://api.netux.com/api/v2.0/variables/5dfa39ee1a9ca53020c69391",
"valuesUrl": "https://api.netux.com/api/v2.0/variables/5dfa39ee1a9ca53020c69391/values"
}
{
"code": 400001,
"message": "Validation Error.",
"detail": {
....
}
}
{
"code": 401001,
"message": "Authentication credentials were not provided.",
"detail": "Authentication credentials were not provided."
}