Quickstart: control a device
You need a project with at least one app user who has a device. See your first project.
1. Turn on IoT Core
Section titled “1. Turn on IoT Core”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”- In Cloud Services, open API keys and add one. Name it after the server that will use it.
- Copy the key. Keep it on your server only: anyone with it can control your users’ devices.
- Under IP whitelist, add your server’s public IP address.
3. Find the device
Section titled “3. Find the device”List the devices of one of your app users. Their user id is on the Apps → App users tab.
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.
4. Switch it on
Section titled “4. Switch it on”Attribute 1 is On Off, and the value 1 means on. A command is the attribute followed by its
values:
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.
5. Read its state
Section titled “5. Read its state”curl "https://openapi.rogo.com.vn/api/v2.0/iot-core/state/devId/<uuid>" \ -H "x-header-apikey: $API_KEY"- Controlling devices: several elements, several devices at once.
- What every attribute means: Reading attributes.
- All routes: API reference.