lirc-client
Node.js module to connect to a LIRC daemon.
BREAKING CHANGE in v2.0 - Promises instead of Callbacks
If you prefer using callbacks or want to use Node < 6.12 you can still install the "old" v1.0:
npm install lirc-client@1.0.0
.
Usage
$ npm install lirc-client
const lirc = require('lirc-client')({ host: '127.0.0.1', port: 8765}); lirc.on('connect', () => { lirc.send('VERSION').then(res => { console.log('LIRC Version', res); }); lirc.sendOnce('Remote1', 'Key1').catch(error => { if (error) console.log(error); });}); lirc.on('receive', function (remote, button, repeat) { console.log('button ' + button + ' on remote ' + remote + ' was pressed!');});
you can also connect to a unix domain socket via path option:
const lirc = require('lirc-client')({ path: '/var/run/lirc/lircd'});
API
Lirc
Kind: global class
- Lirc
- new module.exports.Lirc([config])
- .send() ⇒
Promise.<array.<string>>
- .sendOnce(remote, button, [repeat]) ⇒
Promise.<array.<string>>
- .sendStart(remote, button) ⇒
Promise.<array.<string>>
- .sendStop(remote, button) ⇒
Promise.<array.<string>>
- .list([remote]) ⇒
Promise.<array.<string>>
- .version() ⇒
Promise.<array.<string>>
- .connect() ⇒
Promise
- .disconnect() ⇒
Promise
new module.exports.Lirc([config])
Param | Type | Default | Description |
---|---|---|---|
[config] | object |
Configuration object. | |
[config.autoconnect] | boolean |
true |
Automatically connect. |
[config.host] | string |
"'127.0.0.1'" |
Host running LIRC. |
[config.port] | number |
8765 |
Port of running LIRC daemon. |
[config.path] | string |
Path to LIRC socket. | |
[config.reconnect] | boolean |
true |
Automatically reconnect. |
[config.reconnect_delay] | number |
5000 |
Delay when reconnecting. |
Promise.<array.<string>>
lirc.send() ⇒ Send a command.
Kind: instance method of Lirc
Returns: Promise.<array.<string>>
- Resulting response from LIRC daemon.
Param | Type | Description |
---|---|---|
...args | string |
Command to send, or individual parameters. |
Promise.<array.<string>>
lirc.sendOnce(remote, button, [repeat]) ⇒ Tell LIRC to emit a button press.
Kind: instance method of Lirc
Returns: Promise.<array.<string>>
- Response from LIRC.
Param | Type | Description |
---|---|---|
remote | string |
Remote name. |
button | string |
Button name. |
[repeat] | number |
Number of times to repeat. |
Promise.<array.<string>>
lirc.sendStart(remote, button) ⇒ Tell LIRC to start emitting button presses.
Kind: instance method of Lirc
Returns: Promise.<array.<string>>
- Response from LIRC.
Param | Type | Description |
---|---|---|
remote | string |
Remote name. |
button | string |
Button name. |
Promise.<array.<string>>
lirc.sendStop(remote, button) ⇒ Tell LIRC to stop emitting a button press.
Kind: instance method of Lirc
Returns: Promise.<array.<string>>
- Response from LIRC.
Param | Type | Description |
---|---|---|
remote | string |
Remote name. |
button | string |
Button name. |
Promise.<array.<string>>
lirc.list([remote]) ⇒ If a remote is supplied, list available buttons for remote, otherwise return list of remotes.
Kind: instance method of Lirc
Returns: Promise.<array.<string>>
- Response from LIRC.
Param | Type | Description |
---|---|---|
[remote] | string |
Remote name. |
Promise.<array.<string>>
lirc.version() ⇒ Get LIRC version from server.
Kind: instance method of Lirc
Returns: Promise.<array.<string>>
- Response from LIRC.
Promise
lirc.connect() ⇒ Connect to a running LIRC daemon.
Kind: instance method of Lirc
Returns: Promise
- Resolves upon connection to server.
Promise
lirc.disconnect() ⇒ Disconnect from LIRC daemon and clean up socket.
Kind: instance method of Lirc
Returns: Promise
- Resolves upon disconnect.
License
MIT © Sebastian Raff