ir-remotes provides a command line tool for managing Broadlink devices, recording infra-red codes, then, providing a way to replay those, using a REST API endpoint.
Disclaimer: the following code has been tested on Linux, using a Broadlink RM Mini IR blaster. While it may support other Broadlink devices, this has not been tested. Contributions are welcome.
To build from source, Go >= 1.11 is required, since the repository uses Go modules.
# Clone the repository anywhere you want
$ git clone https://github.com/j-vizcaino/ir-remotes.git
$ cd ir-remotes
$ go buildThe first step is to discover and save the Broadlink devices living in your local network.
$ ir-remotes devices discoverBy default, the devices information get stored in devices.json but this can be configured using the --devices-file option.
When devices.json exist, the command preserves its content. It is safe to run the discover command many times without loosing previously discovered devices.
Once device list is ready, it's time to capture some IR codes. Using this mode, the Broadlink device will wait for IR code and record it.
# Example: record the power, vol_up, vol_down and mute buttons from the TV remote
$ ir-remotes capture -n tv power vol_up vol_down muteThe capture command
- stores the raw IR codes in the 
remotes.jsonfile (configurable with--remotes-fileoption) - captures the IR codes sequentially, asking the user to press the IR remote button when ready
 - skips already captured IR codes that may exist in the remotes file
 
With device list and a couple of IR codes saved to disk, the REST service can be started.
$ ir-remotes serverThe following endpoints are provided by the service:
GET /api/devices: list of Broadlink devices available and listed in thedevices.jsonGET /api/devices/:name: get information for the device withnameGET /api/remotes: list of remote names, loaded fromremotes.jsonGET /api/remotes/:name: get the list of IR codes for the remote withnamePOST /api/remotes/:name/:code: send the IR code namedcode
The server command allows for serving static content from disk.
By default, accessing localhost:8080 redirects to localhost:8080/ui/ where the application serves the UI asset content, located in assets/ui.
In order to improve installation and distribution, a binary can be compiled, embedding both the UI files as well as the remotes.json and devices.json located in assets/config directory.
To build this version of the binary
$ GO_BUILD_TAGS=embedded make buildThe resulting ir-remotes binary can now be copied anywhere without any additional file.