https://github.com/hobbyquaker/lirc-client
Node.js module to connect to a LIRC daemon.
https://github.com/hobbyquaker/lirc-client
hifi infrared lirc node-module remote-control tv
Last synced: about 1 month ago
JSON representation
Node.js module to connect to a LIRC daemon.
- Host: GitHub
- URL: https://github.com/hobbyquaker/lirc-client
- Owner: hobbyquaker
- License: mit
- Created: 2015-11-01T19:34:36.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-12-29T20:27:33.000Z (over 6 years ago)
- Last Synced: 2024-04-26T08:03:10.522Z (about 1 year ago)
- Topics: hifi, infrared, lirc, node-module, remote-control, tv
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 10
- Watchers: 5
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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 [email protected]`. The "old" Readme is here: https://github.com/hobbyquaker/lirc-client/blob/8d6da5a57064b9a59cc170ecae6a86278e006eb6/README.md## 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
## Lirc
**Kind**: global class* [Lirc](#Lirc)
* [new module.exports.Lirc([config])](#new_Lirc_new)
* [.send(command)](#Lirc+send) ⇒Promise.<array.<string>>
* [.sendOnce(remote, button, [repeat])](#Lirc+sendOnce) ⇒Promise.<array.<string>>
* [.sendStart(remote, button)](#Lirc+sendStart) ⇒Promise.<array.<string>>
* [.sendStop(remote, button)](#Lirc+sendStop) ⇒Promise.<array.<string>>
* [.list([remote])](#Lirc+list) ⇒Promise.<array.<string>>
* [.version()](#Lirc+version) ⇒Promise.<array.<string>>
* [.connect()](#Lirc+connect) ⇒Promise
* [.disconnect()](#Lirc+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. |### lirc.send(command) ⇒
Promise.<array.<string>>
Send a command.**Kind**: instance method of [
Lirc
](#Lirc)
**Returns**:Promise.<array.<string>>
- Resulting response from LIRC daemon.
**See**: available commands http://www.lirc.org/html/lircd.html| Param | Type | Description |
| --- | --- | --- |
| command |string
| Command to send. |
| [...args] |string
| optional parameters. |### lirc.sendOnce(remote, button, [repeat]) ⇒
Promise.<array.<string>>
Tell LIRC to emit a button press.**Kind**: instance method of [
Lirc
](#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. |### lirc.sendStart(remote, button) ⇒
Promise.<array.<string>>
Tell LIRC to start emitting button presses.**Kind**: instance method of [
Lirc
](#Lirc)
**Returns**:Promise.<array.<string>>
- Response from LIRC.| Param | Type | Description |
| --- | --- | --- |
| remote |string
| Remote name. |
| button |string
| Button name. |### lirc.sendStop(remote, button) ⇒
Promise.<array.<string>>
Tell LIRC to stop emitting a button press.**Kind**: instance method of [
Lirc
](#Lirc)
**Returns**:Promise.<array.<string>>
- Response from LIRC.| Param | Type | Description |
| --- | --- | --- |
| remote |string
| Remote name. |
| button |string
| Button name. |### lirc.list([remote]) ⇒
Promise.<array.<string>>
If a remote is supplied, list available buttons for remote, otherwise
return list of remotes.**Kind**: instance method of [
Lirc
](#Lirc)
**Returns**:Promise.<array.<string>>
- Response from LIRC.| Param | Type | Description |
| --- | --- | --- |
| [remote] |string
| Remote name. |### lirc.version() ⇒
Promise.<array.<string>>
Get LIRC version from server.**Kind**: instance method of [
Lirc
](#Lirc)
**Returns**:Promise.<array.<string>>
- Response from LIRC.### lirc.connect() ⇒
Promise
Connect to a running LIRC daemon.**Kind**: instance method of [
Lirc
](#Lirc)
**Returns**:Promise
- Resolves upon connection to server.### lirc.disconnect() ⇒
Promise
Disconnect from LIRC daemon and clean up socket.**Kind**: instance method of [
Lirc
](#Lirc)
**Returns**:Promise
- Resolves upon disconnect.## License
MIT © [Sebastian Raff](https://hobbyquaker.github.io)
[mit-badge]: https://img.shields.io/badge/License-MIT-blue.svg?style=flat
[mit-url]: LICENSE