From 690e9e545d2dda5fc7c54b7428cc84c1a3035f2a Mon Sep 17 00:00:00 2001 From: Dave Richer Date: Sat, 25 Nov 2017 20:54:48 -0500 Subject: [PATCH] Added ability to specify socket vs TCP connection for lirc --- config.js | 6 ++++-- index.js | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/config.js b/config.js index 183a087..0d0c6cb 100644 --- a/config.js +++ b/config.js @@ -5,6 +5,7 @@ const config = require('yargs') .describe('u', 'mqtt broker url. See https://github.com/mqttjs/MQTT.js#connect-using-a-url') .describe('l', 'lircd host') .describe('p', 'lircd port') + .describe('s', 'lircd socket. possible values: "/var/run/lirc/lircd"') .describe('h', 'show help') .alias({ h: 'help', @@ -12,7 +13,8 @@ const config = require('yargs') u: 'url', v: 'verbosity', l: 'lirc-host', - p: 'lirc-port' + p: 'lirc-port', + s: 'lirc-socket', }) .default({ u: 'mqtt://127.0.0.1', @@ -20,7 +22,7 @@ const config = require('yargs') v: 'info', l: '127.0.0.1', p: 8765, - i: 60 + i: 60, }) .version() .help('help') diff --git a/index.js b/index.js index d675eb7..d33509c 100755 --- a/index.js +++ b/index.js @@ -14,6 +14,13 @@ let lircConnected; log.info('lirc trying to connect on ' + config.lircHost + ':' + config.lircPort); +const lircOptions = config.lircSocket ? { + path: config.lircSocket, +} : { + host: config.lircHost, + port: config.lircPort +}; + const lirc = new Lirc({ host: config.lircHost, port: config.lircPort