Fork from rodrobin's NPM package https://www.npmjs.com/package/homebridge-lirc
You can install this using:
npm i -g https://github.com/pkmnct/homebridge-lirc/tarball/master
- States don't matter. (My primary use case is controlling a TV with LIRC via homebridge-alexa. I generally know what state the TV is in so I want it to always send a code regardless of its current state)
- Added ability to wait a delayed amount of time using key code
DELAY
followed by the pipe character|
and a time in ms (example:DELAY|100
) - Removed speaker characteristics
Plugin for controlling devices through LIRC via Homebridge. MIT licensed Voice control of devices through Siri or plain Homekit apps.
Since LIRC supports an arbitrary number and types of devices not all combinations of Apple Homekit Services
and Characteristics
are
supported out-of-the-box. However, this plugin implements two one Homekit Services
(Switch and Speaker) and three one Characteristics
(Power, Mute and Volume) that should hopefully provide a solid foundation for anyone needing to add more.
For a full list of Homekit supported Services
and Characteristics
see this.
In order to make use of this plugin the following pre-conditions must be met:
- Homebridge needs to be installed and configured
- LIRC needs to be installed and configured (with at least one working remote definition and listening on a port)
- IR transmitter installed and configured on the same machine as LIRC
Please note that Homebridge and LIRC don't have to be installed on the same machine since they communicate over a standard TCP socket but do mind any firewalls between them.
The following command should be familiar:
npm install -g homebridge-lirc
Add the following JSON snippet to the Homebridge configuration file ~/.homebridge/config.json
(or the equivalent for Windows users) under the section accessories
:
{
"accessory": "Lirc",
"name": "<identifier>",
"commands": {
"on": ["KEY_1"],
"off": ["KEY_0", "KEY_0"],
"mute": ["KEY_MUTE"]
},
"lirc": {
"remote": "<lirc-configured-remote-name>",
"delay": 250,
"host": "<hostname>",
"port": 8765
}
}
Homebridge needs to identify which plugins to load at start-up which is does by looking at the accessory
value, so it is critical this is left as is. Conversely, the name
value should be changed and at the very least be unique since it signifies a discreet accessory in Homebridge. Also, if voice control is essential then it should also be phonetically distinct and understandable by Siri.
The following sections will go into detail on the lirc
and commands
structures and expected values.
Remember to restart Homebridge after any changes.
This section contains information needed for communication with the LIRC installation:
- remote(string): a LIRC configured remote name (mandatory)
- delay(number): refers to the necessary gap between commands in miliseconds - default is 250 (optional)
- host(string): either hostname or IP (mandatory)
- port(number): default is 8765 (optional)
- test(boolean): if set to true will only connect to LIRC and not send commands (optional and not shown)
Commands maps a logical action, e.g. 'volumeup', to one or more commands known by LIRC. The value(s) need to map to actual keys in a remote definition file configured in LIRC. Some devices require this for normal operation such as projectors when turning them off.
The commands ('on', 'off', etc.) are referenced in the plugin for the relevant Characteristics
so any changes in them will need to be reflected
in the code as well.
In the likely event that the included Services
and Characteristics
do not cover a specific need these are the basic steps needed to
extend the plugin:
- Identify the
Service
andCharacteristics
in this - Implement the get and set methods for the required
Characteristics
- Create a new device section to the Homebridge
config.json
file as described under the Configuration section - Add the command key(s) to the section
There is a limited set of Services
and Characteristics
but even if the precise type of service isn't defined one with a similar set of
Characteristics
can be used. Note that only Services
and Characteristics
defined by Homekit can be used.
A projector for example isn't defined but it can be considered a Switch since it needs to turn on and off. To add input switching
another Service
and Characteristic
would have to be found and implemented. The same device can implement more than one Service
and
related Characteristics
.
Please note that recording remotes for use with LIRC is outside the scope of this document. Refer to the man page for irrecord
or go
here.