Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Control Device API

wagmarcel edited this page Jan 10, 2018 · 1 revision

Send actuation command

Send actuation command to the device for specific component (actuator)

Param Type Description Value
Authorization HTTP Header Access Token Authorization: Bearer eyJ0eX...
accountId URL Slug The ID of an Account ed6c80f7-1914-4d21-bc26-47d0bb5fdf4d
Request
POST /v1/api/accounts/{accounId}/control
{
   "commands":
       [
           {
               "componentId":"775c80a5-3313-2221-9028-47da015fdf51",
               "parameters":
                   [
                       {
                           "name":"LED",
                           "value":"1"
                       }
                   ],
               "transport": "either mqtt or ws"
            }
       ],
   "complexCommands": [ "complexCommandName" ]

}

Response 200 OK

See the iotkit-agent README for more information on how it handles these requests.

Save complex command

Saves multiple simple commands as a complex one which can be later executed as one.

Param Type Description Value
Authorization HTTP Header Access Token Authorization: Bearer eyJ0eX...
accountId URL Slug The ID of an Account ed6c80f7-1914-4d21-bc26-47d0bb5fdf4d
commandName URL Slug Name for command to be created FlashingLight
Request
POST /v1/api/accounts/{accounId}/control/commands/{commandName}

{
    "commands": [
        {
            "componentId":"07db2660-2a86-4425-b9b6-59554f734b41",
            "transport":"ws",
            "parameters": [ 
                {"name":"LED","value":"1"},
                {"name":"LED","value":"0"},
                {"name":"LED","value":"1"},
                {"name":"LED","value":"0"},
                {"name":"LED","value":"1"}
            ]
        }
    ]
}

Response 200 OK

Get list of actuations

Get list of actuation commands, which was send to the device. By default method returns list of actuations from last 24 hours. There is possibility to get list of actuations from specific period of time, by adding from and to parameters to the url request (see "from and to" paragraph below).

Param Type Description Value
Authorization HTTP Header Access Token Authorization: Bearer eyJ0eX...
accountId URL Slug The ID of an Account ed6c80f7-1914-4d21-bc26-47d0bb5fdf4d
deviceId URL Slug The ID of a Device 24-a5-80-21-5b-29
from HTTP Param Beginning of the time window in miliseconds, optional 0
to HTTP Param End of the time window in miliseconds, optional 1407979291860

from and to

  • If the to key is omitted, data will be retrieved up to the current time.

  • If the from key is omitted, from will default to currentTime minus 24 hours. If from is positive it will represent the number of milliseconds since Jan-01-1970T00:00:00.000. However, if from is negative, it represents the number of seconds to add to to (because the number is negative, it will decrease to, moving backward in time.

  • There is no way to receive actuations, which were send to device before 24 hours. Only actuations from last 24 hours are stored in application database.

Here are some examples:

from to meaning
0 missing Return all data available
-86400 missing return all data with timestamps in the last 24 hours (86,400 seconds)
1407979291000 1407980711000 return all observations with timestamps between 2014-08-13T18:21:31.000 UTC and 2014-08-13T18:45:11.000 UTC
Request
GET /v1/api/accounts/{accounId}/control/devices/{deviceId}?from=-86400

Response 200 (application/json)
[
    {
       "created": "2015-02-02T08:45:58.776Z",
       "deviceId": "24-a5-80-21-5b-29",
       "componentId": "1f433537-a9ef-4a80-9b61-505e7c5299ac",
       "command": "LED.v1.0",
       "params": [
            {
                "name": "LED",
                "value": "1"
            }
        ],
        "accountId": "ed6c80f7-1914-4d21-bc26-47d0bb5fdf4d",
        "id": "54cf3946e92e91d7c8a9f6c6"
    }
]

Table of Contents

Clone this wiki locally