homebridge-kasa-python 2.7.0-beta.8 → 2.7.0

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.
Files changed (49) hide show
  1. package/README.md +343 -562
  2. package/config.schema.json +23 -1
  3. package/dist/accessoryInformation.js +28 -13
  4. package/dist/accessoryInformation.js.map +1 -1
  5. package/dist/config.d.ts +8 -3
  6. package/dist/config.js +37 -42
  7. package/dist/config.js.map +1 -1
  8. package/dist/devices/create.js +15 -9
  9. package/dist/devices/create.js.map +1 -1
  10. package/dist/devices/deviceManager.d.ts +5 -3
  11. package/dist/devices/deviceManager.js +32 -66
  12. package/dist/devices/deviceManager.js.map +1 -1
  13. package/dist/devices/homekitLightBulb.d.ts +11 -1
  14. package/dist/devices/homekitLightBulb.js +221 -116
  15. package/dist/devices/homekitLightBulb.js.map +1 -1
  16. package/dist/devices/homekitPlug.d.ts +10 -0
  17. package/dist/devices/homekitPlug.js +184 -80
  18. package/dist/devices/homekitPlug.js.map +1 -1
  19. package/dist/devices/homekitPowerStrip.d.ts +10 -0
  20. package/dist/devices/homekitPowerStrip.js +199 -91
  21. package/dist/devices/homekitPowerStrip.js.map +1 -1
  22. package/dist/devices/homekitSwitch.d.ts +11 -1
  23. package/dist/devices/homekitSwitch.js +190 -89
  24. package/dist/devices/homekitSwitch.js.map +1 -1
  25. package/dist/devices/homekitSwitchWithChildren.d.ts +34 -0
  26. package/dist/devices/homekitSwitchWithChildren.js +365 -0
  27. package/dist/devices/homekitSwitchWithChildren.js.map +1 -0
  28. package/dist/devices/index.d.ts +5 -6
  29. package/dist/devices/index.js +18 -17
  30. package/dist/devices/index.js.map +1 -1
  31. package/dist/devices/kasaDevices.d.ts +4 -11
  32. package/dist/devices/kasaDevices.js +83 -95
  33. package/dist/devices/kasaDevices.js.map +1 -1
  34. package/dist/platform.d.ts +8 -2
  35. package/dist/platform.js +111 -46
  36. package/dist/platform.js.map +1 -1
  37. package/dist/python/kasaApi.py +349 -171
  38. package/dist/python/pythonChecker.d.ts +6 -4
  39. package/dist/python/pythonChecker.js +53 -20
  40. package/dist/python/pythonChecker.js.map +1 -1
  41. package/dist/python/startKasaApi.py +25 -0
  42. package/dist/taskQueue.d.ts +11 -0
  43. package/dist/taskQueue.js +44 -0
  44. package/dist/taskQueue.js.map +1 -0
  45. package/dist/utils.d.ts +1 -1
  46. package/dist/utils.js +8 -4
  47. package/dist/utils.js.map +1 -1
  48. package/package.json +15 -23
  49. package/requirements.txt +3 -3
@@ -1,3 +1,4 @@
1
+ import { EventEmitter } from 'node:events';
1
2
  import HomeKitDevice from './index.js';
2
3
  import { deferAndCombine } from '../utils.js';
3
4
  export default class HomeKitDevicePlug extends HomeKitDevice {
@@ -6,6 +7,8 @@ export default class HomeKitDevicePlug extends HomeKitDevice {
6
7
  previousKasaDevice;
7
8
  getSysInfo;
8
9
  pollingInterval;
10
+ updateEmitter = new EventEmitter();
11
+ static locks = new Map();
9
12
  constructor(platform, kasaDevice) {
10
13
  super(platform, kasaDevice, 7 /* Categories.OUTLET */, 'OUTLET');
11
14
  this.kasaDevice = kasaDevice;
@@ -14,7 +17,7 @@ export default class HomeKitDevicePlug extends HomeKitDevice {
14
17
  this.getSysInfo = deferAndCombine(async () => {
15
18
  if (this.deviceManager) {
16
19
  this.previousKasaDevice = JSON.parse(JSON.stringify(this.kasaDevice));
17
- this.kasaDevice.sys_info = await this.deviceManager.getSysInfo(this.deviceConfig);
20
+ this.kasaDevice.sys_info = await this.deviceManager.getSysInfo(this.kasaDevice.sys_info.host);
18
21
  this.log.debug(`Updated sys_info for device: ${this.kasaDevice.sys_info.alias}`);
19
22
  }
20
23
  else {
@@ -22,28 +25,54 @@ export default class HomeKitDevicePlug extends HomeKitDevice {
22
25
  }
23
26
  }, platform.config.advancedOptions.waitTimeUpdate);
24
27
  this.startPolling();
28
+ platform.periodicDeviceDiscoveryEmitter.on('periodicDeviceDiscoveryComplete', () => {
29
+ this.updateEmitter.emit('periodicDeviceDiscoveryComplete');
30
+ });
31
+ }
32
+ async withLock(key, action) {
33
+ let lock = HomeKitDevicePlug.locks.get(key);
34
+ if (!lock) {
35
+ lock = Promise.resolve();
36
+ }
37
+ const currentLock = lock.then(async () => {
38
+ try {
39
+ return await action();
40
+ }
41
+ finally {
42
+ if (HomeKitDevicePlug.locks.get(key) === currentLock) {
43
+ HomeKitDevicePlug.locks.delete(key);
44
+ }
45
+ }
46
+ });
47
+ HomeKitDevicePlug.locks.set(key, currentLock.then(() => { }));
48
+ return currentLock;
25
49
  }
26
50
  checkService() {
27
- const { Outlet } = this.platform.Service;
28
- const service = this.homebridgeAccessory.getService(Outlet) ?? this.addService(Outlet, this.name);
51
+ const serviceType = this.getServiceType();
52
+ const service = this.homebridgeAccessory.getService(serviceType) ?? this.addService(serviceType, this.name);
29
53
  this.checkCharacteristics(service);
30
- return service;
54
+ }
55
+ getServiceType() {
56
+ const { Outlet } = this.platform.Service;
57
+ return Outlet;
31
58
  }
32
59
  checkCharacteristics(service) {
33
- const characteristics = [
34
- {
35
- type: this.platform.Characteristic.On,
36
- name: this.platform.getCharacteristicName(this.platform.Characteristic.On),
37
- },
38
- {
39
- type: this.platform.Characteristic.OutletInUse,
40
- name: this.platform.getCharacteristicName(this.platform.Characteristic.OutletInUse),
41
- },
42
- ].filter(Boolean);
60
+ const characteristics = this.getCharacteristics();
43
61
  characteristics.forEach(({ type, name }) => {
44
62
  this.getOrAddCharacteristic(service, type, name);
45
63
  });
46
64
  }
65
+ getCharacteristics() {
66
+ const characteristics = [];
67
+ characteristics.push({
68
+ type: this.platform.Characteristic.On,
69
+ name: this.platform.getCharacteristicName(this.platform.Characteristic.On),
70
+ }, {
71
+ type: this.platform.Characteristic.OutletInUse,
72
+ name: this.platform.getCharacteristicName(this.platform.Characteristic.OutletInUse),
73
+ });
74
+ return characteristics;
75
+ }
47
76
  getOrAddCharacteristic(service, characteristicType, characteristicName) {
48
77
  const characteristic = service.getCharacteristic(characteristicType) ??
49
78
  service.addCharacteristic(characteristicType);
@@ -51,14 +80,13 @@ export default class HomeKitDevicePlug extends HomeKitDevice {
51
80
  if (characteristicType === this.platform.Characteristic.On) {
52
81
  characteristic.onSet(this.handleOnSet.bind(this, service, characteristicType, characteristicName));
53
82
  }
54
- return service;
55
83
  }
56
84
  async handleOnGet(service, characteristicType, characteristicName) {
85
+ if (this.kasaDevice.offline || this.platform.isShuttingDown) {
86
+ this.log.warn(`Device is offline or platform is shutting down, cannot get value for characteristic ${characteristicName}`);
87
+ return false;
88
+ }
57
89
  try {
58
- if (this.kasaDevice.offline) {
59
- this.log.warn(`Device is offline, cannot get value for characteristic ${characteristicName}`);
60
- return false;
61
- }
62
90
  let characteristicValue = service.getCharacteristic(characteristicType).value;
63
91
  if (!characteristicValue) {
64
92
  characteristicValue = this.getInitialValue(characteristicType);
@@ -71,8 +99,8 @@ export default class HomeKitDevicePlug extends HomeKitDevice {
71
99
  this.log.error(`Error getting current value for characteristic ${characteristicName} for device: ${this.name}:`, error);
72
100
  this.kasaDevice.offline = true;
73
101
  this.stopPolling();
102
+ return false;
74
103
  }
75
- return false;
76
104
  }
77
105
  getInitialValue(characteristicType) {
78
106
  if (characteristicType === this.platform.Characteristic.On || characteristicType === this.platform.Characteristic.OutletInUse) {
@@ -81,77 +109,152 @@ export default class HomeKitDevicePlug extends HomeKitDevice {
81
109
  return false;
82
110
  }
83
111
  async handleOnSet(service, characteristicType, characteristicName, value) {
84
- if (this.kasaDevice.offline) {
85
- this.log.warn(`Device is offline, cannot set value for characteristic ${characteristicName}`);
86
- return;
87
- }
88
- if (this.deviceManager) {
89
- try {
90
- this.isUpdating = true;
91
- this.log.debug(`Setting value for characteristic ${characteristicName} to ${value}`);
92
- const characteristicMap = {
93
- On: 'state',
94
- };
95
- const characteristicKey = characteristicMap[characteristicName ?? ''];
96
- if (!characteristicKey) {
97
- throw new Error(`Characteristic key not found for ${characteristicName}`);
98
- }
99
- await this.deviceManager.controlDevice(this.deviceConfig, characteristicKey, value);
100
- this.kasaDevice.sys_info[characteristicKey] = value;
101
- this.updateValue(service, service.getCharacteristic(characteristicType), this.name, value);
102
- this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.OutletInUse), this.name, value);
103
- this.previousKasaDevice = JSON.parse(JSON.stringify(this.kasaDevice));
104
- this.log.debug(`Set value for characteristic ${characteristicName} to ${value} successfully`);
112
+ const lockKey = `${this.kasaDevice.sys_info.device_id}`;
113
+ await this.withLock(lockKey, async () => {
114
+ if (this.kasaDevice.offline || this.platform.isShuttingDown) {
115
+ this.log.warn(`Device is offline or platform is shutting down, cannot set value for characteristic ${characteristicName}`);
116
+ return;
105
117
  }
106
- catch (error) {
107
- this.log.error(`Error setting current value for characteristic ${characteristicName} for device: ${this.name}:`, error);
108
- this.kasaDevice.offline = true;
109
- this.stopPolling();
110
- }
111
- finally {
112
- this.isUpdating = false;
118
+ if (this.isUpdating || this.platform.periodicDeviceDiscovering) {
119
+ await Promise.race([
120
+ new Promise((resolve) => this.updateEmitter.once('updateComplete', resolve)),
121
+ new Promise((resolve) => this.updateEmitter.once('periodicDeviceDiscoveryComplete', resolve)),
122
+ ]);
113
123
  }
114
- }
115
- else {
116
- throw new Error('Device manager is undefined.');
117
- }
124
+ const task = async () => {
125
+ if (this.deviceManager) {
126
+ try {
127
+ this.isUpdating = true;
128
+ this.log.debug(`Setting value for characteristic ${characteristicName} to ${value}`);
129
+ const characteristicKey = this.getCharacteristicKey(characteristicName);
130
+ if (!characteristicKey) {
131
+ throw new Error(`Characteristic key not found for ${characteristicName}`);
132
+ }
133
+ await this.deviceManager.controlDevice(this.kasaDevice.sys_info.host, characteristicKey, value);
134
+ this.kasaDevice.sys_info[characteristicKey] = value;
135
+ this.updateValue(service, service.getCharacteristic(characteristicType), this.name, value);
136
+ this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.OutletInUse), this.name, value);
137
+ this.previousKasaDevice = JSON.parse(JSON.stringify(this.kasaDevice));
138
+ this.log.debug(`Set value for characteristic ${characteristicName} to ${value} successfully`);
139
+ }
140
+ catch (error) {
141
+ this.log.error(`Error setting current value for characteristic ${characteristicName} for device: ${this.name}:`, error);
142
+ this.kasaDevice.offline = true;
143
+ this.stopPolling();
144
+ }
145
+ finally {
146
+ this.isUpdating = false;
147
+ this.updateEmitter.emit('updateComplete');
148
+ }
149
+ }
150
+ else {
151
+ throw new Error('Device manager is undefined.');
152
+ }
153
+ };
154
+ await task();
155
+ });
156
+ }
157
+ getCharacteristicKey(characteristicName) {
158
+ const characteristicMap = {
159
+ On: 'state',
160
+ };
161
+ return characteristicMap[characteristicName ?? ''];
118
162
  }
119
163
  async updateState() {
120
- if (this.kasaDevice.offline) {
121
- this.stopPolling();
122
- return;
123
- }
124
- if (this.isUpdating || this.platform.periodicDeviceDiscovering) {
125
- return;
126
- }
127
- this.isUpdating = true;
128
- try {
129
- await this.getSysInfo();
130
- const service = this.homebridgeAccessory.getService(this.platform.Service.Outlet);
131
- if (service && this.previousKasaDevice) {
132
- const { state } = this.kasaDevice.sys_info;
133
- const prevState = this.previousKasaDevice.sys_info;
134
- if (prevState.state !== state) {
135
- this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.On), this.name, state ?? false);
136
- this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.OutletInUse), this.name, state ?? false);
137
- this.log.debug(`Updated state for device: ${this.name} to ${state}`);
164
+ const lockKey = `${this.kasaDevice.sys_info.device_id}`;
165
+ await this.withLock(lockKey, async () => {
166
+ if (this.kasaDevice.offline || this.platform.isShuttingDown) {
167
+ this.stopPolling();
168
+ return;
169
+ }
170
+ if (this.isUpdating || this.platform.periodicDeviceDiscovering) {
171
+ let periodicDiscoveryComplete = false;
172
+ await Promise.race([
173
+ new Promise((resolve) => this.updateEmitter.once('updateComplete', resolve)),
174
+ new Promise((resolve) => {
175
+ this.updateEmitter.once('periodicDeviceDiscoveryComplete', () => {
176
+ periodicDiscoveryComplete = true;
177
+ resolve();
178
+ });
179
+ }),
180
+ ]);
181
+ if (periodicDiscoveryComplete) {
182
+ if (this.pollingInterval) {
183
+ await new Promise((resolve) => setTimeout(resolve, this.platform.config.discoveryOptions.pollingInterval));
184
+ }
185
+ else {
186
+ return;
187
+ }
138
188
  }
139
189
  }
140
- else {
141
- this.log.warn(`Service not found for device: ${this.name} or previous Kasa device is undefined`);
190
+ this.isUpdating = true;
191
+ const task = async () => {
192
+ try {
193
+ await this.getSysInfo();
194
+ const service = this.getService();
195
+ if (service && this.previousKasaDevice) {
196
+ this.updateDeviceState(service);
197
+ }
198
+ else {
199
+ this.log.warn(`Service not found for device: ${this.name} or previous Kasa device is undefined`);
200
+ }
201
+ }
202
+ catch (error) {
203
+ this.log.error('Error updating device state:', error);
204
+ this.kasaDevice.offline = true;
205
+ this.stopPolling();
206
+ }
207
+ finally {
208
+ this.isUpdating = false;
209
+ this.updateEmitter.emit('updateComplete');
210
+ }
211
+ };
212
+ await task();
213
+ });
214
+ }
215
+ getService() {
216
+ return this.homebridgeAccessory.getService(this.platform.Service.Outlet);
217
+ ;
218
+ }
219
+ updateDeviceState(service) {
220
+ const previousKasaDevice = this.previousKasaDevice;
221
+ if (previousKasaDevice) {
222
+ if (previousKasaDevice.sys_info.state !== this.kasaDevice.sys_info.state) {
223
+ this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.On), this.name, this.kasaDevice.sys_info.state ?? false);
224
+ this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.OutletInUse), this.name, this.kasaDevice.sys_info.state ?? false);
225
+ this.log.debug(`Updated state for child device: ${this.name} to ${this.kasaDevice.sys_info.state}`);
142
226
  }
143
227
  }
144
- catch (error) {
145
- this.log.error('Error updating device state:', error);
146
- this.kasaDevice.offline = true;
147
- this.stopPolling();
228
+ }
229
+ updateAfterPeriodicDiscovery() {
230
+ const serviceType = this.getServiceType();
231
+ const service = this.homebridgeAccessory.getService(serviceType);
232
+ if (service) {
233
+ this.updateCharacteristics(service);
148
234
  }
149
- finally {
150
- this.isUpdating = false;
235
+ else {
236
+ this.log.debug(`Service not found for device: ${this.name}`);
151
237
  }
152
238
  }
239
+ updateCharacteristics(service) {
240
+ const characteristics = this.getCharacteristics();
241
+ characteristics.forEach(({ type, name }) => {
242
+ if (type === this.platform.Characteristic.On) {
243
+ const characteristic = service.getCharacteristic(type);
244
+ if (characteristic) {
245
+ const characteristicKey = this.getCharacteristicKey(name);
246
+ if (this.kasaDevice.sys_info[characteristicKey] !== undefined) {
247
+ const value = this.kasaDevice.sys_info[characteristicKey];
248
+ this.log.debug(`Setting value for characteristic ${name} to ${value}`);
249
+ this.updateValue(service, characteristic, this.name, value);
250
+ this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.OutletInUse), this.name, value);
251
+ }
252
+ }
253
+ }
254
+ });
255
+ }
153
256
  startPolling() {
154
- if (this.kasaDevice.offline) {
257
+ if (this.kasaDevice.offline || this.platform.isShuttingDown) {
155
258
  this.stopPolling();
156
259
  return;
157
260
  }
@@ -160,9 +263,10 @@ export default class HomeKitDevicePlug extends HomeKitDevice {
160
263
  }
161
264
  this.log.debug('Starting polling for device:', this.name);
162
265
  this.pollingInterval = setInterval(async () => {
163
- if (this.kasaDevice.offline) {
266
+ if (this.kasaDevice.offline || this.platform.isShuttingDown) {
164
267
  if (this.isUpdating) {
165
268
  this.isUpdating = false;
269
+ this.updateEmitter.emit('updateComplete');
166
270
  }
167
271
  this.stopPolling();
168
272
  }
@@ -1 +1 @@
1
- {"version":3,"file":"homekitPlug.js","sourceRoot":"","sources":["../../src/devices/homekitPlug.ts"],"names":[],"mappings":"AAGA,OAAO,aAAa,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI9C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,aAAa;IAQjD;IAPF,UAAU,GAAY,KAAK,CAAC;IAC3B,kBAAkB,CAAyB;IAC3C,UAAU,CAAsB;IAChC,eAAe,CAA6B;IAEpD,YACE,QAA4B,EACrB,UAAgB;QAEvB,KAAK,CACH,QAAQ,EACR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AG,WAAW,CAAC,KAAK,IAAI,EAAE;YAC5C,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;gBAC5D,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACpB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;oBACxB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;gBAC5C,CAAC;gBACD,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;YAC3B,CAAC;QACH,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;IAC5D,CAAC;IAEM,WAAW;QAChB,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACpC,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;YACjC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED,QAAQ;QACN,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5B,CAAC"}
@@ -7,14 +7,24 @@ export default class HomeKitDevicePowerStrip extends HomeKitDevice {
7
7
  private previousKasaDevice;
8
8
  private getSysInfo;
9
9
  private pollingInterval;
10
+ private updateEmitter;
11
+ private static locks;
10
12
  constructor(platform: KasaPythonPlatform, kasaDevice: PowerStrip);
13
+ private withLock;
11
14
  private checkService;
15
+ private getServiceType;
12
16
  private checkCharacteristics;
17
+ private getCharacteristics;
13
18
  private getOrAddCharacteristic;
14
19
  private handleOnGet;
15
20
  private getInitialValue;
16
21
  private handleOnSet;
22
+ private getCharacteristicKey;
17
23
  protected updateState(): Promise<void>;
24
+ private getService;
25
+ private updateChildState;
26
+ updateAfterPeriodicDiscovery(): void;
27
+ private updateCharacteristics;
18
28
  startPolling(): void;
19
29
  stopPolling(): void;
20
30
  identify(): void;