Crear Variable

Este endpoint crea una nueva Variable.

Solicitud HTTP

Para crear una sola Variable, haz una petición POST a la siguiente URL:

HTTP MethodURL
POSThttps://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 MethodURL
POSThttps://api.netux.com/api/v2.0/devices/<device_key>/variables/

Parámetros de consulta

ParameterTypeUseDescription
tokenStringAuthenticationAuthentication Token can optionally be sent as a query parameter

Parámetros de cuerpo

ParameterTypeRequired?Default ValueDescription
labelStringYesN/A (required)API label of Variable
nameStringNoSame as labelName of Variable
descriptionStringNo""Description of Variable
device<device_key>YesN/A (required)Key of Device (id or label)
tagsString ArrayNo[]Variable tags
propertiesObjectNo{}Variable properties. Allowed attributes: _icon, _color, minimum_value, maximum_value, isLocationVariable, _position, _scale, _offset
typeStringNorawVariable type. Allowed values raw (default) and synthetic
unitStringNo""Variable unit
syntheticExpressionStringNo""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

ParameterRequired?Description
X-Auth-TokenYesAuthentication Token of account
Content-TypeString (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."
}