From 3f84f8852d84bb336535a1daaec0b8c4194cd54f Mon Sep 17 00:00:00 2001 From: DutchmanNL Date: Fri, 3 Sep 2021 17:14:11 +0200 Subject: [PATCH] update debug log & solve refactor --- .gitignore | 3 ++- .npmignore | 3 +++ main.js | 10 +++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index f69c5d5..f76e282 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,8 @@ *.code-workspace node_modules nbproject - +*.DS_Store +.create-adapter.json # npm package files iobroker.*.tgz diff --git a/.npmignore b/.npmignore index db28f96..10f78ff 100644 --- a/.npmignore +++ b/.npmignore @@ -5,6 +5,9 @@ nbproject/ Thumbs.db gulpfile.js +*.DS_Store +.create-adapter.json + # CI test files test/ travis/ diff --git a/main.js b/main.js index 4e91db5..e606697 100644 --- a/main.js +++ b/main.js @@ -94,7 +94,7 @@ class SwitchbotHub extends utils.Adapter { } dataRefreshTimer[deviceId] = setTimeout(async () => { - if (deviceId != 'all') { // Only refresh values of device + if (deviceId !== 'all') { // Only refresh values of device await this.deviceStatus(deviceId); @@ -236,7 +236,7 @@ class SwitchbotHub extends utils.Adapter { } // Request device values - this.log.debug(`[deviceStatus for ]: ${JSON.stringify(this.devices[device])}`); + this.log.debug(`[deviceStatus for ]: ${JSON.stringify(this.devices[deviceArray[device].deviceId].deviceName)}`); await this.deviceStatus(deviceArray[device].deviceId); // Define intervall time (only if device has states) @@ -263,7 +263,7 @@ class SwitchbotHub extends utils.Adapter { this.log.info(`Connected to SwitchBot API found ${deviceList.length} devices`); try { - if (deviceList != null) { + if (deviceList) { await arrayHandler(deviceList); } else { this.log.error(`Can not handle device list from SwitchBot API`); @@ -487,10 +487,10 @@ class SwitchbotHub extends utils.Adapter { try { this.log.debug(`[sendState] ${JSON.stringify(this.devices[deviceId])}: ${JSON.stringify(apiData)}`); const apiResponse = await this.apiCall(`${apiURL}`, `${JSON.stringify(apiData)}`); - this.log.debug(`[sendState apiResponse]: ${JSON.stringify(this.devices[apiResponse])}`); + this.log.debug(`[sendState apiResponse]: ${JSON.stringify(apiResponse)}`); // Set ACK to true if API post command successfully - if (apiResponse.statusCode == '100') { + if (apiResponse.statusCode === 100) { this.setState(id, {ack: true}); } else { this.log.error(`Unable to send command : ${apiResponse.message}`);