diff --git a/config.schema.json b/config.schema.json index b568cfc..f756512 100644 --- a/config.schema.json +++ b/config.schema.json @@ -27,6 +27,12 @@ "type": "integer", "default": -79, "required": true + }, + "timeout": { + "title": "Timeout Between commands", + "type": "integer", + "default": 500, + "required": false } } } diff --git a/index.js b/index.js index c03aa6a..7e6bd5a 100755 --- a/index.js +++ b/index.js @@ -158,8 +158,10 @@ module.exports = function(homebridge) { this.log("sendCommand: " + command); if(!this.serialPort.isOpen){ - this.log.warn("serialPort is not open... open it"); - this.open(); + this.log.warn("serialPort is not open... trying to open it"); + this.open(function(result, error) { + if(error && callback) callback(result,error); + }); } this.serialPort.write(command); @@ -212,12 +214,12 @@ module.exports = function(homebridge) { this.serialPort.open(function (error) { if(error) { this.log.error("Error when opening serialport: " + error); - if(callback) callback(0,error); + if(callback) callback(0, error); } else { this.log("Set auto status feedback to full"); setTimeout(function() {this.sendCommand("@AST:F\r");}.bind(this), 5000); - if(callback) callback(); + if(callback) callback(1); } }.bind(this)); }, diff --git a/package.json b/package.json index 64d573f..f7322fb 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-marantz-rs232", - "version": "0.2.2", + "version": "0.2.3", "description": "Marantz rs232 receiver plugin for homebridge: https://github.com/nfarina/homebridge", "license": "ISC", "keywords": [