Skip to content

Commit

Permalink
Add verified by homebridge badge & support 3 more devices (VS20WRF, V…
Browse files Browse the repository at this point in the history
…S10WRF, SQ610RF)
  • Loading branch information
bimusiek committed Mar 27, 2023
1 parent 501376b commit f85ffd9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
14 changes: 10 additions & 4 deletions src/SalusConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,25 @@ 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[] = [];
try {
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) {

Expand Down

0 comments on commit f85ffd9

Please sign in to comment.