lirc-client
Version:
Connect to LIRC Daemon (Infrared)
51 lines (36 loc) • 1.46 kB
Markdown
# lirc-client
[](https://badge.fury.io/js/lirc-client)
[](https://gemnasium.com/github.com/hobbyquaker/lirc-client)
[](https://travis-ci.org/hobbyquaker/lirc-client)
[](https://github.com/sindresorhus/xo)
[![License][mit-badge]][mit-url]
Node.js module to connect to a [LIRC](http://www.lirc.org/) 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`
```Javascript
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:
```Javascript
const lirc = require('lirc-client')({
path: '/var/run/lirc/lircd'
});
```
## API