Device Control
After the device's private deployment configuration is completed and the device information page can be accessed successfully, you can attempt to send commands to the device to control it.
1. Interface Calling
Interface Request:
{Command}
Any device within the same network as the target device can initiate a control request to the device.
Request URL: http://Device-IP-Address/control
Example: If the device's IP address is 192.168.1.123,
the request URL will be: http://192.168.1.123/control
the request URL will be: http://192.168.1.123/control
If a client port number (client) was specified for the device in the user settings during configuration, the port number must be appended to the IP address.
Example: If the client port number "1998" is specified for the device, the request URL should be:
http://192.168.1.123:1998/control
Example: If the client port number "1998" is specified for the device, the request URL should be:
http://192.168.1.123:1998/control
If a password (secret) was set for the device in the user settings during configuration, the "sign" parameter must be included in the request URL.
Example: If the device password is "123", the request URL should be:
http://192.168.1.123/control?sign=202cb962ac59075b964b07152d234b70
sign = md5(secret), so the value of sign is md5("123") = 202cb962ac59075b964b07152d234b70
Example: If the device password is "123", the request URL should be:
http://192.168.1.123/control?sign=202cb962ac59075b964b07152d234b70
sign = md5(secret), so the value of sign is md5("123") = 202cb962ac59075b964b07152d234b70
Request Protocol: HTTP; Request Method: POST; Data Format: JSON, as detailed below:
{Command}
Example: To turn on a smart wall switch, directly POST the following data to the interface:
{"power":1}
For commands supported by the product, please refer to the product manual of each product for detailed descriptions.
Important Note:
For voice broadcast products: The device does not support the UTF-8 character set.
Therefore:
When sending a broadcast command {"play:gbk:16":"content"} to the device,
you need to convert the "content" to GBK or GB2312 character set first, then convert it to hexadecimal before sending.
Example:
{"play:gbk:16":"你好"} (Hello),
the converted result of "你好" is: c4e3bac3. The command sent to the device should be:
{"play:gbk:16":"c4e3bac3"}
Device Response Information:
After a successful request, the device will return the following information.
After a successful request, the device will return the following information.
| Parameter / Name | Description |
|---|---|
Status Codecode |
1. Returns 200 if the device responds correctly; 2. Returns a value > 200 if the device fails to respond correctly; |
Datadata |
1. When code == 200, the device returns the post-execution message content in "data"; 2. When code != 200: No "data" is returned; |
Messagemsg |
1. When code == 200, returns "ok"; 2. When code != 200: Returns the corresponding error information; |
Response Example:
2. Remote Control
If you need to control the device remotely (from outside the device's network), it can be achieved through the following two methods:
Method 1:
Configure the router in the device's network to map external network requests to the device's IP address and port.
Configure the router in the device's network to map external network requests to the device's IP address and port.
Method 2:
Set up a web service (interface) in the device's network to respond to external requests. This interface will be responsible for forwarding these requests to the device.
Set up a web service (interface) in the device's network to respond to external requests. This interface will be responsible for forwarding these requests to the device.