Skip to content

Commit

Permalink
update debug log & solve refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
DutchmanNL committed Sep 3, 2021
1 parent d0d0eaf commit 3f84f88
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*.code-workspace
node_modules
nbproject

*.DS_Store
.create-adapter.json
# npm package files
iobroker.*.tgz

Expand Down
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ nbproject/
Thumbs.db
gulpfile.js

*.DS_Store
.create-adapter.json

# CI test files
test/
travis/
Expand Down
10 changes: 5 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
Expand All @@ -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`);
Expand Down Expand Up @@ -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}`);
Expand Down

0 comments on commit 3f84f88

Please sign in to comment.