Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Commit

Permalink
feat: avoid registering unsupported ThinQ 1 devices
Browse files Browse the repository at this point in the history
  • Loading branch information
sman591 committed Jul 11, 2020
1 parent 6ff554b commit 721c918
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,25 @@ export class HomebridgeLgThinqPlatform implements DynamicPlatformPlugin {
`Discover found ${dashboardResponse.result.item.length} total devices`,
)

const devices = dashboardResponse.result.item.filter(
(item) =>
typeof item === 'object' &&
'deviceType' in item &&
item.deviceType === 401,
)
const devices = dashboardResponse.result.item.filter((item) => {
if (typeof item !== 'object') {
this.log.debug('Item is not an object, ignoring')
return false
}
if (item.deviceType !== 401) {
// Air Conditioners have a 401 device type
this.log.debug(`deviceType is ${item.deviceType}, ignoring`)
return false
}
if (item.platformType !== 'thinq2') {
this.log.error(
`"${item.alias}" (model ${item.modelName}) uses the ${item.platformType} platform, which is not supported. ` +
`Please see https://github.com/sman591/homebridge-lg-thinq-ac/issues/4 for updates.`,
)
return false
}
return true
})

// loop over the discovered devices and register each one if it has not already been registered
for (const device of devices) {
Expand Down

0 comments on commit 721c918

Please sign in to comment.