Skip to content

Quickstart: control a device

You need a project with at least one app user who has a device. See your first project.

In the project, open Cloud Services, choose Add service, pick IoT Core and save.

2. Create an API key and allow your server

Section titled “2. Create an API key and allow your server”
  1. In Cloud Services, open API keys and add one. Name it after the server that will use it.
  2. Copy the key. Keep it on your server only: anyone with it can control your users’ devices.
  3. Under IP whitelist, add your server’s public IP address.

List the devices of one of your app users. Their user id is on the Apps → App users tab.

Terminal window
curl "https://openapi.rogo.com.vn/api/v2.0/iot-core/device/<userId>" \
-H "x-header-apikey: $API_KEY"

Keep the device’s uuid, mac, eid, elementIds, rootUuid, endpoint and protocolCtl.

Attribute 1 is On Off, and the value 1 means on. A command is the attribute followed by its values:

Terminal window
curl -X POST "https://openapi.rogo.com.vn/api/v2.0/iot-core/control/device" \
-H "x-header-apikey: $API_KEY" \
-H "content-type: application/json" \
-d '{
"eid": 12345,
"elementIds": [1],
"command": [1, 1],
"rootUuid": "<rootUuid>",
"endpoint": "<endpoint>",
"protocolCtl": 0,
"partnerId": "<your partner id>"
}'

Fill in the fields you kept from step 3. A 201 answer means the command was sent to the device.

Terminal window
curl "https://openapi.rogo.com.vn/api/v2.0/iot-core/state/devId/<uuid>" \
-H "x-header-apikey: $API_KEY"