diff --git a/package.json b/package.json index bf5e9cc..16839cd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "Xbox TV", "name": "homebridge-xbox-tv", - "version": "3.0.0", + "version": "3.0.1", "description": "Homebridge plugin to control Xbox game consoles.", "license": "MIT", "author": "grzegorz914", diff --git a/src/xboxdevice.js b/src/xboxdevice.js index 0023b8a..c10ffad 100644 --- a/src/xboxdevice.js +++ b/src/xboxdevice.js @@ -51,7 +51,14 @@ class XboxDevice extends EventEmitter { this.volumeControlName = device.volumeControlName || 'Volume'; //external integration + //restRul + const restFul = device.restFul ?? {}; + const restFulEnabled = restFul.enable || false; this.restFulConnected = false; + + //mqtt + const mqtt = device.restFul ?? {}; + const mqttEnabled = mqtt.enable || false; this.mqttConnected = false; //accessory services @@ -313,11 +320,10 @@ class XboxDevice extends EventEmitter { }) .on('prepareAccessory', async () => { //RESTFul server - const restFulEnabled = device.restFul.enable || false; if (restFulEnabled) { this.restFul = new RestFul({ - port: device.restFul.port || 3000, - debug: device.restFul.debug || false + port: restFul.port || 3000, + debug: restFul.debug || false }); this.restFul.on('connected', (message) => { @@ -333,16 +339,15 @@ class XboxDevice extends EventEmitter { } //mqtt client - const mqttEnabled = device.mqtt.enable || false; if (mqttEnabled) { this.mqtt = new Mqtt({ - host: device.mqtt.host, - port: device.mqtt.port || 1883, - clientId: device.mqtt.clientId || `xbox_${Math.random().toString(16).slice(3)}`, - prefix: `${device.mqtt.prefix}/${device.name}`, - user: device.mqtt.user, - passwd: device.mqtt.passwd, - debug: device.mqtt.debug || false + host: mqtt.host, + port: mqtt.port || 1883, + clientId: mqtt.clientId || `xbox_${Math.random().toString(16).slice(3)}`, + prefix: `${mqtt.prefix}/${device.name}`, + user: mqtt.user, + passwd: mqtt.passwd, + debug: mqtt.debug || false }); this.mqtt.on('connected', (message) => {