功能描述

创建命令调用用于向设备发出命令,例如打开/关闭智能开关(SP1)或对网络继电器(NR1)设备进行分路控制。

请求地址

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

将 CHANNEL_ID 替换为您的空间编号。

请求方式

HTTP POST

请求参数

名称 类型 是否必须 描述
account_key String 账户的account_key密钥
command_string String 要发送到设备的命令。 每个 command_string 限制为 255 个字符。

command_string Format

对于SP1类型设备:

使用以下格式的 JSON 字符串:

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

set_state 代表开或关的指令。 SP1类型设备仅有port1存在。

对于NR1类型设备:

使用以下格式的 JSON 字符串:

{"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}]}

使用 control_list 数组。 set_state 表示目标操作。 对于 NR1,允许四个端口,每个端口代表相关的继电器。

返回说明

每个成功的数据请求返回 HTTP 状态码 200。