diff --git a/README.md b/README.md index a8b5967..cd17c5e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,14 @@ [![NPM](https://img.shields.io/npm/v/@hernas/homebridge-salus-sq610)](https://npmjs.org/package/@hernas/homebridge-salus-sq610) - +[![verified-by-homebridge](https://badgen.net/badge/homebridge/verified/purple)](https://github.com/homebridge/homebridge/wiki/Verified-Plugins) # homebridge-salus-sq610 -Salus SQ610/SQ610RF plugin for [HomeBridge](https://github.com/nfarina/homebridge) using the [Salus *Connect* API](https://eu.salusconnect.io/dashboard) to expose Salus Thermostats to Apple's HomeKit. +Salus plugin for [HomeBridge](https://github.com/nfarina/homebridge) using the [Salus *Connect* API](https://eu.salusconnect.io/dashboard) to expose Salus Thermostats to Apple's HomeKit. + +**Supported devices:** +* SQ610 +* SQ610RF +* VS20WRF +* VS10WRF ![HomeKit Screenshot](.github/statics/homekit-1.png) diff --git a/src/SalusConnect.ts b/src/SalusConnect.ts index 70b58e6..1005e5c 100644 --- a/src/SalusConnect.ts +++ b/src/SalusConnect.ts @@ -87,9 +87,7 @@ export class SalusConnect { this.username = username; this.password = password; this.log = log; - this.thermostatModels = thermostatModels.map((e) => { - return e.toUpperCase().replace(/^VS(10|20)\w+/, 'IT600THERMHW'); - }); + this.thermostatModels = thermostatModels; } async getToken(): Promise { @@ -117,6 +115,14 @@ export class SalusConnect { return token; } + isCorrectDevice(device: {oem_model: string}) { + const modelName = device.oem_model.toUpperCase(); + this.log?.debug(`Checking if model[${modelName}] is supported...`); + return this.thermostatModels.some((model) => { + return modelName.includes(model); + }); + } + async getDevices(retried = false) { const token = await this.getToken(); try { @@ -130,7 +136,7 @@ export class SalusConnect { const result: DeviceWithProps[] = []; for (const e of allDevices) { const device = e.device; - if (this.thermostatModels.includes(device.oem_model.toUpperCase())) { + if (this.isCorrectDevice(device)) { result.push( new DeviceWithProps( device.dsn, diff --git a/src/platform.ts b/src/platform.ts index f3a20f2..fdd97d3 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -42,13 +42,14 @@ export class SalusSQ610HomebridgePlatform implements DynamicPlatformPlugin { async discoverDevices() { if(!this.email || !this.password) { + this.log.error('Missing email & password, please configure the plugin correctly.'); return; } const salusConnect = new SalusConnect({ username: this.email, password: this.password, log: this.log, - thermostatModels: ['SQ610', 'SQ610RF'], + thermostatModels: ['SQ610', 'IT600THERM'], }); let devices:DeviceWithProps[] = []; @@ -56,6 +57,10 @@ export class SalusSQ610HomebridgePlatform implements DynamicPlatformPlugin { devices = await salusConnect.getDevices(); } catch(e) { this.log.error(`Could not load the devices: ${e}`); + this.log.info('Trying to fetch devices again in 60s...'); + setTimeout(() => { + this.discoverDevices(); + }, 60000); } for (const device of devices) {