RM Plugin API Server [Alpha]
Version: 1.1.7 (45)
This is a Json API server acting as a HTTP Bridge to enable access to your Broadlink devices via simple HTTP commands or URLs.
This release is pretty much in Alpha state, many things might break or does not work properly. But I hope you like the progress so far.
Do send your bug reports, feature requests, feedbacks, cheers, etc. to
[email protected].
Recommended setup:
This was designed to work with only Broadlink devices in the same WiFi network. 3G Bridge will not be used.
This Web/API server always runs as a service in background, and it will drain your battery quickly. It is not recommended to use on your daily mobile phone. It was intended to run on Android boxes or other Android devices permanently connected to a power source at home.
Web Console
This is a big feature in the making. This will let you control all your devices, manage codes & learn new code via a web browswer.
Take a look at this awesome work-in-progress demo so far.
DEMO HERE
API Syntax
SEND A CODE
http://192.168.1.102:9876/send
This API let you send a code via a given Broadlink device.
Works with either GET or POST request.
Parameters:
deviceMac : The hardware MAC address of your Broadlink devices. You can use /devices API below to obtain this, or obtain it from RM Plugin app - under Device List. Acceptable MAC formats are (case insensitive):
codeId : The ID of the code to be sent. You can use /codes API below to obtain this, or obtain it from RM Plugin app - under Code List.
To control on/off devices such as SP2 or SPMini, use one of the following parameters:
on=true/false
off=true/false
codeId=0/1
repeat : (optional) Number of times to send the code. Values 0 or 1 will not repeat the code. Value 2 means send the code 2 times.
Examples:
http://192.168.1.102:9876/send?deviceMac=bb&codeId=25
http://192.168.1.102:9876/send?deviceMac=bb&codeId=25
http://192.168.1.102:9876/send?deviceMa ... 5&repeat=3
http://192.168.1.102:9876/send?deviceMa ... ff&on=true
http://192.168.1.102:9876/send?deviceMa ... f&on=false
Response:
{msg: "Code Fan • Mist successfully sent", status: "ok", codeId: "19", deviceMac: "b"}
LEARN A CODE
http://192.168.1.102:9876/study?deviceMac=b
Executing this command will put RM device into 'study mode' for at most 30 seconds.
Orange LED on RM device will lit up until a IR/RF code is detected. Use /get_code API to retrieve the learnt code.
Works with either GET or POST request.
RETRIEVE STUDIED CODE
http://192.168.1.102:9876/get_code?deviceMac=b&name=My new code
Retrieve the code that has just been learned in 'study mode' by previous API and save it as a new code.
Works with either GET or POST request.
Parameters:
deviceMac : The hardware MAC address of your Broadlink RM device.
name : Save the studied code with this name.
DEVICES LIST
http://192.168.1.102:9876/devices
Show the list of your configured Broadlink devices.
Works with either GET or POST request.
Response:
[{"name":" Smart Plug ","typecode":10026,"lanaddr":"192.168.1.","type":"RM2+","mac":"b"}]
CODES LIST
http://192.168.1.102:9876/codes
Show the list of your codes.
Works with either GET or POST request.
Response:
[{"
all the code I've made my RM2+ learn}]
FIND A DEVICE
http://192.168.1.102:9876/devices?deviceMac=b
Find a device with the given MAC address.
Works with either GET or POST request.
FIND A CODE
http://192.168.1.102:9876/codes?codeName=tv
Find a code with the given name.
Works with either GET or POST request.
GET TEMPERATURE (ON RM)
http://192.168.1.102:9876/temperature?deviceMac=b
Retrieve current temperature reading on a RM device (RM2, RM Home, RM Pro).
Works with either GET or POST request.
Response:
{"status":"ok","temperature":"30.8","timestamp":"1455356271220","deviceMac":"b"}
GET ON/OFF STATUS
http://192.168.1.102:9876/status?device ... c:dd:ee:ff
Retrieve current on/off status on a SP device (SP2 or SPMini).
Works with either GET or POST request.
Response:
{"on_off_status":1,"status":"ok","timestamp":"1455356271220","deviceMac":"b"}
GET NIGHT LIGHT ON/OFF STATUS (CONTROS ONLY)
http://192.168.1.102:9876/contros_statu ... c:dd:ee:ff
Retrieve current on/off status of the night light on a Contros device (SP-CC).
Works with either GET or POST request.
Response:
{"led_status":0,"on_off_status":1,"status":"ok","timestamp":"1455356271220","deviceMac":"b"}
GET ENERGY READING (SP2 ONLY)
http://192.168.1.102:9876/current_power ... c:dd:ee:ff
Retrieve current energy reading on a SP2 device.
Works with either GET or POST request.
Response:
{"status":"ok","timestamp":"1455357197117","current_power":0.823000,"deviceMac":"b"}
DELETE A DEVICE
http://192.168.1.102:9876/delete?deviceMac=b
Delete a device from device list.
Note that deleted device will be automatically detect again if it is within LAN network.
Works with either GET or POST request.
DELETE A CODE
http://192.168.1.102:9876/delete?codeId=123
Delete a code from code list.
Works with either GET or POST request.
(RE)START WEB SERVER FROM TASKER
If you want to use Tasker to manage or re-start this web service in case it crashes or stopped, use the following parameters:
Category: Default
Package: us.originally.tasker
Class: us.originally.tasker.service.WebServerService
Target: Service
Leave the other parameters empty.
TODO
These features are currently planned to be released in future updates:
Proper support for Contros device (SPMini-CC)
Read sensor data from A1 device
More API endpoints
TBC: Pretty web-based interface to manage devices & codes
Drop me an email to
[email protected] to let me know what do you want to see in future updates.
Proudly brought to you by the cool folks at Originally US.