@homebridge-plugins/homebridge-smarthq 0.5.0-beta.5 → 0.5.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/config.yml +1 -1
- package/.github/copilot-instructions.md +90 -0
- package/.github/scripts/branch-helper.sh +41 -0
- package/.github/workflows/beta-release.yml +1 -1
- package/.github/workflows/release.yml +53 -17
- package/CHANGELOG.md +563 -18
- package/README.md +15 -0
- package/dist/devices/OpalIceMaker/Managers/OpalProgressSvcManager.d.ts +1 -1
- package/dist/devices/OpalIceMaker/Managers/OpalProgressSvcManager.d.ts.map +1 -1
- package/dist/devices/OpalIceMaker/Managers/OpalProgressSvcManager.js +9 -5
- package/dist/devices/OpalIceMaker/Managers/OpalProgressSvcManager.js.map +1 -1
- package/dist/devices/advantium.d.ts +10 -0
- package/dist/devices/advantium.d.ts.map +1 -0
- package/dist/devices/advantium.js +75 -0
- package/dist/devices/advantium.js.map +1 -0
- package/dist/devices/beverageCenter.d.ts +10 -0
- package/dist/devices/beverageCenter.d.ts.map +1 -0
- package/dist/devices/beverageCenter.js +125 -0
- package/dist/devices/beverageCenter.js.map +1 -0
- package/dist/devices/clothesDryer.d.ts +10 -0
- package/dist/devices/clothesDryer.d.ts.map +1 -0
- package/dist/devices/clothesDryer.js +84 -0
- package/dist/devices/clothesDryer.js.map +1 -0
- package/dist/devices/clothesWasher.d.ts +10 -0
- package/dist/devices/clothesWasher.d.ts.map +1 -0
- package/dist/devices/clothesWasher.js +84 -0
- package/dist/devices/clothesWasher.js.map +1 -0
- package/dist/devices/coffeeMaker.d.ts +10 -0
- package/dist/devices/coffeeMaker.d.ts.map +1 -0
- package/dist/devices/coffeeMaker.js +79 -0
- package/dist/devices/coffeeMaker.js.map +1 -0
- package/dist/devices/device.js +1 -1
- package/dist/devices/device.js.map +1 -1
- package/dist/devices/dishwasher.d.ts +0 -1
- package/dist/devices/dishwasher.d.ts.map +1 -1
- package/dist/devices/dishwasher.js +47 -12
- package/dist/devices/dishwasher.js.map +1 -1
- package/dist/devices/hood.d.ts +34 -0
- package/dist/devices/hood.d.ts.map +1 -0
- package/dist/devices/hood.js +306 -0
- package/dist/devices/hood.js.map +1 -0
- package/dist/devices/microwave.d.ts +10 -0
- package/dist/devices/microwave.d.ts.map +1 -0
- package/dist/devices/microwave.js +84 -0
- package/dist/devices/microwave.js.map +1 -0
- package/dist/devices/oven.d.ts.map +1 -1
- package/dist/devices/oven.js +78 -32
- package/dist/devices/oven.js.map +1 -1
- package/dist/devices/refrigerator.d.ts.map +1 -1
- package/dist/devices/refrigerator.js +142 -13
- package/dist/devices/refrigerator.js.map +1 -1
- package/dist/devices/waterFilter.d.ts +10 -0
- package/dist/devices/waterFilter.d.ts.map +1 -0
- package/dist/devices/waterFilter.js +67 -0
- package/dist/devices/waterFilter.js.map +1 -0
- package/dist/devices/waterHeater.d.ts +10 -0
- package/dist/devices/waterHeater.d.ts.map +1 -0
- package/dist/devices/waterHeater.js +95 -0
- package/dist/devices/waterHeater.js.map +1 -0
- package/dist/devices/waterSoftener.d.ts +10 -0
- package/dist/devices/waterSoftener.d.ts.map +1 -0
- package/dist/devices/waterSoftener.js +67 -0
- package/dist/devices/waterSoftener.js.map +1 -0
- package/dist/platform.d.ts +10 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +383 -0
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +13 -0
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +3 -0
- package/dist/settings.js.map +1 -1
- package/docs/assets/highlight.css +7 -0
- package/docs/assets/main.js +5 -5
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +248 -226
- package/docs/classes/SmartHQPlatform.html +45 -56
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +22 -12
- package/docs/interfaces/DeviceOptions.html +2 -3
- package/docs/interfaces/SmartHQPlatformConfig.html +6 -17
- package/docs/interfaces/SmartHqContext.html +6 -4
- package/docs/interfaces/SmartHqERDResponse.html +7 -8
- package/docs/interfaces/credentials.html +3 -4
- package/docs/interfaces/devicesConfig.html +7 -8
- package/docs/interfaces/options.html +7 -8
- package/docs/media/copilot-instructions.md +90 -0
- package/docs/modules.html +1 -2
- package/docs/variables/API_URL.html +1 -2
- package/docs/variables/ERD_CODES.html +1 -2
- package/docs/variables/ERD_TYPES.html +1 -2
- package/docs/variables/KEEPALIVE_TIMEOUT.html +1 -2
- package/docs/variables/LOGIN_URL.html +2 -3
- package/docs/variables/OAUTH2_CLIENT_ID.html +1 -2
- package/docs/variables/OAUTH2_CLIENT_SECRET.html +1 -2
- package/docs/variables/OAUTH2_REDIRECT_URI.html +1 -2
- package/docs/variables/PLATFORM_NAME.html +2 -3
- package/docs/variables/PLUGIN_NAME.html +2 -3
- package/docs/variables/SECURE_URL.html +2 -3
- package/docs/variables/default.html +1 -0
- package/package.json +21 -28
- package/typedoc.json +0 -4
- package/vitest.config.ts +6 -5
- package/.github/workflows/build.yml +0 -18
- package/.github/workflows/changerelease.yml +0 -11
- package/.github/workflows/labeler.yml +0 -9
- package/.github/workflows/release-drafter.yml +0 -14
- package/docs/assets/dmt/dmt-component-data.js +0 -1
- package/docs/assets/dmt/dmt-components.css +0 -20
- package/docs/assets/dmt/dmt-components.js +0 -67
- package/docs/assets/dmt/dmt-search.cmp +0 -0
- package/docs/assets/dmt/dmt-theme.css +0 -1
- package/docs/functions/default.html +0 -2
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { deviceBase } from './device.js';
|
|
2
|
+
export class SmartHQWaterSoftener extends deviceBase {
|
|
3
|
+
platform;
|
|
4
|
+
device;
|
|
5
|
+
constructor(platform, accessory, device) {
|
|
6
|
+
super(platform, accessory, device);
|
|
7
|
+
this.platform = platform;
|
|
8
|
+
this.device = device;
|
|
9
|
+
this.debugLog(`Water Softener Features: ${JSON.stringify(accessory.context.device.features)}`);
|
|
10
|
+
// Water Softener Filter/Salt Status
|
|
11
|
+
const filterService = this.accessory.getService('Softener Salt') ?? this.accessory.addService(this.platform.Service.FilterMaintenance, 'Softener Salt', 'SoftenerSalt');
|
|
12
|
+
filterService.setCharacteristic(this.platform.Characteristic.Name, 'Softener Salt');
|
|
13
|
+
filterService
|
|
14
|
+
.getCharacteristic(this.platform.Characteristic.FilterChangeIndication)
|
|
15
|
+
.onGet(async () => {
|
|
16
|
+
try {
|
|
17
|
+
// TODO: Implement salt level ERD
|
|
18
|
+
return this.platform.Characteristic.FilterChangeIndication.FILTER_OK;
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
this.warnLog?.(`Softener Salt Status error: ${error?.message ?? error}`);
|
|
22
|
+
return this.platform.Characteristic.FilterChangeIndication.FILTER_OK;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
filterService
|
|
26
|
+
.getCharacteristic(this.platform.Characteristic.FilterLifeLevel)
|
|
27
|
+
.onGet(async () => {
|
|
28
|
+
try {
|
|
29
|
+
// TODO: Implement salt level percentage ERD
|
|
30
|
+
return 100;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
this.warnLog?.(`Softener Salt Level error: ${error?.message ?? error}`);
|
|
34
|
+
return 100;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
// Water Valve
|
|
38
|
+
const valveService = this.accessory.getService('Water Softener') ?? this.accessory.addService(this.platform.Service.Valve, 'Water Softener', 'WaterSoftener');
|
|
39
|
+
valveService.setCharacteristic(this.platform.Characteristic.Name, 'Water Softener');
|
|
40
|
+
valveService.setCharacteristic(this.platform.Characteristic.ValveType, this.platform.Characteristic.ValveType.WATER_FAUCET);
|
|
41
|
+
valveService
|
|
42
|
+
.getCharacteristic(this.platform.Characteristic.Active)
|
|
43
|
+
.onGet(async () => {
|
|
44
|
+
try {
|
|
45
|
+
// TODO: Implement softener active state ERD
|
|
46
|
+
return this.platform.Characteristic.Active.ACTIVE;
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
this.warnLog?.(`Water Softener Active error: ${error?.message ?? error}`);
|
|
50
|
+
return this.platform.Characteristic.Active.INACTIVE;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
valveService
|
|
54
|
+
.getCharacteristic(this.platform.Characteristic.InUse)
|
|
55
|
+
.onGet(async () => {
|
|
56
|
+
try {
|
|
57
|
+
// TODO: Implement softener in-use state ERD
|
|
58
|
+
return this.platform.Characteristic.InUse.IN_USE;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
this.warnLog?.(`Water Softener InUse error: ${error?.message ?? error}`);
|
|
62
|
+
return this.platform.Characteristic.InUse.NOT_IN_USE;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=waterSoftener.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waterSoftener.js","sourceRoot":"","sources":["../../src/devices/waterSoftener.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,MAAM,OAAO,oBAAqB,SAAQ,UAAU;IAEvC;IAEA;IAHX,YACW,QAAyB,EAClC,SAA4C,EACnC,MAAgD;QAEzD,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAA;QAJzB,aAAQ,GAAR,QAAQ,CAAiB;QAEzB,WAAM,GAAN,MAAM,CAA0C;QAGzD,IAAI,CAAC,QAAQ,CAAC,4BAA4B,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QAE9F,oCAAoC;QACpC,MAAM,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,iBAAiB,EAAE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QPlatform implements DynamicPlatformPlugin {
|
|
|
42
42
|
private createSmartHQIceMaker;
|
|
43
43
|
private createSmartHQRefrigerator;
|
|
44
44
|
private createSmartHQAirConditioner;
|
|
45
|
+
private createSmartHQHood;
|
|
46
|
+
private createSmartHQClothesWasher;
|
|
47
|
+
private createSmartHQClothesDryer;
|
|
48
|
+
private createSmartHQWaterFilter;
|
|
49
|
+
private createSmartHQWaterSoftener;
|
|
50
|
+
private createSmartHQWaterHeater;
|
|
51
|
+
private createSmartHQAdvantium;
|
|
52
|
+
private createSmartHQMicrowave;
|
|
53
|
+
private createSmartHQCoffeeMaker;
|
|
54
|
+
private createSmartHQBeverageCenter;
|
|
45
55
|
unregisterPlatformAccessories(existingAccessory: PlatformAccessory): Promise<void>;
|
|
46
56
|
getPlatformLogSettings(): Promise<void>;
|
|
47
57
|
getPlatformRateSettings(): Promise<void>;
|
package/dist/platform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,qBAAqB,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAG7F,OAAO,KAAK,EAA8B,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,qBAAqB,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAG7F,OAAO,KAAK,EAA8B,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AA+B/G;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,qBAAqB;IACpD,WAAW,EAAE,iBAAiB,CAAC,cAAc,CAAC,EAAE,CAAA;IAC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AAI,CAAC;IAMjC;;;;;;OAMG;IACG,2BAA2B,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAgCpG;;;OAGG;IACG,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrC,UAAU,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMxC,eAAe,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ7C,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMrC,YAAY,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ1C,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAMtC,aAAa,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ3C,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAUtC,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IAIlC,uBAAuB,IAAI,OAAO,CAAC,OAAO,CAAC;CAGlD"}
|
package/dist/platform.js
CHANGED
|
@@ -4,10 +4,20 @@ import { SmartHQIceMaker } from './devices/OpalIceMaker/index.js';
|
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
import pkg from 'lodash';
|
|
6
6
|
import ws from 'ws';
|
|
7
|
+
import { SmartHQAdvantium } from './devices/advantium.js';
|
|
7
8
|
import { SmartHQAirConditioner } from './devices/airConditioner.js';
|
|
9
|
+
import { SmartHQBeverageCenter } from './devices/beverageCenter.js';
|
|
10
|
+
import { SmartHQClothesDryer } from './devices/clothesDryer.js';
|
|
11
|
+
import { SmartHQClothesWasher } from './devices/clothesWasher.js';
|
|
12
|
+
import { SmartHQCoffeeMaker } from './devices/coffeeMaker.js';
|
|
8
13
|
import { SmartHQDishWasher } from './devices/dishwasher.js';
|
|
14
|
+
import { SmartHQHood } from './devices/hood.js';
|
|
15
|
+
import { SmartHQMicrowave } from './devices/microwave.js';
|
|
9
16
|
import { SmartHQOven } from './devices/oven.js';
|
|
10
17
|
import { SmartHQRefrigerator } from './devices/refrigerator.js';
|
|
18
|
+
import { SmartHQWaterFilter } from './devices/waterFilter.js';
|
|
19
|
+
import { SmartHQWaterHeater } from './devices/waterHeater.js';
|
|
20
|
+
import { SmartHQWaterSoftener } from './devices/waterSoftener.js';
|
|
11
21
|
import getAccessToken, { refreshAccessToken } from './getAccessToken.js';
|
|
12
22
|
import { API_URL, ERD_CODES, ERD_TYPES, KEEPALIVE_TIMEOUT, PLATFORM_NAME, PLUGIN_NAME } from './settings.js';
|
|
13
23
|
const { find } = pkg;
|
|
@@ -235,6 +245,37 @@ export class SmartHQPlatform {
|
|
|
235
245
|
case 'Split Air Conditioner':
|
|
236
246
|
await this.createSmartHQAirConditioner(userId, device, details, features);
|
|
237
247
|
break;
|
|
248
|
+
case 'Hood':
|
|
249
|
+
await this.createSmartHQHood(userId, device, details, features);
|
|
250
|
+
break;
|
|
251
|
+
case 'Clothes Washer':
|
|
252
|
+
await this.createSmartHQClothesWasher(userId, device, details, features);
|
|
253
|
+
break;
|
|
254
|
+
case 'Clothes Dryer':
|
|
255
|
+
await this.createSmartHQClothesDryer(userId, device, details, features);
|
|
256
|
+
break;
|
|
257
|
+
case 'Whole Home Water Filter':
|
|
258
|
+
await this.createSmartHQWaterFilter(userId, device, details, features);
|
|
259
|
+
break;
|
|
260
|
+
case 'Whole Home Water Softener':
|
|
261
|
+
await this.createSmartHQWaterSoftener(userId, device, details, features);
|
|
262
|
+
break;
|
|
263
|
+
case 'Whole Home Water Heater':
|
|
264
|
+
await this.createSmartHQWaterHeater(userId, device, details, features);
|
|
265
|
+
break;
|
|
266
|
+
case 'Advantium':
|
|
267
|
+
await this.createSmartHQAdvantium(userId, device, details, features);
|
|
268
|
+
break;
|
|
269
|
+
case 'Microwave':
|
|
270
|
+
await this.createSmartHQMicrowave(userId, device, details, features);
|
|
271
|
+
break;
|
|
272
|
+
case 'Coffee Maker':
|
|
273
|
+
case 'Espresso Maker':
|
|
274
|
+
await this.createSmartHQCoffeeMaker(userId, device, details, features);
|
|
275
|
+
break;
|
|
276
|
+
case 'Beverage Center':
|
|
277
|
+
await this.createSmartHQBeverageCenter(userId, device, details, features);
|
|
278
|
+
break;
|
|
238
279
|
default:
|
|
239
280
|
await this.warnLog(`Device Type Not Supported: ${device.type}`);
|
|
240
281
|
break;
|
|
@@ -483,6 +524,348 @@ export class SmartHQPlatform {
|
|
|
483
524
|
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
|
|
484
525
|
}
|
|
485
526
|
}
|
|
527
|
+
async createSmartHQHood(userId, device, details, features) {
|
|
528
|
+
const uuid = this.api.hap.uuid.generate(device.applianceId);
|
|
529
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
530
|
+
if (existingAccessory) {
|
|
531
|
+
if (!device.hide_device) {
|
|
532
|
+
existingAccessory.context.device = device;
|
|
533
|
+
existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
534
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
535
|
+
existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
536
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
537
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
538
|
+
new SmartHQHood(this, existingAccessory, device);
|
|
539
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
540
|
+
}
|
|
541
|
+
else {
|
|
542
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
else if (!device.hide_device && !existingAccessory) {
|
|
546
|
+
this.infoLog(`Adding new accessory: ${device.nickname}`);
|
|
547
|
+
const accessory = new this.api.platformAccessory(device.nickname, uuid);
|
|
548
|
+
accessory.context.device = device;
|
|
549
|
+
accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
550
|
+
accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
551
|
+
accessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
552
|
+
new SmartHQHood(this, accessory, device);
|
|
553
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
554
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
555
|
+
this.accessories.push(accessory);
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
async createSmartHQClothesWasher(userId, device, details, features) {
|
|
562
|
+
const uuid = this.api.hap.uuid.generate(device.applianceId);
|
|
563
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
564
|
+
if (existingAccessory) {
|
|
565
|
+
if (!device.hide_device) {
|
|
566
|
+
existingAccessory.context.device = device;
|
|
567
|
+
existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
568
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
569
|
+
existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
570
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
571
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
572
|
+
// create the accessory handler for the restored accessory
|
|
573
|
+
new SmartHQClothesWasher(this, existingAccessory, device);
|
|
574
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
575
|
+
}
|
|
576
|
+
else {
|
|
577
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
else if (!device.hide_device && !existingAccessory) {
|
|
581
|
+
this.infoLog(`Adding new accessory: ${device.nickname}`);
|
|
582
|
+
const accessory = new this.api.platformAccessory(device.nickname, uuid);
|
|
583
|
+
accessory.context.device = device;
|
|
584
|
+
accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
585
|
+
accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
586
|
+
accessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
587
|
+
new SmartHQClothesWasher(this, accessory, device);
|
|
588
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
589
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
590
|
+
this.accessories.push(accessory);
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
async createSmartHQClothesDryer(userId, device, details, features) {
|
|
597
|
+
const uuid = this.api.hap.uuid.generate(device.applianceId);
|
|
598
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
599
|
+
if (existingAccessory) {
|
|
600
|
+
if (!device.hide_device) {
|
|
601
|
+
existingAccessory.context.device = device;
|
|
602
|
+
existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
603
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
604
|
+
existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
605
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
606
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
607
|
+
// create the accessory handler for the restored accessory
|
|
608
|
+
new SmartHQClothesDryer(this, existingAccessory, device);
|
|
609
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
610
|
+
}
|
|
611
|
+
else {
|
|
612
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
else if (!device.hide_device && !existingAccessory) {
|
|
616
|
+
this.infoLog(`Adding new accessory: ${device.nickname}`);
|
|
617
|
+
const accessory = new this.api.platformAccessory(device.nickname, uuid);
|
|
618
|
+
accessory.context.device = device;
|
|
619
|
+
accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
620
|
+
accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
621
|
+
accessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
622
|
+
new SmartHQClothesDryer(this, accessory, device);
|
|
623
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
624
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
625
|
+
this.accessories.push(accessory);
|
|
626
|
+
}
|
|
627
|
+
else {
|
|
628
|
+
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
async createSmartHQWaterFilter(userId, device, details, features) {
|
|
632
|
+
const uuid = this.api.hap.uuid.generate(device.applianceId);
|
|
633
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
634
|
+
if (existingAccessory) {
|
|
635
|
+
if (!device.hide_device) {
|
|
636
|
+
existingAccessory.context.device = device;
|
|
637
|
+
existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
638
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
639
|
+
existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
640
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
641
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
642
|
+
new SmartHQWaterFilter(this, existingAccessory, device);
|
|
643
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
else if (!device.hide_device && !existingAccessory) {
|
|
650
|
+
this.infoLog(`Adding new accessory: ${device.nickname}`);
|
|
651
|
+
const accessory = new this.api.platformAccessory(device.nickname, uuid);
|
|
652
|
+
accessory.context.device = device;
|
|
653
|
+
accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
654
|
+
accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
655
|
+
accessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
656
|
+
new SmartHQWaterFilter(this, accessory, device);
|
|
657
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
658
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
659
|
+
this.accessories.push(accessory);
|
|
660
|
+
}
|
|
661
|
+
else {
|
|
662
|
+
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
async createSmartHQWaterSoftener(userId, device, details, features) {
|
|
666
|
+
const uuid = this.api.hap.uuid.generate(device.applianceId);
|
|
667
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
668
|
+
if (existingAccessory) {
|
|
669
|
+
if (!device.hide_device) {
|
|
670
|
+
existingAccessory.context.device = device;
|
|
671
|
+
existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
672
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
673
|
+
existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
674
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
675
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
676
|
+
new SmartHQWaterSoftener(this, existingAccessory, device);
|
|
677
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
678
|
+
}
|
|
679
|
+
else {
|
|
680
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
else if (!device.hide_device && !existingAccessory) {
|
|
684
|
+
this.infoLog(`Adding new accessory: ${device.nickname}`);
|
|
685
|
+
const accessory = new this.api.platformAccessory(device.nickname, uuid);
|
|
686
|
+
accessory.context.device = device;
|
|
687
|
+
accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
688
|
+
accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
689
|
+
accessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
690
|
+
new SmartHQWaterSoftener(this, accessory, device);
|
|
691
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
692
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
693
|
+
this.accessories.push(accessory);
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
async createSmartHQWaterHeater(userId, device, details, features) {
|
|
700
|
+
const uuid = this.api.hap.uuid.generate(device.applianceId);
|
|
701
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
702
|
+
if (existingAccessory) {
|
|
703
|
+
if (!device.hide_device) {
|
|
704
|
+
existingAccessory.context.device = device;
|
|
705
|
+
existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
706
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
707
|
+
existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
708
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
709
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
710
|
+
new SmartHQWaterHeater(this, existingAccessory, device);
|
|
711
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
712
|
+
}
|
|
713
|
+
else {
|
|
714
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
else if (!device.hide_device && !existingAccessory) {
|
|
718
|
+
this.infoLog(`Adding new accessory: ${device.nickname}`);
|
|
719
|
+
const accessory = new this.api.platformAccessory(device.nickname, uuid);
|
|
720
|
+
accessory.context.device = device;
|
|
721
|
+
accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
722
|
+
accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
723
|
+
accessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
724
|
+
new SmartHQWaterHeater(this, accessory, device);
|
|
725
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
726
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
727
|
+
this.accessories.push(accessory);
|
|
728
|
+
}
|
|
729
|
+
else {
|
|
730
|
+
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
async createSmartHQAdvantium(userId, device, details, features) {
|
|
734
|
+
const uuid = this.api.hap.uuid.generate(device.applianceId);
|
|
735
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
736
|
+
if (existingAccessory) {
|
|
737
|
+
if (!device.hide_device) {
|
|
738
|
+
existingAccessory.context.device = device;
|
|
739
|
+
existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
740
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
741
|
+
existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
742
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
743
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
744
|
+
new SmartHQAdvantium(this, existingAccessory, device);
|
|
745
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
746
|
+
}
|
|
747
|
+
else {
|
|
748
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
else if (!device.hide_device && !existingAccessory) {
|
|
752
|
+
this.infoLog(`Adding new accessory: ${device.nickname}`);
|
|
753
|
+
const accessory = new this.api.platformAccessory(device.nickname, uuid);
|
|
754
|
+
accessory.context.device = device;
|
|
755
|
+
accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
756
|
+
accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
757
|
+
accessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
758
|
+
new SmartHQAdvantium(this, accessory, device);
|
|
759
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
760
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
761
|
+
this.accessories.push(accessory);
|
|
762
|
+
}
|
|
763
|
+
else {
|
|
764
|
+
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
async createSmartHQMicrowave(userId, device, details, features) {
|
|
768
|
+
const uuid = this.api.hap.uuid.generate(device.applianceId);
|
|
769
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
770
|
+
if (existingAccessory) {
|
|
771
|
+
if (!device.hide_device) {
|
|
772
|
+
existingAccessory.context.device = device;
|
|
773
|
+
existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
774
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
775
|
+
existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
776
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
777
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
778
|
+
new SmartHQMicrowave(this, existingAccessory, device);
|
|
779
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
else if (!device.hide_device && !existingAccessory) {
|
|
786
|
+
this.infoLog(`Adding new accessory: ${device.nickname}`);
|
|
787
|
+
const accessory = new this.api.platformAccessory(device.nickname, uuid);
|
|
788
|
+
accessory.context.device = device;
|
|
789
|
+
accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
790
|
+
accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
791
|
+
accessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
792
|
+
new SmartHQMicrowave(this, accessory, device);
|
|
793
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
794
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
795
|
+
this.accessories.push(accessory);
|
|
796
|
+
}
|
|
797
|
+
else {
|
|
798
|
+
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
async createSmartHQCoffeeMaker(userId, device, details, features) {
|
|
802
|
+
const uuid = this.api.hap.uuid.generate(device.applianceId);
|
|
803
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
804
|
+
if (existingAccessory) {
|
|
805
|
+
if (!device.hide_device) {
|
|
806
|
+
existingAccessory.context.device = device;
|
|
807
|
+
existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
808
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
809
|
+
existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
810
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
811
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
812
|
+
new SmartHQCoffeeMaker(this, existingAccessory, device);
|
|
813
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
814
|
+
}
|
|
815
|
+
else {
|
|
816
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
else if (!device.hide_device && !existingAccessory) {
|
|
820
|
+
this.infoLog(`Adding new accessory: ${device.nickname}`);
|
|
821
|
+
const accessory = new this.api.platformAccessory(device.nickname, uuid);
|
|
822
|
+
accessory.context.device = device;
|
|
823
|
+
accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
824
|
+
accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
825
|
+
accessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
826
|
+
new SmartHQCoffeeMaker(this, accessory, device);
|
|
827
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
828
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
829
|
+
this.accessories.push(accessory);
|
|
830
|
+
}
|
|
831
|
+
else {
|
|
832
|
+
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
async createSmartHQBeverageCenter(userId, device, details, features) {
|
|
836
|
+
const uuid = this.api.hap.uuid.generate(device.applianceId);
|
|
837
|
+
const existingAccessory = this.accessories.find(accessory => accessory.UUID === uuid);
|
|
838
|
+
if (existingAccessory) {
|
|
839
|
+
if (!device.hide_device) {
|
|
840
|
+
existingAccessory.context.device = device;
|
|
841
|
+
existingAccessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
842
|
+
existingAccessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
843
|
+
existingAccessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
844
|
+
this.api.updatePlatformAccessories([existingAccessory]);
|
|
845
|
+
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName}`);
|
|
846
|
+
new SmartHQBeverageCenter(this, existingAccessory, device);
|
|
847
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
848
|
+
}
|
|
849
|
+
else {
|
|
850
|
+
this.unregisterPlatformAccessories(existingAccessory);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
else if (!device.hide_device && !existingAccessory) {
|
|
854
|
+
this.infoLog(`Adding new accessory: ${device.nickname}`);
|
|
855
|
+
const accessory = new this.api.platformAccessory(device.nickname, uuid);
|
|
856
|
+
accessory.context.device = device;
|
|
857
|
+
accessory.context = { device: { brand: 'GE', ...details, ...features }, userId };
|
|
858
|
+
accessory.displayName = await this.validateAndCleanDisplayName(device.nickname, 'nickname', device.nickname);
|
|
859
|
+
accessory.context.device.firmware = device.firmware ?? await this.getVersion();
|
|
860
|
+
new SmartHQBeverageCenter(this, accessory, device);
|
|
861
|
+
this.debugLog(`${device.nickname} uuid: ${device.applianceId}`);
|
|
862
|
+
this.api.registerPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [accessory]);
|
|
863
|
+
this.accessories.push(accessory);
|
|
864
|
+
}
|
|
865
|
+
else {
|
|
866
|
+
this.debugErrorLog(`Unable to Register new device: ${JSON.stringify(device.nickname)}`);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
486
869
|
async unregisterPlatformAccessories(existingAccessory) {
|
|
487
870
|
// remove platform accessories when no longer present
|
|
488
871
|
this.api.unregisterPlatformAccessories(PLUGIN_NAME, PLATFORM_NAME, [existingAccessory]);
|