homebridge-winix-purifiers 2.2.2 → 2.2.4

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/dist/platform.js CHANGED
@@ -22,7 +22,6 @@ class WinixPurifierPlatform {
22
22
  this.handlers = new Map();
23
23
  this.deviceOverrides = (this.config.deviceOverrides ?? [])
24
24
  .reduce((m, o) => m.set(o.deviceId, o), new Map());
25
- this.client = new winix_api_1.WinixClient();
26
25
  this.winix = new winix_1.WinixHandler(api.user.storagePath(), settings_1.ENCRYPTION_KEY);
27
26
  this.api.on("didFinishLaunching" /* APIEvent.DID_FINISH_LAUNCHING */, this.onFinishLaunching.bind(this));
28
27
  }
@@ -52,6 +51,7 @@ class WinixPurifierPlatform {
52
51
  this.log.error('error getting devices:', e.message);
53
52
  return;
54
53
  }
54
+ this.client = new winix_api_1.WinixClient(this.winix.getIdentityId());
55
55
  await this.discoverDevices();
56
56
  // refresh devices on the configured interval
57
57
  const refreshIntervalMs = (this.config.deviceRefreshIntervalMinutes ?? DEFAULT_DEVICE_REFRESH_INTERVAL_MINUTES) * 60 * 1000;
@@ -81,7 +81,13 @@ class WinixPurifierPlatform {
81
81
  const uuid = this.api.hap.uuid.generate(device.deviceId);
82
82
  let accessory = this.accessories.get(uuid);
83
83
  this.log.debug('Found', accessory ? 'existing' : 'new', 'accessory:', this.logName(device));
84
- if (accessory) {
84
+ if (accessory && this.handlers.has(uuid)) {
85
+ // Existing device on refresh: update metadata only, keep handler + polling loop
86
+ accessory.context.device = device;
87
+ this.api.updatePlatformAccessories([accessory]);
88
+ }
89
+ else if (accessory) {
90
+ // First boot with cached accessory: create handler
85
91
  accessory.context.device = device;
86
92
  const handler = await this.createNewAccessoryHandler(accessory, devices.length);
87
93
  this.handlers.set(uuid, handler);
package/dist/winix.js CHANGED
@@ -95,6 +95,12 @@ class WinixHandler {
95
95
  return '';
96
96
  }
97
97
  }
98
+ getIdentityId() {
99
+ if (!this.winix) {
100
+ throw new UnauthenticatedError();
101
+ }
102
+ return this.winix.getIdentityId();
103
+ }
98
104
  async getDevices() {
99
105
  if (!this.winix || !this.auth) {
100
106
  throw new UnauthenticatedError();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "Winix Air Purifiers",
3
3
  "name": "homebridge-winix-purifiers",
4
- "version": "2.2.2",
4
+ "version": "2.2.4",
5
5
  "description": "Homebridge plugin for Winix air purifiers",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -44,6 +44,8 @@
44
44
  "postversion": "git push && git push --tags && yarn clean",
45
45
  "prepublishOnly": "yarn validate",
46
46
  "test": "vitest run",
47
+ "test:integration": "vitest run --config vitest.integration.config.ts tests/integration/integration.test.ts --reporter=verbose",
48
+ "test:integration:rate-limit": "vitest run --config vitest.integration.config.ts tests/integration/integration-rate-limit.test.ts --reporter=verbose",
47
49
  "test:watch": "vitest",
48
50
  "test:coverage": "vitest run --coverage",
49
51
  "validate": "yarn lint && yarn build && yarn test",
@@ -63,7 +65,7 @@
63
65
  ],
64
66
  "dependencies": {
65
67
  "@homebridge/plugin-ui-utils": "1.0.3",
66
- "winix-api": "1.9.0"
68
+ "winix-api": "2.0.0"
67
69
  },
68
70
  "devDependencies": {
69
71
  "@types/node": "20.11.0",