Вы находитесь на странице: 1из 53

openSDK20160127

User's Manual

For General Use


Open API of SDK for Smart Home Mobile App – User Manual

Copyright Information

The information contained in this document is the proprietary information of Hangzhou Gubei Electronics
Technology Co., Ltd. (hereinafter referred as BroadLink). The contents are confidential and any disclosure to
persons other than the officers, employees, agents or subcontractors of the owner or licensee of this document,
without the prior written consent of BroadLink, is strictly prohibited.

Further, no portion of this document may be reproduced, stored in a retrieval system, or transmitted in any form or
by any means, electronic or mechanical, including photocopying and recording, without the prior written consent
of BroadLink, the copyright holder.

BroadLink publishes this document without making any warranty as to the content contained herein. Further
BroadLink reserves the right to make modifications, additions and deletions to this document due to
typographical errors, inaccurate information, or improvements to products mentioned in the document at any time
and without notice. Such changes will, nevertheless be incorporated into new editions of this document.

BroadLink, EasyConfig and their logos are registered trademarks of Hangzhou Gubei Electronics Technology Co.,
Ltd.

Android is the trademark of Google Inc. IOS is a trademark or registered trademark of Cisco in the U.S. and
other countries and is used under license by Apple Inc. Other marks may be mentioned herein that belong to
other companies.

Version History

V1.0.0 Oct 27, 2014 1st issue of preliminary document

www.broadlink.com.cn 2 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Table of Contents
1. Introduction...................................................................................................................................................7
2. How to use the SDK .....................................................................................................................................7
3. API Specification..........................................................................................................................................8
network_init....................................................................................................................................................10
SDK_version...................................................................................................................................................11
probe_list.........................................................................................................................................................12
device_add ......................................................................................................................................................14
device_update .................................................................................................................................................15
device_delete...................................................................................................................................................16
device_lan_ip ..................................................................................................................................................17
device_state.....................................................................................................................................................18
sp1_auth..........................................................................................................................................................18
sp1_control......................................................................................................................................................20
sp1_refresh......................................................................................................................................................21
sp1_task...........................................................................................................................................................22
sp2_refresh......................................................................................................................................................24
sp2_control......................................................................................................................................................26
sp2_task...........................................................................................................................................................27
sp2_current_power..........................................................................................................................................29
sp2_24_power.................................................................................................................................................30
sp2_week_power.............................................................................................................................................31
sp2_month_power...........................................................................................................................................32
sp2_year_power..............................................................................................................................................33
sp2_get_standby_power..................................................................................................................................35
sp2_set_standby_power..................................................................................................................................36
sp3_refresh......................................................................................................................................................37
sp3_control......................................................................................................................................................40
sp3_task...........................................................................................................................................................41
sp3_set_eleprotect...........................................................................................................................................44
sp3_set_day_saving_time ...............................................................................................................................45

www.broadlink.com.cn 3 / 53
Open API of SDK for Smart Home Mobile App – User Manual

sp3_get_day_saving_time...............................................................................................................................46
rm1_auth .........................................................................................................................................................47
rm1_study .......................................................................................................................................................48
rm1_code.........................................................................................................................................................49
rm1_send.........................................................................................................................................................50
rm2_refresh.....................................................................................................................................................51
rm2_study .......................................................................................................................................................52
rm2_code.........................................................................................................................................................52
rm2_send.........................................................................................................................................................53
rmpro_freq_scan .............................................................................................................................................54
rmpro_freq_scan_status ..................................................................................................................................55
rmpro_scan_study...........................................................................................................................................56
rmpro_cancel_study........................................................................................................................................57
a1_refresh........................................................................................................................................................58
a1_task_list .....................................................................................................................................................59
a1_add_task.....................................................................................................................................................61
a1_del_task .....................................................................................................................................................64
rmac_current_power .......................................................................................................................................66
rmac_24_power...............................................................................................................................................67
rmac_week_energy .........................................................................................................................................68
rmac_month_energy .......................................................................................................................................69
rmac_year_energy...........................................................................................................................................71
rmac_get_standby_power ...............................................................................................................................72
rmac_set_standby_power................................................................................................................................73
rmac_set_low_time.........................................................................................................................................74
rmac_get_all_energy.......................................................................................................................................75
easyconfig .......................................................................................................................................................76
Cancel easyconfig ...........................................................................................................................................77
Obtain wifi_info..............................................................................................................................................78

www.broadlink.com.cn 4 / 53
Open API of SDK for Smart Home Mobile App – User Manual

1. Introduction
BroadLink UART Data transmission SDK allows developers to directly access the easyconfig technique of
Broadlink and provides integration support for their applications of the Broadlink devices discovery and control.
Users only need to be ready for the hardware and UI,That can be completed the development of the product in the
shortest time.At the same time, it can also directly control the BroadLink intelligent products.

2.How to use the SDK


Before calling a API, use network_init to initialize the library at first.
1)Devices Network Configuration
Use easyconfig to configure the device network parameters.
2)Device Discovery
After using probe_list, all broadlink devices can be detected within the local area network (LAN).
3) Device Initialization
As soon as probe_list returns that the command finished successfully, use device_add to initialize the device.Ensure
the parameters of device_add are the same as the contents returned by probe_list.
4) Device Information Storage
When devices are detected by applications, APP need to save device information (returned by probe_list) to their
own database or file. It is required to send the saved device information from the database or file to underlying
libraries using device_add.
5) Send and receive data
Call the passthrough command so that to send the APP data to the UART.

3. API Specification
All requests listed in the following table are in synchronous mode.
Request ID Function Comment Command
1 Network threads Using this method is the premise of the network network_init
initialization operation
2 Obtain SDK Version Obtain current SDK version information and updated
SDK_version
information contents
11 Through this interface, the list of new devices or the
Search for new
devices with updated content can be found. It requires probe_list
"device list"
users to determine whether devices are saved
12 Through this interface, devices can be added to the
Add devices to
network threads, and this step is the premise of further device_add
network threads
operations of these devices
13 Modify device Through this interface, the name and locking status of
device_update
information devices can be updated
14 Delete devices
Through this interface, devices can be deleted from
from network device_delete
network threads
threads
15 Obtain LAN IP
Through this interface, IP address of the device in
address of the
local network can be obtained device_lan_ip
devices
16 Obtain network Through this interface, current network status of the
status of devices device can be obtained device_state
41 Authenticate SP1 through this interface. Only the
SP1 login sp1_auth
authenticated devices can be controlled
42 SP1 control Through this interface, SP1 can be switched on or off sp1_control
43 SP1 refresh Through this interface, the current status of SP1 can sp1_refresh
be looked up
44 Through this interface, the periodic tasks of SP1 can
SP1 tasks sp1_task
be set up
71 SP2/SPmini Through this interface, the current state of the SP2 sp2_refresh

www.broadlink.com.cn 5 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Request ID Function Comment Command


refresh can be obtained directly, without the need of login
72 SP2/SPmini Through this interface, SP2/SPmini can be switched sp2_control
control on or off
73 Through this interface, the periodic tasks of
SP2/SPmini tasks sp2_task
SP2/SPmini can be set up
74 SP2 Real-Time Through this interface, current Real-Time power of
sp2_current_power
power SP2 can be obtained
75 SP2 power of last Through this interface, power curve of SP2 power of sp2_24_power
24 hours last 24 hours can be obtained
76 SP2 measured
energy Through this interface, SP2 measured energy
sp2_week_power
consumption of a consumption of the specified week can be obtained
week
77 SP2 measured
energy Through this interface, SP2 measured energy sp2_month_power
consumption of a consumption of the specified month can be obtained
month
78
SP2 measured
energy Through this interface, SP2 measured energy sp2_year_power
consumption of a consumption of the specified year can be obtained
year
79
SP2 standby Through this interface, SP2 standby power can be
sp2_get_standby_power
power obtainment obtained
80 SP2 standby sp2_set_standby_power
Through this interface, SP2 standby power can be set
power setting
82 Through this interface, current status of
SP3/SPMiniV2 refresh sp3_refresh
SP3/SPMiniV2 can be obtained
83 SP3 control Through this interface, SP3 can be switched on or off sp3_control
84 Through this interface, the periodic tasks of sp3_task
SP3/SPMiniV2 task
SP3/SPMiniV2 can be set up
85 SP3/SPMiniV2
Through this interface, the charging protection of
charging sp3_set_eleprotect
SP3/SPMiniV2 can be set up
protection
86 SP3 set day light Through this interface, the day light saving of SP3
sp3_set_day_saving_time
saving can be set up
87 SP3 get day light Through this interface, the day light saving of SP3 sp3_get_day_saving_time
saving can be obtained
101 Through this interface, Authenticate RM1 through
RM1 login this interface. Only the authenticated devices can be rm1_auth
controlled
102 RM1 Learning Through this interface, RM1 can be set to Learning
rm1_study
Mode Mode
103 RM1 control code Through this interface, the control codes learned by
rm1_code
query RM1 can be obtained
104 RM1control code Through this interface, the specified control codes can
rm1_send
sent be sent by RM1
131 RM2/RMhome+/RMpr Through this interface, ambient temperature value can
rm2_refresh
o+/RMmini refresh
132 be obtained
RM2/RMhome+/RMmi
Through this interface, RM can be set to Learning
ni Learning rm2_study
Mode
Mode
133 RM2/RMhome+/RMpr Through this interface, the control codes learned by
o+/RMmini code query RM can be obtained rm2_code
134 RM2/RMhome+/RMpr Through this interface, the specified control codes can
rm2_send
o+/RMmini code sent be sent by RM
135 Rmpro+ start frequecny Through this interface, Rmpro+ start frequecny rmpro_freq_scan
scanning scanning funtion
136 Rmpro+ frequecny Through this interface,obtain Rmpro+ frequecny rmpro_freq_scan_status
scanning status query scanning status
137 Rmpro+ frequecny Through this interface,let Rmpro+ frequecny rmpro_scan_study
scanning and study scanning,then study
138 Rmpro+ quit learning Through this interface, Rmpro+ quit learning rmpro_cancel_study
status status
161 A1 refresh Through this interface, the temperature, humidity, a1_refresh

www.broadlink.com.cn 6 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Request ID Function Comment Command


illumination, air quality and noise can be detected
162 Check Current Through this interface, Current Task List of A1 can a1_task_list
Task List of A1 be obtained
163 Add new tasks Through this interface, new tasks can be added into
a1_add_task
into A1 A1
164 Delete tasks from Through this interface, the specified tasks can be
a1_del_task
A1 deleted from A1
190 RMAC Real-Time Through this interface, current Real-Time power of
rmac_current_power
power RMAC can be obtained
191 RMAC power of last Through this interface, power curve of RMAC power rmac_24_power
24 hours of last 24 hours can be obtained
192
RMAC measured
Energy consumption of Through this interface, RMAC measured energy
rmac_week_energy
a consumption of the specified week can be obtained
week

193 RMAC measured


energy Through this interface, RMAC measured energy rmac_month_energy
consumption of a consumption of the specified month can be obtained
1 month
94 RMAC measured
energy Through this interface, RMAC measured energy
rmac_year_energy
consumption of a consumption of the specified year can be obtained
year
1
95 RMAC standby Through this interface, RMAC standby power can be
rmac_get_standby_power
power obtainment obtained
196 RMAC standby Through this interface, RMAC standby power can be
rmac_set_standby_power
power setting set
197 RMAC low time setting Through this interface, RMAC low time can be set rmac_set_low_time
198 RMAC energy
Through this interface, RMAC energy consumption
consumption real time rmac_get_all_energy
data getting real time data can be get
9000 Through this interface,let the module send the
UART passthrough passthrough
specified data
When the devices using broadlink modules are not
10000 EasyConfig connected to a network, they can be deployed to a easyconfig
local area network through this interface
10001 Through this interface, easyconfig processing can be
CancelEasyConfig cancel_easyconfig
canceled
10002 Obtain Wi-Fi Through this interface, information of current network_init
information connected router (specified router) can be obtained
For the code field of the return data, 0 means success, while non-zero means failure. All data are
transmitted in json format。

network_init
Arguments Example
arguments:
{
"api_id" : 1,
"command" : "network_init",
"license" : "0000000000000000000000",
"type_license" : "aaaaaaaaaaaaaaaaaaaaa",
"main_udp_ser" : "www.baidu.com",
"backup_udp_ser" : "www.sina.com.cn",
"main_tcp_ser" : "www.google.com",
"main_udp_port" : 80,

www.broadlink.com.cn 7 / 53
Open API of SDK for Smart Home Mobile App – User Manual

"backup_udp_port" : 8080,
"main_tcp_port" : 80
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command command
license The license obtained by users when they apply for the API.
type_license The license obtained by users when they apply for the API.
backup_udp_ser Specified backup udp server domain name (Option)
main_udp_ser Specified udp server domain name (Option)
main_tcp_ser Specified tcp server domain name (Option)
main_udp_port Specified main udp port (Option, if specify the main udp server domain
name, it is must be set)
backup_udp_port Specified backup udp port (Option, if specify the backup udp server domain
name, it is must be set)
main_tcp_port Specified main tcp port (Option, if specify the tcp server domain name, it is
must be set)

Return Message
Retval:
{ "code":0,
"msg":"network init success"
}

SDK_version

Arguments Example
arguments:
{
"api_id" : 2,
"command" : "SDK_version",
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).

Return Message
Retval:
{ "code":0,
"version":"V1.1.0-201406091100",
"update":"V1.1.0-201406091100 update contents: ......"
}
</pre>
Arguments Specification
Arguments Name Arguments Specification
code return code
version Current SDK version
update Current SDK update content

www.broadlink.com.cn 8 / 53
Open API of SDK for Smart Home Mobile App – User Manual

probe_list

Arguments Example
arguments:
{
"api_id" : 11,
"command" : "probe_list"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

Return Message
Retval:
{ "code":0,
"msg":"Execute success!",
"list":[
{ "mac":"00:11:22:33:44:55",
"type":"SP2",
"name":" Smart Plug ",
"lock":0,
"password":987961777,
"id":0,
"subdevice":0,
"key":"097628343fe99e23765c1513accf8b02"
},
{ "mac":"00:11:22:33:44:55",
"type":"SP2",
"name":"Example",
"lock":0,
"password":912023642,
"id":0,
"subdevice":0,
"key":"097628343fe99e23765c1513accf8b02"
}
]
}
Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message
list Device property information array from the query
mac mac address of the device
type Device type, the current supported device types, SP1/SP2/RM1/RM2 (Note:should be
capitalized).
name Device name, UTF8 code.
lock Current locking state of the device
password Password required for SP1/RM1 authentication, which is generated by device and
cannot be modified.
id ID used in SP2/RM2 communication, which is generated by device and cannot be
modified.
subdevice Reserved field. Set to 0
key Key used in SP2/RM2 communication, which is generated by device and cannot be

www.broadlink.com.cn 9 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Name Arguments Specification


modified.

device_add

Arguments Example
arguments:
{ "api_id":12,
"command":"device_add",
"mac":"00:11:22:33:44:55",
"type":"RM2",
"name":" Smart Plug ",
"lock":0,
"password":1028000492,
"id":0,
"subdevice":0,
"key":"00000000000000000000000000000000"
}

Arguments Specification
Arguments Arguments Specification
Name
api_id command ID
command Command (optional).
The following fields obtained from probe_list cannot be modified.
mac MAC address of the device.
type Device type, the current supported device types, SP1/SP2/RM1/RM2. (Note: should be
capitalized)
name Device name, UTF8 code.
lock Current locking state of the device
password Password required for SP1/RM1 authentication, which is generated by device and cannot be
modified.
id ID used in SP2/RM2 communication, which is generated by device and cannot be modified.
subdevice Reserved field. Set to 0
key Key used in SP2/RM2 communication, which is generated by device and cannot be
modified.

Return Message
Retval:
{ "code":0,
"msg":"Add device success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

www.broadlink.com.cn 10 / 53
Open API of SDK for Smart Home Mobile App – User Manual

device_update

Arguments Example
arguments:
{ "api_id":13,
"command":"device_update",
"mac":"00:11:22:33:44:55",
"name":" Smart Plug ",
"lock":0,
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac Device MAC address needs to be modified.
name Device name needs to be modified, UTF8 code.
lock Whether or not to lock

Return Message
Retval:
{ "code":0,
"msg":"Update device info success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

device_delete

Arguments Example
arguments:
{ "api_id":14,
"command":"device_delete",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional)
mac Device MAC address needs to be deleted.

Return Message

Retval:
{ "code":0,
"msg":"Delete device success"
}

www.broadlink.com.cn 11 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

device_lan_ip

Arguments Example
arguments:
{ "api_id":15,
"command":"device_lan_ip",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional)
mac Device MAC address needs to be deleted.

Return Message
Retval:
{ "code":0,
"lan_ip":"192.168.1.113",
"msg":"mac:00:11:22:33:44:55 get lan ip success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
lan_ip Current device LAN IP address.
msg return message

device_state

Arguments Example
arguments:
{ "api_id":16,
"command":"device_state",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac Device MAC address needs to be deleted.

Return Message

www.broadlink.com.cn 12 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Retval:
{ "code":0,
"status":"LOCAL",
"msg":"mac:00:11:22:33:44:55 get state success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
status current network status of the device (NOT_INIT: Not initialized Local: LAN
REMOTE: Remote OFFLINE: offline)
msg return message

sp1_auth

Arguments Example
arguments:
{ "api_id":41,
"command":"sp1_auth",
"mac":"00:11:22:33:44:55",
"password":1028000492
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device that needs to login.(mandatory)
password Device Login Password(mandatory)

Return Message
Retval:
{ "code":0,
"msg":"sp1 auth success",
"status":1,
"name":"Smart Plug 1",
"lock":0,
"periodic_task":[
{ "enable":1,
"on_time":"08:00",
"off_time":"15:00",
"repeat":0
},
{ "enable":1,
"on_time":"--:--",
"off_time":"00:00",
"repeat":127
}
] "status":1
}

Arguments Specification
Arguments Name Arguments Specification
code return code

www.broadlink.com.cn 13 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Name Arguments Specification


msg return message
status current status of the SP1 device.(1: turn on, 0: turn off)
name Name of SP2
lock Whether SP2 device is locked or not.
periodic_task Periodic task of SP2.
enable Enable periodic tasks of the SP1 device.
on_time Start time of periodic tasks, if not set, set it to be"--:--".
off_time End time of periodic tasks, if not set, set it to be"--:--".
repeat Repetitive cycles of periodic tasks in one-week iteration, 0 means task is only executed
once (bit0: Sunday, bit1: Monday, bit2: Tuesday, bit3: Wednesday, bit4:Thursday, bit5:
Friday, bit6: Saturday).

sp1_control

Arguments Example
arguments:
{ "api_id":42,
"command":"sp1_control",
"mac":"00:11:22:33:44:55",
"status": 0
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
status status: the status to be set (0: off; 1: on).

Return Message
Retval:
{ "code":0,
"msg":"Set sp1 status success"
}
Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

sp1_refresh

Arguments Example

arguments:
{ "api_id":43,
"command":"sp1_refresh",
"mac":"00:11:22:33:44:55"
}

Arguments Specification

www.broadlink.com.cn 14 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Name Arguments Specification


api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"msg":"Refresh sp1 status success"
"status": 0
"name":"Smart Plug 1",
"lock":0,
"periodic_task":[
{ "enable":1,
"on_time":"08:00",
"off_time":"15:00",
"repeat":0
},
{ "enable":1,
"on_time":"--:--",
"off_time":"00:00",
"repeat":127
}
]
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message
status current status of the SP1 device.(1: turn on, 0: turn off)
name Name of SP2
lock Whether SP2 device is locked or not
periodic_task Periodic task of SP2.
enable Enable periodic tasks of the SP1 device
on_time Start time of periodic tasks, if not set, set it to be"--:--".
off_time End time of periodic tasks, if not set, set it to be"--:--".
repeat Repetitive cycles of periodic tasks in one-week iteration, 0 means task is only executed
once (bit0: Sunday, bit1: Monday, bit2: Tuesday, bit3: Wednesday, bit4:Thursday, bit5:
Friday, bit6: Saturday).

sp1_task

Arguments Example
arguments:
{ "api_id":44,
"command":"sp1_task",
"mac":"00:11:22:33:44:55",
"name":"Smart Plug 1",
"lock":0,
"periodic_task":[
{ "enable":1,
"on_time":"08:00",

www.broadlink.com.cn 15 / 53
Open API of SDK for Smart Home Mobile App – User Manual

"off_time":"15:00",
"repeat":0
},
{ "enable":1,
"on_time":"--:--",
"off_time":"00:00",
"repeat":127
}
]
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
name Name of SP2
lock Whether SP2 device is locked or not.
periodic_task Periodic task of SP2.
enable Enable periodic task
on_time Start time of periodic tasks, if not set, set it to be"--:--".
off_time End time of periodic tasks, if not set, set it to be"--:--".
repeat Repetitive cycles of periodic tasks in one-week iteration, 0 means task is only executed
once (bit0: Sunday, bit1: Monday, bit2: Tuesday, bit3: Wednesday, bit4: Thursday,
bit5: Friday, bit6: Saturday).

Note: While setting up a task, the previous task need to be set up at the same time. Task of adding and deleting
should use the same interface. The device name and locking status also need to be set.
Retval:
{ "code":0,
"msg":"Set sp1 task success"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
msg return message

sp2_refresh

Arguments Example
arguments:
{ "api_id":71,
"command":"sp2_refresh",
"mac":"00:11:22:33:44:55"
}
Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:

www.broadlink.com.cn 16 / 53
Open API of SDK for Smart Home Mobile App – User Manual

{ "code":0,
"msg":"Refresh sp2 status success",
"status":0
"name":"Smart Plug 2",
"lock":0,
"periodic_task":[
{ "enable":1,
"on_time":"08:00",
"off_time":"15:00",
"repeat":0
},
{ "enable":1,
"on_time":"--:--",
"off_time":"00:00",
"repeat":127
}
] "timer_task":[
{ "on_enable":1,
"on_time":"2014-07-02 14:58:03"
"off_enable":0,
"off_time":"2014-07-02 15:58:03"
},
{ "on_enable":0,
"on_time":"2014-07-02 14:58:03"
"off_enable":1,
"off_time":"2014-07-03 16:58:03"
},
{ "on_enable":1,
"on_time":"2014-07-02 14:58:03"
"off_enable":1,
"off_time":"2014-07-05 18:58:03"
}
]
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message
status Current ON/OFF of Devices (0: OFF 1: ON)
name Name of SP2.
lock Whether SP2 device is locked or not.
periodic_task Periodic task of SP2.
enable Enable periodic task
on_time Start time of periodic tasks, if not set, set it to be"--:--".
off_time End time of periodic tasks, if not set, set it to be"--:--".
repeat Repetitive cycles of periodic tasks in one-week iteration, 0 means task is only executed
once (bit0: Sunday, bit1:Monday, bit2:Tuesday, bit3:Wednesday,bit4:Thursday,
bit5:Friday, bit6: Saturday).
timer_task Timer task of SP2.
on_enable Timer task.enable open.
on_time Timer task.enable open time.
off_enable Timer task.enable closure.
off_time Timer task.enable closure time.

www.broadlink.com.cn 17 / 53
Open API of SDK for Smart Home Mobile App – User Manual

sp2_control

Arguments Example
arguments:
{ "api_id":72,
"command":"sp2_control",
"mac":"00:11:22:33:44:55",
"status":1
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
status ON/OFF status to be set (0: OFF 1: ON)(mandatory)

Return Message
Retval:
{ "code":0,
"msg":"Set status success"
}

Arguments Specification
Arguments Name Arguments Specification
code return codec
msg return message

sp2_task

Arguments Example
arguments:
{ "api_id":73,
"command":"sp2_task",
"mac":"00:11:22:33:44:55",
"name":"Smart Plug 2",
"lock":0,
"periodic_task":[
{ "enable":1,
"on_time":"08:00",
"off_time":"15:00",
"repeat":0
},
{ "enable":1,
"on_time":"--:--",
"off_time":"00:00",
"repeat":127
}
] "timer_task":[
{ "on_enable":1,
"on_time":"2014-07-02 14:58:03"
"off_enable":0,

www.broadlink.com.cn 18 / 53
Open API of SDK for Smart Home Mobile App – User Manual

"off_time":"2014-07-02 15:58:03"
},
{ "on_enable":0,
"on_time":"2014-07-02 14:58:03"
"off_enable":1,
"off_time":"2014-07-03 16:58:03"
},
{ "on_enable":1,
"on_time":"2014-07-02 14:58:03"
"off_enable":1,
"off_time":"2014-07-05 18:58:03"
}
]
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
name Name of SP2
lock Whether SP2 device is locked or not.
periodic_task Periodic task of SP2.
enable Enable periodic task
on_time Start time of periodic tasks, if not set, set it to be"--:--".
off_time End time of periodic tasks, if not set, set it to be"--:--".
repeat Repetitive cycles of periodic tasks in one-week iteration, 0 means task is only executed
once (bit0: Sunday, bit1: Monday, bit2: Tuesday, bit3: Wednesday, bit4:Thursday, bit5:
Friday, bit6: Saturday).
timer_task Timer task of SP2.
on_enable Timer task.enable open.
on_time Timer task.enable open time.
off_enable Timer task.enable closure
off_time Timer task.enable closure time.

Note: While setting up a task, the previous task need to be set up at the same time. Task of adding and deleting
should use the same interface. The device name and locking status also need to be set.
Return Message
Retval:
{ "code":0,
"msg":"Set sp2 task success"
}
Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

sp2_current_power

Arguments Example
arguments:
{ "api_id":74,
"command":"sp2_current_power",
"mac":"00:11:22:33:44:55"

www.broadlink.com.cn 19 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"current_power":121.000000,
"msg":"Get sp2 current power success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
current_power Current real time power of device
msg return message

sp2_24_power

Arguments Example

arguments:
{ "api_id":75,
"command":"sp2_24_power",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"current_power":121.000000,
"24hour_power":[0.000000, 60.000000, 80.000000, ...],
"msg":"Get sp2 last 24hour power success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
current_power Current real time power of device
24hour_power SP2 power of last 24 hours, power data collected each 5 minutes and 288 data points in
total.
msg return message

www.broadlink.com.cn 20 / 53
Open API of SDK for Smart Home Mobile App – User Manual

sp2_week_power

Arguments Example
arguments:
{ "api_id":76,
"command":"sp2_week_power",
"mac":"00:11:22:33:44:55",
"week_index":2
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
week_index The specific week of current year(Start from 1)

Return Message
Retval:
{ "code":0,
"week_energy":[
{ "peak_energy":0.250000,
"low_energy":0.750000,
"on_time":50,
"standby_energy":0.180000
},
{ "peak_energy":0.450000,
"low_energy":1.250000,
"on_time":300,
"standby_energy":0.580000
}
]
"msg":"Get sp2 week's energy info success."
}

Arguments Specification
Arguments Name Arguments Specification
code return code
week_energy Device energy consumption statistics of a specific week, consumption data collected
each day and 7 data points in total.
peak_energy Energy consumption statistic of peak electricity
low_energy Energy consumption statistic of valley electricity
on_time Operation Time
standby_energy Energy consumption statistic of peak electricity
msg return message

sp2_month_power

Arguments Example

www.broadlink.com.cn 21 / 53
Open API of SDK for Smart Home Mobile App – User Manual

arguments:
{ "api_id":77,
"command":"sp2_month_power",
"mac":"00:11:22:33:44:55",
"year":2014,
"month_index":3
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
year Specific year
month_index Specific month

Return Message
Retval:
{ "code":0,
"month_energy":[
{ "peak_energy":0.250000,
"low_energy":0.750000,
"on_time":50,
"standby_energy":0.180000
},
{ "peak_energy":0.450000,
"low_energy":1.250000,
"on_time":300,
"standby_energy":0.580000
}
]
"msg":"Get sp2 month's energy info success."
}

Arguments Specification
Arguments Name Arguments Specification
code return code
month_energy Device energy consumption statistics of a specific week, consumption data collected
each day and 31 data points in total
peak_energy Energy consumption statistic of peak electricity
low_energy Energy consumption statistic of valley electricity
on_time Operation Time
standby_energy Energy consumption statistic of peak electricity
msg return message

sp2_year_power

Arguments Example
arguments:
{ "api_id":78,
"command":"sp2_year_power",
"mac":"00:11:22:33:44:55",
"year":2014

www.broadlink.com.cn 22 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
year Specific year)

Return Message
Retval:
{ "code":0,
"year_energy":[
{ "peak_energy":100.250000,
"low_energy":150.750000,
"on_time":1550,
"standby_energy":30.180000
},
{ "peak_energy":120.450000,
"low_energy":170.250000,
"on_time":3000,
"standby_energy":80.580000
}
]
"msg":"Get sp2 year's energy info success."
}

Arguments Specification
Arguments Name Arguments Specification
code return code
year_energy Device energy consumption statistics of a specific week, consumption data collected
each day and 12 data points in total.
peak_energy Energy consumption statistic of peak electricity
low_energy Energy consumption statistic of valley electricity
on_time Operation Time
standby_energy Energy consumption statistic of peak electricity
msg return message

sp2_get_standby_power

Arguments Example
arguments:
{ "api_id":79,
"command":"sp2_get_standby_power",
"mac":"00:11:22:33:44:55",
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message

www.broadlink.com.cn 23 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Retval:
{ "code":0,
"enable":1,
"standby_power":10
"msg":"Get sp2 standby power success."
}

Arguments Specification
Arguments Name Arguments Specification
code return code
enable Whether standby power takes effect or not
standby_power standby power
msg return message

sp2_set_standby_power

Arguments Example
arguments:
{ "api_id":80,
"command":"sp2_set_standby_power",
"mac":"00:11:22:33:44:55",
"enable":1,
"standby_power":5
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
enable Whether enable standby power or not
standby_power Set standby power

Retval:
{ "code":0,
"msg":"Set sp2 standby power success."
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

sp3_refresh

Arguments Example
arguments:
{ "api_id":82,

www.broadlink.com.cn 24 / 53
Open API of SDK for Smart Home Mobile App – User Manual

"command":"sp3_refresh",
"mac":"00:11:22:33:44:55"
}
Arguments Specification
Arguments Name Arguments Specification
api_id Command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"msg":"Refresh status success",
"status":0
"name":"Smart Plug",
"lock":0,
"periodic_task":[
{ "enable":1,
"on_time":"08:00:00",
"off_time":"15:00:00",
"repeat":0
},
{ "enable":1,
"on_time":"--:--:--",
"off_time":"00:00:00",
"repeat":127
}
]
"timer_task":[
{ "on_enable":1,
"on_time":"2014-07-02 14:58:03"
"off_enable":0,
"off_time":"2014-07-02 15:58:03"
},
{ "on_enable":0,
"on_time":"2014-07-02 14:58:03"
"off_enable":1,
"off_time":"2014-07-03 16:58:03"
},
{ "on_enable":1,
"on_time":"2014-07-02 14:58:03"
"off_enable":1,
"off_time":"2015-07-05 18:58:03"
}
],
"random_timer_task":{
"start_time": "08:00",
"end_time":"12:00",
"repeat":0,
"enable":1
},

"cycle_timer_task":{
"start_time":"08:00:00",
"end_time":"12:00:00",
"repeat":0,
"enable":1,

www.broadlink.com.cn 25 / 53
Open API of SDK for Smart Home Mobile App – User Manual

"on_level":60,
"off_level":100
}
"ele_protect":1,
"ele_protect_time":1,
"module_time":"2015-07-05 18:58:03"
}

Arguments Specification
Arguments Arguments Specification
code Return code
msg Return message
status Current switch status
(Spminiv2: 0: off 1:on)
(SP3: 0:all off,1:night light off,switch on
2:night light on,switch off 3:all on)
name Name of device
lock Is the device locked?
periodic_task Repeated timer
enable Enable repeated timer
on_time Set switch on time for repeated timer. Default is "--:--:--"
off_time Set switch off time for repeated timer. Default is "--:--:--"
repeat Repetitive cycles of periodic tasks in one-week iteration, 0 means task is only executed
once (bit0: Sunday, bit1: Monday, bit2: Tuesday, bit3: Wednesday, bit4:Thursday, bit5:
Friday, bit6: Saturday).
timer_task Timer task
on_enable Enable timer
on_time Start time
off_enable Disable timer
off_time End time
random_timer_task Random timer. Return null if it is not set.
start_time Start time of random timer
end_time End time of random timer

enable Enable random timer


cycle_timer_task Cycled timer. Return null if it is not set
start_time Start time of cycled timer
end_time End time of cycled timer
enable Enable cycled timer
on_level Keep on time. Unit: s, rang: <1H (3600s)
off_level Keep off time. Unit: s, rang: <1H (3600s)
ele_protect Charging protection. 1: On; 0: Off
ele_protect_time Charging protection time
module_time Module time

sp3_control

Arguments Sample

arguments:
{ "api_id":83,
"command":"sp3_control",
"mac":"00:11:22:33:44:55",

www.broadlink.com.cn 26 / 53
Open API of SDK for Smart Home Mobile App – User Manual

"status":1,
"mask":0
}

Arguments Specification
参数名称 参数说明
api_id Command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
status Set switch status (required), 0:All off
1:Night light off, switch on
2:Night light on, switch off
3:All on
mask Set controllable services (required)),0:All available
1:Night light available, switch unavailable
2: light unavailable, switch available
Night
3:All unavailable

Return Message
Retval:
{ "code":0,
"msg":"Set sp3 status success"
}

Arguments Specification
Arguments Name Arguments Specification
code Return code
msg Return message

sp3_task

Arguments Sample
arguments:
{ "api_id":84,
"command":"sp3_task",
"mac":"00:11:22:33:44:55",
"name":"Smart Plug",
"lock":0,
"periodic_task":[
{ "enable":1,
"on_time":"08:00:00",
"off_time":"15:00:00",
"repeat":0,
"on_done":0,
"off_done":0,
"mask":2
},
{ "enable":1,
"on_time":"--:--:--",
"off_time":"00:00:00",
"repeat":127

www.broadlink.com.cn 27 / 53
Open API of SDK for Smart Home Mobile App – User Manual

"on_done":0,
"off_done":0,
"mask":1
}
] "timer_task":[
{ "on_enable":1,
"on_time":"2014-07-02 14:58:03"
"off_enable":0,
"off_time":"2014-07-02 15:58:03",
},
{ "on_enable":0,
"on_time":"2014-07-02 14:58:03"
"off_enable":1,
"off_time":"2014-07-03 16:58:03"
},
{ "on_enable":1,
"on_time":"2014-07-02 14:58:03"
"off_enable":1,
"off_time":"2014-07-05 18:58:03"
}
],
"random_timer_task":{
"start_time": "08:00",
"end_time":"12:00",
"repeat":0,
"enable":1
}

"cycle_timer_task":{
"start_time":"08:00:00",
"end_time":"12:00:00",
"repeat":0,
"enable":1,
"on_level":60,
"off_level":100
}
}

Arguments Specification
Arguments Arguments Specification
api_id Command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
name Name of device
lock Is the device locked?
periodic_task Repeated timer(Max 16 timers can be added for switch and night light together.)
enable Enable repeated timer
on_time Set switch on time for repeated timer. Default is "--:--:--"
off_time Set switch off time for repeated timer. Default is "--:--:--"
repeat Repetitive cycles of periodic tasks in one-week iteration, 0 means task is only executed
once (bit0: Sunday, bit1: Monday, bit2: Tuesday, bit3: Wednesday, bit4:Thursday, bit5:
Friday, bit6: Saturday).
on_done Is “turn on” command executed? 0: No, 1: Yes
off_done Is “turn off” command executed? 0: No, 1: Yes
mask Set timer for switch or night light
1: Night light

www.broadlink.com.cn 28 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Arguments Specification


2: Switch
Note: Max 16 timers can be added for switch and night light together.
timer_task Timer tasks (max 8)
on_enable Enable timer
on_time Start time
off_enable Disable timer

off_time End time


random_timer_task Random timer. Return null if it is not set.
start_time Start time of random timer
end_time End time of random timer
enable Enable random timer
cycle_timer_task Cycled timer. Return null if it is not set
start_time Start time of cycled timer
end_time End time of cycled timer
enable Enable cycled timer
on_level Keep on time. Unit: s, rang: <1H (3600s)
off_level Keep off time. Unit: s, rang: <1H (3600s)

Note: While setting up a task, the previous task need to be set up at the same time. Task of adding and deleting
should use the same interface. The device name and locking status also need to be set.
Return Message
Retval:
{ "code":0,
"msg":"Set task success"
}
Arguments Specification
Arguments Name Arguments Specification
code Return code
msg Return message

sp3_set_eleprotect

Arguments Sample

arguments:
{ "api_id":85,
"command":"sp3_set_eleprotect",
"mac":"00:11:22:33:44:55",
"enable":1,
"time":3600
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
enable Charging protection (all timers will be disabled during the charging protection period)
1: Enable
2: Disable

www.broadlink.com.cn 29 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Name Arguments Specification


time Charging protection time. Default: 3H, unit: s.
This function will be automatically disabled after 3 hours.

Return Message
Retval:
{ "code":0,
"msg":"Set eleprotect success"
}

Arguments Specification
Arguments Arguments Specification
code Return code
msg Return message

sp3_set_day_saving_time

Arguments Sample
arguments:
{ "api_id":86,
"command":"sp3_set_day_saving_time",
"mac":"00:11:22:33:44:55",
"enable":1,
"start_time":"2015-11-15 08:00:00",
"end_time":"2015-11-15 15:00:00",
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
enable Daylight saving function (for some available functions)
1: Enable
2: Disable
start_time Start time of daylight saving
end_time End time of daylight saving

Return Message
Retval:
{ "code":0,
"msg":"Set day saving time success"
}

Arguments Specification
Arguments Name Arguments Specification
code Return code
msg Return message

www.broadlink.com.cn 30 / 53
Open API of SDK for Smart Home Mobile App – User Manual

sp3_get_day_saving_time

Arguments Sample
arguments:
{ "api_id":87,
"command":"sp3_get_day_saving_time",
"mac":"00:11:22:33:44:55",
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"msg":"get day saving time success",
"enable":1,
"start_time":"2015-11-15 08:00:00",
"end_time":"2015-11-15 15:00:00"
}

Arguments Specification
Arguments Name Arguments Specification
code Return code
msg Return message
enable Daylight saving function (for some available functions)
1: Enable
2: Disable
start_time Start time of daylight saving
end_time End time of daylight saving

rm1_auth

Arguments Example
arguments:
{ "api_id":101,
"command":"rm1_auth",
"mac":"00:11:22:33:44:55",
"password":1028000492
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:

www.broadlink.com.cn 31 / 53
Open API of SDK for Smart Home Mobile App – User Manual

{ "code":0,
"temperature":23.100000,
"msg":"rm1 auth success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
temperature Current ambient temperature of the device
msg return message

rm1_study

Arguments Example
arguments:
{ "api_id":102,
"command":"rm1_study",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"msg":"rm1 enter study mode success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

rm1_code

Arguments Example
arguments:
{ "api_id":103,
"command":"rm1_code",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional)

www.broadlink.com.cn 32 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Name Arguments Specification


mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{
"code":-100,
"msg":"rm1 check data failed"
}

Retval:
{"code":0,
"data":"2600e6006f390e2a0e290d100d100e0f0e290e0f0e0f0e2a0e290d100e2a0e0e0f0e0e2a0d2a0e0f0e2a0e",
"msg":"rm1 check data success"
}

Arguments Specification
Arguments Name Arguments Specification
code Return code, -100 means no learning data found, while 0 means learning data found.
data Learned control code
msg return message

rm1_send

Arguments Example
arguments:
{ "api_id":104,
"command":"rm1_send",
"mac":"00:11:22:33:44:55",
"data":"2600e6006f390e2a0e290d100d100e0f0e290e0f0e0f0e2a0e290d100e2a0e0e0f0e0e2a0d2a0e0f0e2a0e"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"msg":"rm1 send data success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

www.broadlink.com.cn 33 / 53
Open API of SDK for Smart Home Mobile App – User Manual

rm2_refresh

Arguments Example
arguments:
{ "api_id":131,
"command":"rm2_refresh",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"temperature":23.100000,
"msg":"Refresh rm2 status success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
temperature Current ambient temperature of the device
msg return message

rm2_study

Arguments Example
arguments:
{ "api_id":132,
"command":"rm2_study",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"msg":"rm2 enter study mode success"
}

Arguments Specification
Arguments Name Arguments Specification

www.broadlink.com.cn 34 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Name Arguments Specification


code return code
msg return message

rm2_code

Arguments Example
arguments:
{ "api_id":133,
"command":"rm2_code",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification

api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated

Return Message
Retval:
{
"code":-1,
"msg":"rm2 check data failed"
}

Retval:
{ "code":0,
"data":"2600e6006f390e2a0e290d100d100e0f0e290e0f0e0f0e2a0e290d100e2a0e0e0f0e0e2a0d2a0e0f0e2a0e",
"msg":"rm2 check data success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
data Learned control code
msg return message

rm2_send

Arguments Example
arguments:
{ "api_id":134,
"command":"rm2_send",
"mac":"00:11:22:33:44:55",
"data":"2600e6006f390e2a0e290d100d100e0f0e290e0f0e0f0e2a0e290d100e2a0e0e0f0e0e2a0d2a0e0f0e2a0e"
}

Arguments Specification

www.broadlink.com.cn 35 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Name Arguments Specification


api_id command ID

command Command (optional).


mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"msg":"rm2 send data success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

rmpro_freq_scan

Arguments Example
arguments:
{ "api_id":135,
"command":"rmpro_freq_scan",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"msg":"Set freq scan success."
}

Return Message
Return Message Arguments Specification
code return code
msg return message

rmpro_freq_scan_status

Arguments Example
arguments:
{ "api_id":136,
"command":"rmpro_freq_scan_status",
"mac":"00:11:22:33:44:55"
}

www.broadlink.com.cn 36 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"msg":"Get freq scan status success",
"status":1,
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message
status Get scanning frequency status,0:not start or scanning,1:success,4:fail

rmpro_scan_study

Arguments Example
arguments:
{ "api_id":137,
"command":"rmpro_scan_study",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"msg":"Enter study mode success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

rmpro_cancel_study

Arguments Example

www.broadlink.com.cn 37 / 53
Open API of SDK for Smart Home Mobile App – User Manual

arguments:
{ "api_id":138,
"command":"rmpro_cancel_study",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"msg":"Cancel study mode success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

a1_refresh

Arguments Example
arguments:
{ "api_id":161,
"command":"a1_refresh",
"mac":"00:11:22:33:44:55",
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"temperature":25.0,
"humidity":56.3,
"light":3,
"air":2,
"noisy":1,
"name":"A1 Eair",
"lock":0,
"msg":"Refresh a1 sensor's value success"
}
Arguments Specification
Arguments Name Arguments Specification
code return code
temperature temperature, floating-point type

www.broadlink.com.cn 38 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Name Arguments Specification


humidity humidity value, floating point type
light light: light: illuminance, integer (0:dark 1:dim 2:normal 3:bright)
air air: air: air quality, integer (0:excellent 1:fine 2:normal 3:bad)
noisy noisy: noise, integer (0:quiet 1:normal 2:noisy)
name name: name: device name, string
lock lock: lock: device locking status, integer (0:unlocked 1:locked)
msg return message

a1_task_list

Arguments Example
arguments:
{ "api_id":162,
"command":"a1_task_list",
"mac":"00:11:22:33:44:55",
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0, “list”:[
{
"mac": "00:11:22:33:44:55",
"time_enable":0,
"task_enable":1,
"index":0,
"start_time":"10:30",
"end_time":"18:30",
"repeat":7, "sensor_type":0,
"sensor_trigger": 0,
"sensor_value":25.0,
"task_name":" Turn on TV "
},
{
"mac": "55:44:33:22:11:00",
"time_enable":1,
"task_enable":1,
"index":2,
"start_time":"10:30",
"end_time":"17:30",
"repeat":5,
"sensor_type":2,
"sensor_trigger": 1,
"sensor_value":3.0,
"task_name":" Turn on audio "
}
],

www.broadlink.com.cn 39 / 53
Open API of SDK for Smart Home Mobile App – User Manual

"msg":"Get a1 task list success"


}

Arguments Specification
Arguments Name Arguments Specification
code return code
code return code
list Task list
mac Mac address of the device to execute tasks.
time_enable Time enable Integer
task_enable Task enable Integer
index Task Number, (used when deleting task) Integer
start_time Start time of task executing String
end_time End time of task executing String
repeat Repetitive cycles of periodic tasks in one-week iteration, 0 means task is only executed
once (bit0: Sunday, bit1: Monday, bit2: Tuesday, bit3: Wednesday, bit4:Thursday, bit5:
Friday, bit6: Saturday). Integer
sensor_type Sensor types of the task execution condition (0: temperature 1:humidity
2:illuminance 3:air quality 4:noise). Integer
sensor_trigger The change in the trend of the sensor value of the task execution condition (0:rise 1:
fall) Integer
sensor_value The sensor value of the task execution condition. float
task_name Name of the executed task. String
msg return message

a1_add_task

Arguments Example
arguments:
{ "api_id":163,
"command":"a1_add_task",
"mac":"00:11:22:33:44:55",
"task_name": " Turn off air con ",
"time_enable": 1,
"task_enable": 1,
"start_time": "2014-06-06 10:30:00",
"end_time": "2014-06-06 18:30:00",
"repeat": 7,
"sensor_type": 0,
"sensor_trigger": 1,
"sensor_value" : 20.0,
"device_mac": "aa:bb:cc:dd:ee:ff",
"device_id": 25,
"device_key": "097628343fe99e23765c1513accf8b02",
"device_type": "RM2",
"task_data":"2600e6006f390e2a0e290d100d100e0f0e290e0f0e0f0e2a0e290d100e2a0e0e0f0e0e2a0d2a0e0f0e2a0e",

"status": 0
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID

www.broadlink.com.cn 40 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Name Arguments Specification


command Command (optional).
mac MAC address of the device needs to be manipulated.
task_name Name of the added task
time_enable Task time enable.
task_enable Task enable
start_time Task start time. must be passed into time parameter in this format, especially day,month
and year are only available when time_enable is set to be 0 (day, month and year must
be the exact time of the day)
end_time Task end time. must be passed into time parameter in this format, especially day,month
and year are only available when time_enable is set to be 0 (day, month and year must
be the exact time of the day)
repeat Repetitive cycles of periodic tasks. is available when time_enable is 1
sensor_type Sensor types of the task execution condition.
sensor_trigger The change in the trend of the sensor value of the task execution condition.
sensor_value The sensor value of the task execution condition.
device_mac Mac address of the device to execute tasks.
device_id ID of the device to execute tasks. (the value returned from probe_list)
device_key Key of the device to execute tasks. (the value returned from probe_list)
device_type ID of the device to execute tasks. (the value returned from probe_list)
task_data Command to execute tasks. (It is invalid when device to execute tasks is SP2. If the
device is RM2, it is set to be the returned data of rm2_code.)
status ID of the device to execute tasks. Status of the device to execute tasks. (Only is valid
when the device is SP2, otherwise the field should be canceled.)

Return Message
Retval:
{ "code":0, “list”:[
{
"mac": "00:11:22:33:44:55",
"time_enable":0,
"task_enable":1,
"index":0,
"start_time":"10:30",
"end_time":"18:30",
"repeat":7,
"sensor_type":0,
"sensor_trigger": 0,
"sensor_value":25.0,
"task_name":" Turn on TV "
},
{
"mac": "55:44:33:22:11:00",
"time_enable":1,
"task_enable":1,
"index":2,
"start_time":"10:30",
"end_time":"17:30",
"repeat":5,
"sensor_type":2,
"sensor_trigger": 1,
"sensor_value":3.0,
"task_name":" Turn on audio "
}
],
"msg":"Get a1 task list success"

www.broadlink.com.cn 41 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Specification
Arguments Name Arguments Specification
code return code
list Task list
mac Mac address of the device to execute tasks.
time_enable Time enable Integer
task_enable Task enable Integer
index Task Number, (used when deleting task) Integer
start_time Start time of task executing String
end_time End time of task executing String
repeat Repetitive cycles of periodic tasks in one-week iteration, 0 means task is only executed
once (bit0: Sunday, bit1:Monday, bit2:Tuesday, bit 3:Wednesday,bit4:Thursday,
bit5:Friday, bit6: Saturday). Integer
sensor_type Sensor types of the task execution condition (0: temperature 1:humidity
2:illuminance 3:air quality 4:noise). Integer
sensor_trigger The change in the trend of the sensor value of the task execution condition (0:rise 1:
fall) Integer
sensor_value The sensor value of the task execution condition. float
task_name Name of the executed task. String
msg return message

a1_del_task

Arguments Example
arguments:
{ "api_id":164,
"command":"a1_del_task",
"mac":"00:11:22:33:44:55",
"index": 0
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
index The index of tasks need to be deleted. (The value is obtained from the returned list)

Return Message
Retval:
{ "code":0, “list”:[
{
"mac": "00:11:22:33:44:55",
"time_enable":0,
"task_enable":1,
"index":0,
"start_time":"10:30",
"end_time":"18:30",
"repeat":7,
"sensor_type":0,
"sensor_trigger": 0,

www.broadlink.com.cn 42 / 53
Open API of SDK for Smart Home Mobile App – User Manual

"sensor_value":25.0,
"task_name":" Turn on TV "
},
{
"mac": "55:44:33:22:11:00",
"time_enable":1,
"task_enable":1,
"index":2,
"start_time":"10:30",
"end_time":"17:30",
"repeat":5, "sensor_type":2,
"sensor_trigger": 1,
"sensor_value":3.0,
"task_name":" Turn on audio "
}
],
"msg":"Get a1 task list success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
list Task list
mac Mac address of the device to execute tasks.
time_enable Time enable Integer
task_enable Task enable Integer
index Task Number, (used when deleting task) Integer
start_time Start time of task executing String
end_time End time of task executing String
repeat Repetitive cycles of periodic tasks in one-week iteration, 0 means task is only executed
once (bit0: Sunday, bit1:Monday, bit2:Tuesday, bit3:Wednesday,bit4:Thursday,
bit5:Friday, bit6: Saturday). Integer
sensor_type Sensor types of the task execution condition (0: temperature 1:humidity
2:illuminance 3:air quality 4:noise). Integer
sensor_trigger The change in the trend of the sensor value of the task execution condition (0:rise 1:
fall) Integer
sensor_value The sensor value of the task execution condition. float
task_name Name of the executed task. String
msg return message

rmac_current_power
Arguments Example
arguments:
{ "api_id":190,
"command":"rmac_current_power",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).

www.broadlink.com.cn 43 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Name Arguments Specification


mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"current_power":121.000000,
"msg":"Get rmac current power success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
current_power Device current real time power(unit:W)
msg return message

rmac_24_power
Arguments Example
arguments:
{ "api_id":191,
"command":"rmac_24_power",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional
mac MAC address of the device needs to be manipulated.

Return Message
Retval:
{ "code":0,
"current_power":121.000000,
"24hour_power":[0.000000, 60.000000, 80.00000
0, ...],
"msg":"Get rmac last 24hour power success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
current_power Device current real time power(unit:W)
24hour_power RMAC power of last 24 hours, power data collected each 5 minutes and 288 data points
in total.
msg return message

www.broadlink.com.cn 44 / 53
Open API of SDK for Smart Home Mobile App – User Manual

rmac_week_energy
Arguments Example
arguments:
{ "api_id":192,
"command":"rmac_week_energy",
"mac":"00:11:22:33:44:55",
"week_index":2
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
week_index The specific week of current year(Start from 1)

Return Message
Retval:
{ "code":0,
"week_energy":[
{ "on_time":50,
"standby_energy":0.180000,
"peak_energy":0.250000,
"low_energy":0.750000
},
{ "on_time":300,
"standby_energy":0.580000,
"peak_energy":0.450000,
"low_energy":1.250000
}
]
"msg":"Get rmac week's energy info success."
}

Arguments Specification
Arguments Name Arguments Specification
code return code
week_energy Device energy consumption statistics of a specific week, consumption data collected
each day and 7 data points in total.
peak_energy Energy consumption statistic of peak electricity(unit:KWH)
low_energy Energy consumption statistic of valley electricity(unit:KWH)
on_time Operation Time
standby_energy Energy consumption statistic of peak electricity(unit:KWH)
msg return message

rmac_month_energy
Arguments Example
arguments:
{ "api_id":193,

www.broadlink.com.cn 45 / 53
Open API of SDK for Smart Home Mobile App – User Manual

"command":"rmac_month_energy",
"mac":"00:11:22:33:44:55",
"year":2016,
"month_index":1
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional)
mac Mac address of the device to execute tasks.
year Specific year
month_index The specific month of current year(Start from 1)

Return Message
Retval:
{ "code":0,
"month_energy":[
{ "on_time":50,
"standby_energy":0.180000,
"peak_energy":0.250000,
"low_energy":0.750000
},
{ "on_time":300,
"standby_energy":0.580000,
"peak_energy":0.450000,
"low_energy":1.250000
}
]
"msg":"Get rmac month's energy info success."
}

Arguments Specification
Arguments Name Arguments Specification
code return code
month_energy Device energy consumption statistics of a specific week, consumption data collected
each day and 31 data points in total.
peak_energy Energy consumption statistic of peak electricity(unit:KWH)
low_energy Energy consumption statistic of valley electricity(unit:KWH)
on_time Operation Time
standby_energy Energy consumption statistic of peak electricity(unit:KWH)
msg return message

rmac_year_energy
Arguments Examplearguments:
{ "api_id":194,
"command":"rmac_year_energy",
"mac":"00:11:22:33:44:55",
"year":2015
}

www.broadlink.com.cn 46 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
year Specific year

Return Message
Retval:
{ "code":0,
"year_energy":[
{"on_time":1550,
"standby_energy":30.180000,
"peak_energy":100.250000,
"low_energy":150.750000
},
{ "on_time":3000,
"standby_energy":80.580000,
"peak_energy":120.450000,
"low_energy":170.250000
}
]
"msg":"Get rmac year's energy info success."
}

Arguments Specification
Arguments Name Arguments Specification
code return code
year_energy Device energy consumption statistics of a specific week, consumption data collected
each day and 12 data points in total.
peak_energy Energy consumption statistic of peak electricity(unit:KWH)
low_energy Energy consumption statistic of valley electricity(unit:KWH)
on_time Operation Time
standby_energy Energy consumption statistic of peak electricity(unit:KWH)
msg return message

rmac_get_standby_power
Arguments Example
arguments:
{ "api_id":195,
"command":"rmac_get_standby_power",
"mac":"00:11:22:33:44:55",
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Return Message
Retval:

www.broadlink.com.cn 47 / 53
Open API of SDK for Smart Home Mobile App – User Manual

{ "code":0,
"enable":1,
"standby_power":10
"msg":"Get rmac standby power success."
}

Arguments Specification
Arguments Name Arguments Specification
code command ID
enable Whether standby power takes effect or not,1-on,0-off
standby_power standby power(unit:W)
msg return message

rmac_set_standby_power
Arguments Example
arguments:
{ "api_id":196,
"command":"rmac_set_standby_power",
"mac":"00:11:22:33:44:55",
"enable":1,
"standby_power":5
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated
enable Whether enable standby power or not,1-on,0-off
standby_power Set standby power(unit:W)

Retval:
{ "code":0,
"msg":"Set rmac standby power success."
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

rmac_set_low_time
Arguments Example
arguments:
{ "api_id":197,
"command":"rmac_set_low_time",
"mac":"00:11:22:33:44:55",
"start_hour":20,

www.broadlink.com.cn 48 / 53
Open API of SDK for Smart Home Mobile App – User Manual

"start_min":10,
"end_hour":22,
"end_min":10
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.
start_hour valley electricity start time -hour part
start_min valley electricity start time -min part
end_hour valley electricity end time- hour part
end_min valley electricity end time - min part

Retval:
{ "code":0,
"msg":"Set rmac standby power success."
}
Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

rmac_get_all_energy
Arguments Example
arguments:
{ "api_id":198,
"command":"rmac_get_all_energy",
"mac":"00:11:22:33:44:55"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be manipulated.

Retval:
{ "code":0,
"msg":"get rmac all energy success."
"energy": 0,
"voltage": 0,
"current": 0,
"frequent": 0,
"active_power": 0,
"reactive_power": 0,
"apparent_power": 0,
"power_factor": 0,
}

Arguments Specification
Arguments Name Arguments Specification

www.broadlink.com.cn 49 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Name Arguments Specification


code return code
msg return message
energy Real time power(unit:KWH)
voltage Real time voltage(unit:V)
current Real time current(unit:A)
frequent Real time frequency(unit:Hz)
active_power Real time active power(unit:W)
reactive_power Real time reactive power (unit:W)
apparent_power Real time apparent power(unit:W)
power_factor Power factor

easyconfig

Arguments Example
arguments:
{ "api_id":10000,
"command":"easyconfig",
"ssid":"abcdefg",
"password":"11111111",
"broadlinkv2":1,
"dst":"192.168.3.1"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
ssid Name of network that the device will connect to. (mandatory)
password Password of network that the device will connect to. (mandatory)
broadlinkv2 Whether the device need to be configured uses the second and later generation
broadlink wireless module or not. (optional, the default setting is second generation
module))
dst (required, filling the gateway address can accelerate the configuration speed)
*Note: the interface is not thread-safe*
Retval:
{ "code":0,
"msg":"easyconfig success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

Cancel easyconfig

Arguments Example

www.broadlink.com.cn 50 / 53
Open API of SDK for Smart Home Mobile App – User Manual

arguments:
{ "api_id":10001,
"command":"cancel_easyconfig"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).

Return Message
*Note: the interface is not thread-safe*
Retval:
{ "code":0,
"msg":"easyconfig success"
}

Arguments Specification
Arguments Name Arguments Specification
code return code
msg return message

Obtain wifi_info

Arguments Example
arguments:
{ "api_id":10002,
"command":"wifi_info",
"mac":"11:22:33:44:55:66",
"ipaddr":"192.168.1.1"
}

Arguments Specification
Arguments Name Arguments Specification
api_id command ID
command Command (optional).
mac MAC address of the device needs to be obtained. (Mandatory)
ipaddr IP address of current connected router(Mandatory)

Return Message
Retval:
{ "code":0,
"msg":"Get wifi info success",
"info":
{
"ssid":"ChinaNet",
"pwd":"12345678"
}
}
Arguments Specification
Arguments Name Arguments Specification
code code: return code 0 means success, others means error; if return -100 means not support
this command

www.broadlink.com.cn 51 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Arguments Name Arguments Specification


msg return message
info SSID and password of the router Only get the contents if it is successful

Note: Except the explained return code, the corresponding error informations of rest return code are shown below
Return code Info
0 Success
-1 The network that devices are connected to or the password of the network has been changed.
The device has logged in at another location, if there is a need to continue to control the
-2
device, please log in again (Especially for rm1/sp1)
-3 The device is offline
-4 Unsupported operations
-5 Storage space is full
-6 Data structure is abnormal
Device has been reset, and need to enter the LAN for a new configuration. (especially for the
-7
device beyond sp1/rm1)
-100 Timeout
-101 Network thread cannot find the device
-102 There is not enough memory
-103 The device is uninitialized
-104 Network thread has been suspended
-105 Type of return message is error
-106 Operations are too frequent
-107 The server has declined the operation of this license, please contact the custmer sevice
-108 The device is not connected to the LAN
-10000 Unknown error

www.broadlink.com.cn 52 / 53
Open API of SDK for Smart Home Mobile App – User Manual

Hangzhou Gubei Electronics Technology Co., Ltd.


Room 106, Building 1, No. 611 Jianghong Road, Binjiang, Hangzhou, Zhejiang, P.R.China
T: +86-571-85159281 F: +86-571-86631817
E: intl@broadlink.com.cn W: www.ibroadlink.com.cn
Download APP & Follow Us:
Facebook: facebook.com/broadlinkdna
Twitter: twitter.com/broadlinkdna
LinkedIn: cn.linkedin.com/in/broadlink

e-Control APP Facebook Twitter LinkedIn

www.broadlink.com.cn 53 / 53

Вам также может понравиться