This is a Node.js module available through the npm registry.
There is also an unaffiliated similar project written in Python lbschenkel/broadlink-bridge
Global installation using the following command is recommended:
$ npm i -g broadlink-bridge
Alternatively, the repo can be cloned and linked instead:
$ git clone https://github.com/401unauthorized/broadlink-bridge.git && cd broadlink-bridge && npm i && npm link
Run the CLI command to start the server:
$ broadlink-bridge start -p <port> -t <uuid-based-token>,<uuid-based-token>,...
-p <port>
sets the port
-t <uuid-based-token>,...
comma separated list of user created API tokens
Please note, the following was only tested with the RM mini3
Connecting a new BroadLink device on your local wireless network:
Number | Security |
---|---|
0 | none (open) |
1 | WEP |
2 | WPA1 |
3 | WPA2 |
4 | WPA1/2 |
$ broadlink-bridge connect -w wifi_name -p wifi_password -s 3
To locate configuration and data files on your machine, run the following:
$ broadlink-bridge files
Prints the following information to stdout
{
"db.json": "/path/to/db.json",
"db-example.json": "/path/to/db-example.json",
".env": "/path/to/.env",
"postman-bearer-token": "/path/to/broadlink-bridge_bearer_auth.postman_collection.json",
"postman-query-string": "/path/to/broadlink-bridge_query_string_auth.postman_collection.json"
}
This is the local JSON database file used for Broadlink-Bridge.
While the server is not running, this file can be manually edited for advanced use cases.
This is a starting example of local JSON database file for Broadlink-Bridge.
Rename this file to db.json
for use with the example postman collections.
This file is used to store persistant environmental variables and sensitive information for the server.
After installation, it is advised to create/update this file.
Example of storing information in this file:
PORT=8080
TOKENS=aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa,12345678-9012-3456-7890-123456789012
This postman collection provides example requests for interacting with the server using authentication bearer tokens.
<insert-API-token-here>
in the .json
file with an API Token used by the serverThis postman collection provides example requests for interacting with the server using query string tokens.
<insert-API-token-here>
in the .json
file with an API Token used by the serverAPI tokens are required with most endpoints and may be defined in the following ways:
Passed in as an argument
$ broadlink-bridge start -t <uuid-based-token>,<uuid-based-token>,...
Defined in the
.env
file
TOKENS=<uuid-based-token>,<uuid-based-token>,...
Run the CLI command to start the server:
$ broadlink-bridge start -p <port> -t <uuid-based-token>,<uuid-based-token>,...
For a full list of commands, enter the following:
$ broadlink-bridge --help
Use the following API endpoints described in this documentation to perform the steps:
The JSON database file contains two, top level fields: blasters
& devices
.
blasters
contains an array of blaster objects.
devices
contains an array of device objects.
A BroadLink IR Blaster
{
"id": "pMtEfSYMmg",
"name": "Basement Blaster",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF",
"devices": [ "GZFnCHSDM" ],
"active": false
}
id: An auto-generated short ID
name: A user entered blaster name
type: A user entered blaster identifier
address: LAN IP address for the blaster
port: Port for the blaster
mac: MAC address for the blaster
devices: An array of device IDs this blaster controls
active: Is the server able to reach the blaster? (updated dynamically)
Any Device with IR Receiver Capabilities
{
"id": "GZFnCHSDM",
"name": "Basement Projector",
"type": "PROJECTOR",
"commands": []
}
id: An auto-generated short ID
name: A user entered device name
type: A user entered device type (not used)
commands: An array of IR command objects for the device
IR Codes & Metadata
{
"command": "power on",
"repeat": 0,
"delay": 0,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
}
command: A user entered command name (must be URL encodable)
repeat: A user entered repeat count for the command (not used)
delay: A user entered milliseconds delay between repeats for the command (not used)
data: A user entered or a blaster captured hex string representation of an IR command
{
"blasters": [
{
"id": "pMtEfSYMmg",
"name": "Basement Blaster",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF",
"devices": [
"GZFnCHSDM"
],
"active": false
}
],
"devices": [
{
"id": "GZFnCHSDM",
"name": "Basement Projector",
"type": "PROJECTOR",
"commands": [
{
"command": "power on",
"repeat": 0,
"delay": 0,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
}
]
}
]
}
Most endpoints require authentication via an
authentication bearer token
or aquery string token
"Authentication": "Bearer <token-here>"
?token=<token-here>
Request (Body)
--
Response (Body)
Welcome to BroadLink Bridge!
Request (Body)
--
Response (Body)
OK
Request (Body)
--
Response (Body)
{
"version": "1.1.1"
}
Request (Body)
--
Response (Body)
{
"timestamp": 1589701522333,
"uptime": {
"duration": 64.125,
"text": "a minute",
"started": "2020-05-17T07:44:18.209Z"
},
"process": {
"rss": 47550464,
"heapTotal": 25456640,
"heapUsed": 16501232,
"external": 63281,
"pid": 12345
}
}
Read all Blasters
Request (Body)
--
Response (Body)
[
{
"id": "pMtEfSYMmg",
"name": "Basement Blaster",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF",
"devices": [ "GZFnCHSDM" ],
"active": false
}
]
Create a new Blaster.
Blaster type can be derived through the following:
[]
for the line with your product namenode -e 'console.log(<paste-here>)'
type
field in the JSON bodyRequest (Body)
{
"name": "Basement Blaster",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF"
}
Response (Body)
{
"id": "pMtEfSYMmg",
"name": "Basement Blaster",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF",
"devices": [],
"active": false
}
Read a specific Blaster
Request (Body)
--
Response (Body)
{
"id": "pMtEfSYMmg",
"name": "Basement Blaster",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF",
"devices": [],
"active": true
}
Update a specific Blaster
Request (Body)
{
"name": "Basement Blaster Updated"
}
Response (Body)
{
"id": "pMtEfSYMmg",
"name": "Basement Blaster Updated",
"type": "148340",
"address": "192.168.1.2",
"port": 80,
"mac": "AA:BB:CC:DD:EE:FF",
"devices": [],
"active": true
}
Delete a specific Blaster
Read a Blaster's Devices
Request (Body)
--
Response (Body)
[
{
"id": "GZFnCHSDM",
"name": "Basement Projector",
"type": "PROJECTOR",
"commands": [
{
"command": "power on",
"repeat": 0,
"delay": 0,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
},
{
"command": "power off",
"repeat": 1,
"delay": 300,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
},
...
]
},
...
]
Create a new Blaster's Device
Request (Body)
{
"name": "Basement Projector",
"type": "PROJECTOR"
}
Response (Body)
{
"id": "GZFnCHSDM",
"name": "Basement Projector",
"type": "PROJECTOR",
"commands": []
}
Read a specific Blaster's Device
Request (Body)
--
Response (Body)
{
"id": "GZFnCHSDM",
"name": "Basement Projector",
"type": "PROJECTOR",
"commands": [
{
"command": "power on",
"repeat": 0,
"delay": 0,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
},
{
"command": "power off",
"repeat": 1,
"delay": 300,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
},
...
]
}
Update a specific Blaster's Device
Request (Body)
{
"name": "Basement Wall Projector"
}
Response (Body)
{
"id": "GZFnCHSDM",
"name": "Basement Wall Projector",
"type": "PROJECTOR",
"commands": [
{
"command": "power on",
"repeat": 0,
"delay": 0,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
},
{
"command": "power off",
"repeat": 1,
"delay": 300,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
},
...
]
}
Delete a specific Blaster's Device
Read a Blaster's Device's Commands
Request (Body)
--
Response (Body)
[
{
"command": "power on",
"repeat": 0,
"delay": 0,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
},
{
"command": "power off",
"repeat": 1,
"delay": 300,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
},
...
]
Create a new Blaster's Device's Command.
If the HEX IR code is unknown, start a learning process:
command
name in the request JSON bodycommand
buttonRequest (Body)
{
"command": "power on",
"repeat": 0,
"delay": 0
}
If the HEX IR code is already known :
Request (Body)
{
"command": "power on",
"repeat": 0,
"delay": 0,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
}
Response (Body)
{
"command": "power on",
"repeat": 0,
"delay": 0,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
}
Read a Blaster's Device's specific Command
Request (Body)
--
Response (Body)
{
"command": "power on",
"repeat": 0,
"delay": 0,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
}
Update a Blaster's Device's specific Command
Request (Body)
{
"repeat": 1,
"delay": 200
}
Response (Body)
{
"command": "power on",
"repeat": 1,
"delay": 200,
"data": "260054000001299316101512141215111511151115111536153615361537153615361536153616111437153615361536143815111536151115111511151115111412153715111536150003750900019200012a4812000d0500000000"
}
Delete a Blaster's Device's specific Command
Request (Body)
--
Response (Body)
{
"status": "Done!"
}
Request (Body)
--
Response (Body)
{
"status": "Done!"
}
Stephen Mendez
Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.
Give a ⭐️if this project helped you!
Consider making a donation of any amount!
Copyright © 2020 Stephen Mendez
This project is MIT licensed.
BroadLink is a registered trademark of Hangzhou BroadLink Technology Co. Ltd
Part of this README was generated with ❤️ by readme-md-generator