Skip to content

Commit

Permalink
fix getDevices
Browse files Browse the repository at this point in the history
  • Loading branch information
donavanbecker committed Sep 30, 2024
1 parent aeaacc7 commit 6551cb0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"async-mqtt": "^2.6.3",
"fakegato-history": "^0.6.5",
"homebridge-lib": "^7.0.8",
"node-switchbot": "2.5.0-beta.28",
"node-switchbot": "2.5.0-beta.29",
"rxjs": "^7.8.1"
},
"devDependencies": {
Expand Down
14 changes: 3 additions & 11 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes'
* For Testing Locally:
* import { SwitchBotModel } from '/Users/Shared/GitHub/OpenWonderLabs/node-switchbot/dist/index.js';
*/
import type { blindTilt, curtain, curtain3, device, irdevice } from 'node-switchbot'
import type { blindTilt, curtain, curtain3, device, devices, irdevice } from 'node-switchbot'

import { LogLevel, SwitchBot, SwitchBotModel, SwitchBotOpenAPI } from 'node-switchbot'
import { queueScheduler } from 'rxjs'
Expand Down Expand Up @@ -469,16 +469,8 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
const { response, statusCode } = await this.switchBotAPI.getDevices()
await this.debugLog(`response: ${JSON.stringify(response)}`)
if (this.isSuccessfulResponse(statusCode)) {
if (Array.isArray(response.deviceList)) {
await this.handleDevices(response.deviceList)
} else {
await this.errorLog('deviceList is not an array')
}
if (Array.isArray(response.infraredRemoteList)) {
await this.handleIRDevices(response.infraredRemoteList)
} else {
await this.errorLog('infraredRemoteList is not an array')
}
await this.handleDevices(Array.isArray(response.body.deviceList) ? response.body.deviceList : [])
await this.handleIRDevices(Array.isArray(response.body.infraredRemoteList) ? response.body.infraredRemoteList : [])
break
} else {
await this.handleErrorResponse(statusCode, retryCount, maxRetries, delayBetweenRetries)
Expand Down

0 comments on commit 6551cb0

Please sign in to comment.