Add Command

Overview

The Add Command API call is used to issue commands to devices, such as turning on/off a smart plug (SP1) or a network relay device (NR1).

API URL

https://webapi.ubibot.com/channels/CHANNEL_ID/commands?parameters

HTTP Method

POST

URL Parameters

Name Type Required Description
account_key String Required Specify the account_key obtained from the web console panel.
command_string String Required Command to be sent to your device. There is a limit of 255 characters per command_string.

command_string Format

For SP1-based Devices: Use a JSON string in the following format:

Turn on the switch: {"action":"command","set_state":1,"s_port":"port1"}
Turn off the switch: {"action":"command","set_state":0,"s_port":"port1"}

Where set_state represents the target action. For SP1, only port1 exists.
For NR1-based Devices: Use a JSON string in the following format:

{"action":"command", "control_list":[{"s_port":"port1", "set_state":1}, {"s_port":"port2", "set_state":0}, {"s_port":"port3", "set_state":0}, {"s_port":"port4", "set_state":0}]}

The control_list array is used. set_state represents the target action. For NR1, four ports are allowed, each representing the associated relay.

Response

An HTTP code of 200 is responded for each successful data requests. The message body contains a JSON object listing the metadata for all channels associated with the specified user.

Error: See the separate list of error codes for more details.