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 build
The first step is to discover and save the Broadlink devices living in your local network.
$ ir-remotes devices discover
By 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 mute
The capture
command
- stores the raw IR codes in the
remotes.json
file (configurable with--remotes-file
option) - 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 server
The following endpoints are provided by the service:
GET /api/devices
: list of Broadlink devices available and listed in thedevices.json
GET /api/devices/:name
: get information for the device withname
GET /api/remotes
: list of remote names, loaded fromremotes.json
GET /api/remotes/:name
: get the list of IR codes for the remote withname
POST /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 build
The resulting ir-remotes
binary can now be copied anywhere without any additional file.