homebridge-kasa-python 2.9.1 → 3.0.0-beta.1

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 (57) hide show
  1. package/README.md +1 -1
  2. package/config.schema.json +17 -2
  3. package/dist/accessoryInformation.d.ts +2 -2
  4. package/dist/accessoryInformation.js +24 -28
  5. package/dist/accessoryInformation.js.map +1 -1
  6. package/dist/config.d.ts +5 -1
  7. package/dist/config.js +24 -16
  8. package/dist/config.js.map +1 -1
  9. package/dist/devices/baseDevice.d.ts +61 -0
  10. package/dist/devices/baseDevice.js +361 -0
  11. package/dist/devices/baseDevice.js.map +1 -0
  12. package/dist/devices/baseParent.d.ts +19 -0
  13. package/dist/devices/baseParent.js +150 -0
  14. package/dist/devices/baseParent.js.map +1 -0
  15. package/dist/devices/create.d.ts +3 -3
  16. package/dist/devices/create.js +21 -27
  17. package/dist/devices/create.js.map +1 -1
  18. package/dist/devices/descriptorHelpers.d.ts +14 -0
  19. package/dist/devices/descriptorHelpers.js +146 -0
  20. package/dist/devices/descriptorHelpers.js.map +1 -0
  21. package/dist/devices/deviceManager.d.ts +13 -13
  22. package/dist/devices/deviceManager.js +115 -137
  23. package/dist/devices/deviceManager.js.map +1 -1
  24. package/dist/devices/{kasaDevices.d.ts → deviceTypes.d.ts} +58 -42
  25. package/dist/devices/deviceTypes.js +20 -0
  26. package/dist/devices/deviceTypes.js.map +1 -0
  27. package/dist/devices/homekitLightBulb.d.ts +7 -28
  28. package/dist/devices/homekitLightBulb.js +42 -365
  29. package/dist/devices/homekitLightBulb.js.map +1 -1
  30. package/dist/devices/homekitPlug.d.ts +6 -25
  31. package/dist/devices/homekitPlug.js +21 -322
  32. package/dist/devices/homekitPlug.js.map +1 -1
  33. package/dist/devices/homekitPowerStrip.d.ts +6 -26
  34. package/dist/devices/homekitPowerStrip.js +25 -345
  35. package/dist/devices/homekitPowerStrip.js.map +1 -1
  36. package/dist/devices/homekitSwitch.d.ts +5 -26
  37. package/dist/devices/homekitSwitch.js +18 -302
  38. package/dist/devices/homekitSwitch.js.map +1 -1
  39. package/dist/devices/homekitSwitchWithChildren.d.ts +5 -29
  40. package/dist/devices/homekitSwitchWithChildren.js +24 -371
  41. package/dist/devices/homekitSwitchWithChildren.js.map +1 -1
  42. package/dist/energyCharacteristics.d.ts +8 -0
  43. package/dist/energyCharacteristics.js +88 -0
  44. package/dist/energyCharacteristics.js.map +1 -0
  45. package/dist/platform.d.ts +4 -2
  46. package/dist/platform.js +68 -63
  47. package/dist/platform.js.map +1 -1
  48. package/dist/python/kasaApi.py +68 -55
  49. package/dist/python/pythonChecker.js +2 -2
  50. package/dist/python/pythonChecker.js.map +1 -1
  51. package/package.json +15 -15
  52. package/requirements.txt +2 -2
  53. package/dist/devices/index.d.ts +0 -33
  54. package/dist/devices/index.js +0 -100
  55. package/dist/devices/index.js.map +0 -1
  56. package/dist/devices/kasaDevices.js +0 -102
  57. package/dist/devices/kasaDevices.js.map +0 -1
@@ -1,395 +1,72 @@
1
- import { EventEmitter } from 'node:events';
2
- import HomeKitDevice from './index.js';
3
- import { deferAndCombine } from '../utils.js';
1
+ import HomeKitDevice from './baseDevice.js';
2
+ import { buildOnDescriptor, buildBrightnessDescriptor, buildColorTemperatureDescriptor, buildHSVDescriptors, } from './descriptorHelpers.js';
4
3
  export default class HomeKitDeviceLightBulb extends HomeKitDevice {
5
4
  kasaDevice;
6
- isUpdating = false;
7
- getSysInfo;
8
5
  hasBrightness;
9
6
  hasColorTemp;
10
7
  hasHSV;
11
- hsvUpdateTimeout = setTimeout(() => { }, 0);
12
- pendingHSVUpdate = { hue: 0, saturation: 0 };
13
- previousKasaDevice;
14
- pollingInterval;
15
- updateEmitter = new EventEmitter();
16
- static locks = new Map();
8
+ pendingHSV = {};
9
+ hsvFlushTimer = null;
17
10
  constructor(platform, kasaDevice) {
18
11
  super(platform, kasaDevice, 5 /* Categories.LIGHTBULB */, 'LIGHTBULB');
19
12
  this.kasaDevice = kasaDevice;
20
- this.log.debug(`Initializing HomeKitDeviceLightBulb for device: ${kasaDevice.sys_info.alias}`);
21
- this.hasBrightness = !!this.kasaDevice.feature_info.brightness;
22
- this.hasColorTemp = !!this.kasaDevice.feature_info.color_temp;
23
- this.hasHSV = !!this.kasaDevice.feature_info.hsv;
24
- this.checkService();
25
- this.getSysInfo = deferAndCombine(async () => {
26
- if (!this.deviceManager) {
27
- this.log.warn('Device manager is not available');
28
- return;
29
- }
30
- const host = this.kasaDevice.sys_info?.host;
31
- if (!host) {
32
- this.log.warn('No host found in sys_info for device');
33
- return;
34
- }
35
- try {
36
- this.previousKasaDevice = { ...this.kasaDevice };
37
- const updatedSysInfo = await this.deviceManager.getSysInfo(host);
38
- if (!updatedSysInfo) {
39
- this.log.warn('getSysInfo returned undefined');
40
- return;
41
- }
42
- this.kasaDevice.sys_info = updatedSysInfo;
43
- this.log.debug(`Updated sys_info for device: ${updatedSysInfo.alias ?? host}`);
44
- }
45
- catch (err) {
46
- const errorMsg = 'Error updating sys_info:';
47
- if (err instanceof Error) {
48
- this.log.error(`${errorMsg} ${err.message}`);
49
- }
50
- else {
51
- this.log.error(`${errorMsg} ${String(err)}`);
52
- }
53
- }
54
- }, platform.config.advancedOptions.waitTimeUpdate);
55
- platform.periodicDeviceDiscoveryEmitter.on('periodicDeviceDiscoveryComplete', () => {
56
- this.updateEmitter.emit('periodicDeviceDiscoveryComplete');
57
- });
13
+ this.hasBrightness = !!kasaDevice.feature_info.brightness;
14
+ this.hasColorTemp = !!kasaDevice.feature_info.color_temp;
15
+ this.hasHSV = !!kasaDevice.feature_info.hsv;
16
+ this.setupPrimaryService();
58
17
  }
59
18
  async initialize() {
60
- this.log.debug(`Initializing polling for device: ${this.kasaDevice.sys_info.alias}`);
61
19
  await this.startPolling();
62
20
  }
63
- async withLock(key, action) {
64
- let lock = HomeKitDeviceLightBulb.locks.get(key);
65
- if (!lock) {
66
- lock = Promise.resolve();
67
- }
68
- const currentLock = lock.then(async () => {
69
- try {
70
- return await action();
71
- }
72
- finally {
73
- if (HomeKitDeviceLightBulb.locks.get(key) === currentLock) {
74
- HomeKitDeviceLightBulb.locks.delete(key);
75
- }
76
- }
77
- });
78
- HomeKitDeviceLightBulb.locks.set(key, currentLock.then(() => { }));
79
- return currentLock;
80
- }
81
- checkService() {
82
- const serviceType = this.getServiceType();
83
- const service = this.homebridgeAccessory.getService(serviceType) ?? this.addService(serviceType, this.name);
84
- this.checkCharacteristics(service);
21
+ getPrimaryServiceType() {
22
+ return this.platform.Service.Lightbulb;
85
23
  }
86
- getServiceType() {
87
- const { Lightbulb } = this.platform.Service;
88
- return Lightbulb;
89
- }
90
- checkCharacteristics(service) {
91
- const characteristics = this.getCharacteristics();
92
- characteristics.forEach(({ type, name }) => {
93
- this.getOrAddCharacteristic(service, type, name);
94
- });
95
- }
96
- getCharacteristics() {
97
- const characteristics = [];
98
- characteristics.push({
99
- type: this.platform.Characteristic.On,
100
- name: this.platform.getCharacteristicName(this.platform.Characteristic.On),
24
+ buildPrimaryDescriptors() {
25
+ const C = this.platform.Characteristic;
26
+ const onDescriptor = buildOnDescriptor(C, async (value, context) => {
27
+ await this.deviceManager.controlDevice(context.device.host, 'state', value);
101
28
  });
29
+ const list = [onDescriptor];
102
30
  if (this.hasBrightness) {
103
- characteristics.push({
104
- type: this.platform.Characteristic.Brightness,
105
- name: this.platform.getCharacteristicName(this.platform.Characteristic.Brightness),
106
- });
31
+ list.push(buildBrightnessDescriptor(C, async (value, context) => {
32
+ await this.deviceManager.controlDevice(context.device.host, 'brightness', value);
33
+ }));
107
34
  }
108
35
  if (this.hasColorTemp) {
109
- characteristics.push({
110
- type: this.platform.Characteristic.ColorTemperature,
111
- name: this.platform.getCharacteristicName(this.platform.Characteristic.ColorTemperature),
112
- });
36
+ list.push(buildColorTemperatureDescriptor(C, async (value, context) => {
37
+ await this.deviceManager.controlDevice(context.device.host, 'color_temp', value);
38
+ }));
113
39
  }
114
40
  if (this.hasHSV) {
115
- characteristics.push({
116
- type: this.platform.Characteristic.Hue,
117
- name: this.platform.getCharacteristicName(this.platform.Characteristic.Hue),
118
- }, {
119
- type: this.platform.Characteristic.Saturation,
120
- name: this.platform.getCharacteristicName(this.platform.Characteristic.Saturation),
121
- });
122
- }
123
- return characteristics;
124
- }
125
- getOrAddCharacteristic(service, characteristicType, characteristicName) {
126
- const characteristic = service.getCharacteristic(characteristicType) ??
127
- service.addCharacteristic(characteristicType);
128
- characteristic.onGet(this.handleOnGet.bind(this, service, characteristicType, characteristicName));
129
- characteristic.onSet(this.handleOnSet.bind(this, service, characteristicType, characteristicName));
130
- }
131
- async handleOnGet(service, characteristicType, characteristicName) {
132
- if (this.kasaDevice.offline || this.platform.isShuttingDown) {
133
- this.log.warn(`Device is offline or platform is shutting down, cannot get value for characteristic ${characteristicName}`);
134
- return this.getDefaultValue(characteristicType);
135
- }
136
- try {
137
- let characteristicValue = service.getCharacteristic(characteristicType).value;
138
- if (!characteristicValue) {
139
- characteristicValue = this.getInitialValue(characteristicType);
140
- service.getCharacteristic(characteristicType).updateValue(characteristicValue);
141
- }
142
- this.log.debug(`Got value for characteristic ${characteristicName}: ${characteristicValue}`);
143
- return characteristicValue ?? this.getDefaultValue(characteristicType);
144
- }
145
- catch (error) {
146
- this.log.error(`Error getting current value for characteristic ${characteristicName} for device: ${this.name}:`, error);
147
- this.kasaDevice.offline = true;
148
- await this.stopPolling();
149
- return this.getDefaultValue(characteristicType);
150
- }
151
- }
152
- getDefaultValue(characteristicType) {
153
- const zeroValueCharacteristics = [
154
- this.platform.Characteristic.Brightness,
155
- this.platform.Characteristic.ColorTemperature,
156
- this.platform.Characteristic.Hue,
157
- this.platform.Characteristic.Saturation,
158
- ];
159
- if (zeroValueCharacteristics.includes(characteristicType)) {
160
- return 0;
161
- }
162
- return false;
163
- }
164
- getInitialValue(characteristicType) {
165
- if (characteristicType === this.platform.Characteristic.On) {
166
- return this.kasaDevice.sys_info.state ?? false;
167
- }
168
- else if (characteristicType === this.platform.Characteristic.Brightness) {
169
- return this.kasaDevice.sys_info.brightness ?? 0;
170
- }
171
- else if (characteristicType === this.platform.Characteristic.ColorTemperature) {
172
- return this.kasaDevice.sys_info.color_temp ?? 0;
173
- }
174
- else if (characteristicType === this.platform.Characteristic.Hue) {
175
- return this.kasaDevice.sys_info.hsv?.hue ?? 0;
176
- }
177
- else if (characteristicType === this.platform.Characteristic.Saturation) {
178
- return this.kasaDevice.sys_info.hsv?.saturation ?? 0;
179
- }
180
- return this.getDefaultValue(characteristicType);
181
- }
182
- async handleOnSet(service, characteristicType, characteristicName, value) {
183
- const lockKey = `${this.kasaDevice.sys_info.device_id}`;
184
- await this.withLock(lockKey, async () => {
185
- if (this.kasaDevice.offline || this.platform.isShuttingDown) {
186
- this.log.warn(`Device is offline or platform is shutting down, cannot set value for characteristic ${characteristicName}`);
187
- return;
188
- }
189
- const task = async () => {
190
- if (this.deviceManager) {
41
+ list.push(...buildHSVDescriptors(C, async (partial, context) => {
42
+ Object.assign(this.pendingHSV, partial);
43
+ if (this.hsvFlushTimer) {
44
+ clearTimeout(this.hsvFlushTimer);
45
+ }
46
+ const host = context.device.host;
47
+ const baseHue = this.kasaDevice.sys_info.hsv?.hue ?? 0;
48
+ const baseSat = this.kasaDevice.sys_info.hsv?.saturation ?? 0;
49
+ this.hsvFlushTimer = setTimeout(async () => {
50
+ const hue = this.pendingHSV.hue ?? baseHue;
51
+ const saturation = this.pendingHSV.saturation ?? baseSat;
191
52
  try {
192
- this.isUpdating = true;
193
- const characteristicKey = this.getCharacteristicKey(characteristicName);
194
- if (!characteristicKey) {
195
- throw new Error(`Characteristic key not found for ${characteristicName}`);
196
- }
197
- if (characteristicKey === 'hue' || characteristicKey === 'saturation') {
198
- this.pendingHSVUpdate[characteristicKey] = value;
199
- if (this.hsvUpdateTimeout) {
200
- clearTimeout(this.hsvUpdateTimeout);
201
- }
202
- this.hsvUpdateTimeout = setTimeout(async () => {
203
- const hue = this.pendingHSVUpdate.hue ?? this.kasaDevice.sys_info.hsv?.hue ?? 0;
204
- const saturation = this.pendingHSVUpdate.saturation ?? this.kasaDevice.sys_info.hsv?.saturation ?? 0;
205
- this.log.debug(`Setting value for characteristic Hue to ${hue} and Saturation to ${saturation}`);
206
- if (this.deviceManager) {
207
- await this.deviceManager.controlDevice(this.kasaDevice.sys_info.host, 'hsv', { hue, saturation });
208
- }
209
- this.kasaDevice.sys_info.hsv = { hue, saturation };
210
- this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.Hue), this.name, hue);
211
- this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.Saturation), this.name, saturation);
212
- this.previousKasaDevice = JSON.parse(JSON.stringify(this.kasaDevice));
213
- this.log.debug(`Set value for characteristic Hue to ${hue} and Saturation to ${saturation} successfully`);
214
- this.pendingHSVUpdate = { hue: 0, saturation: 0 };
215
- }, 50);
216
- }
217
- else {
218
- this.log.debug(`Setting value for characteristic ${characteristicName} to ${value}`);
219
- await this.deviceManager.controlDevice(this.kasaDevice.sys_info.host, characteristicKey, value);
220
- this.kasaDevice.sys_info[characteristicKey] = value;
221
- this.updateValue(service, service.getCharacteristic(characteristicType), this.name, value);
222
- this.previousKasaDevice = JSON.parse(JSON.stringify(this.kasaDevice));
223
- this.log.debug(`Set value for characteristic ${characteristicName} to ${value} successfully`);
224
- }
53
+ await this.deviceManager.controlDevice(host, 'hsv', { hue, saturation });
54
+ context.device.hsv = { hue, saturation };
55
+ this.kasaDevice.sys_info.hsv = { hue, saturation };
225
56
  }
226
57
  catch (error) {
227
- this.log.error(`Error setting current value for characteristic ${characteristicName} for device: ${this.name}:`, error);
228
- this.kasaDevice.offline = true;
229
- await this.stopPolling();
58
+ this.log.error('HSV flush error', error);
230
59
  }
231
60
  finally {
232
- this.isUpdating = false;
233
- this.updateEmitter.emit('updateComplete');
61
+ this.pendingHSV = {};
234
62
  }
235
- }
236
- else {
237
- throw new Error('Device manager is undefined.');
238
- }
239
- };
240
- await task();
241
- });
242
- }
243
- getCharacteristicKey(characteristicName) {
244
- const characteristicMap = {
245
- On: 'state',
246
- Brightness: 'brightness',
247
- ColorTemperature: 'color_temp',
248
- Hue: 'hue',
249
- Saturation: 'saturation',
250
- };
251
- return characteristicMap[characteristicName ?? ''];
252
- }
253
- async updateState() {
254
- const lockKey = `${this.kasaDevice.sys_info.device_id}`;
255
- await this.withLock(lockKey, async () => {
256
- if (this.kasaDevice.offline || this.platform.isShuttingDown) {
257
- await this.stopPolling();
258
- return;
259
- }
260
- if (this.isUpdating || this.platform.periodicDeviceDiscovering) {
261
- let periodicDiscoveryComplete = false;
262
- await Promise.race([
263
- new Promise((resolve) => this.updateEmitter.once('updateComplete', resolve)),
264
- new Promise((resolve) => {
265
- this.updateEmitter.once('periodicDeviceDiscoveryComplete', () => {
266
- periodicDiscoveryComplete = true;
267
- resolve();
268
- });
269
- }),
270
- ]);
271
- if (periodicDiscoveryComplete) {
272
- if (this.pollingInterval) {
273
- await new Promise((resolve) => setTimeout(resolve, this.platform.config.discoveryOptions.pollingInterval));
274
- }
275
- else {
276
- return;
277
- }
278
- }
279
- }
280
- this.isUpdating = true;
281
- const task = async () => {
282
- try {
283
- await this.getSysInfo();
284
- const service = this.getService();
285
- if (service && this.previousKasaDevice) {
286
- this.updateDeviceState(service);
287
- }
288
- else {
289
- this.log.warn(`Service not found for device: ${this.name} or previous Kasa device is undefined`);
290
- }
291
- }
292
- catch (error) {
293
- this.log.error('Error updating device state:', error);
294
- this.kasaDevice.offline = true;
295
- await this.stopPolling();
296
- }
297
- finally {
298
- this.isUpdating = false;
299
- this.updateEmitter.emit('updateComplete');
300
- }
301
- };
302
- await task();
303
- });
304
- }
305
- getService() {
306
- return this.homebridgeAccessory.getService(this.platform.Service.Lightbulb);
307
- }
308
- updateDeviceState(service) {
309
- const { state, brightness, color_temp, hsv } = this.kasaDevice.sys_info;
310
- const prevState = this.previousKasaDevice.sys_info;
311
- if (prevState.state !== state) {
312
- this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.On), this.name, state ?? false);
313
- this.log.debug(`Updated state for device: ${this.name} to state: ${state}`);
314
- }
315
- if (this.hasBrightness && prevState.brightness !== brightness) {
316
- this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.Brightness), this.name, brightness ?? 0);
317
- this.log.debug(`Updated brightness for device: ${this.name} to brightness: ${brightness}`);
318
- }
319
- if (this.hasColorTemp && prevState.color_temp !== color_temp) {
320
- this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.ColorTemperature), this.name, color_temp ?? 0);
321
- this.log.debug(`Updated color_temp for device: ${this.name} to color_temp: ${color_temp}`);
63
+ }, 40);
64
+ }));
322
65
  }
323
- if (this.hasHSV) {
324
- if (prevState.hsv?.hue !== hsv?.hue) {
325
- this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.Hue), this.name, hsv?.hue ?? 0);
326
- this.log.debug(`Updated hue for device: ${this.name} to hue: ${hsv?.hue}`);
327
- }
328
- if (prevState.hsv?.saturation !== hsv?.saturation) {
329
- this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.Saturation), this.name, hsv?.saturation ?? 0);
330
- this.log.debug(`Updated saturation for device: ${this.name} to saturation: ${hsv?.saturation}`);
331
- }
332
- }
333
- }
334
- updateAfterPeriodicDiscovery() {
335
- const serviceType = this.getServiceType();
336
- const service = this.homebridgeAccessory.getService(serviceType);
337
- if (service) {
338
- this.updateCharacteristics(service);
339
- }
340
- else {
341
- this.log.debug(`Service not found for device: ${this.name}`);
342
- }
343
- }
344
- updateCharacteristics(service) {
345
- const characteristics = this.getCharacteristics();
346
- characteristics.forEach(({ type, name }) => {
347
- const characteristic = service.getCharacteristic(type);
348
- if (characteristic) {
349
- const characteristicKey = this.getCharacteristicKey(name);
350
- if (this.kasaDevice.sys_info[characteristicKey] !== undefined) {
351
- const value = this.kasaDevice.sys_info[characteristicKey];
352
- this.log.debug(`Setting value for characteristic ${name} to ${value}`);
353
- this.updateValue(service, characteristic, this.name, value);
354
- }
355
- }
356
- });
66
+ return list;
357
67
  }
358
- async startPolling() {
359
- if (this.kasaDevice.offline || this.platform.isShuttingDown) {
360
- await this.stopPolling();
361
- return;
362
- }
363
- if (this.pollingInterval) {
364
- clearInterval(this.pollingInterval);
365
- }
366
- this.log.debug('Starting polling for device:', this.name);
367
- this.pollingInterval = setInterval(async () => {
368
- if (this.kasaDevice.offline || this.platform.isShuttingDown) {
369
- if (this.isUpdating) {
370
- this.isUpdating = false;
371
- this.updateEmitter.emit('updateComplete');
372
- }
373
- await this.stopPolling();
374
- }
375
- else {
376
- await this.updateState();
377
- }
378
- }, this.platform.config.discoveryOptions.pollingInterval);
379
- }
380
- async stopPolling() {
381
- if (this.pollingInterval) {
382
- clearInterval(this.pollingInterval);
383
- this.pollingInterval = undefined;
384
- this.log.debug('Stopped polling');
385
- }
386
- if (this.isUpdating) {
387
- this.log.debug('Waiting for ongoing polling task to complete for device:', this.name);
388
- await new Promise((resolve) => {
389
- this.isUpdating = false;
390
- this.updateEmitter.once('updateComplete', resolve);
391
- });
392
- }
68
+ async updateAllServicesAndCharacteristics(forceUpdate) {
69
+ await super.updateAllServicesAndCharacteristics(forceUpdate);
393
70
  }
394
71
  identify() {
395
72
  this.log.info('identify');
@@ -1 +1 @@
1
- {"version":3,"file":"homekitLightBulb.js","sourceRoot":"","sources":["../../src/devices/homekitLightBulb.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,aAAa,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAI9C,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,aAAa;IAetD;IAdF,UAAU,GAAY,KAAK,CAAC;IAC3B,UAAU,CAAsB;IAChC,aAAa,CAAU;IACvB,YAAY,CAAU;IACtB,MAAM,CAAU;IAChB,gBAAgB,GAAmB,UAAU,CAAC,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3D,gBAAgB,GAAQ,EAAC,GAAG,EAA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,CAAC,UAAU,GAAG,EAAE,CAAC;oBACvB,CAAC;gBACH,CAAC,EAAE,EAAE,CAAC,CAAC;YACT,CAAC,CACF,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAES,KAAK,CAAC,mCAAmC,CAAC,WAAoB;QACtE,MAAM,KAAK,CAAC,mCAAmC,CAAC,WAAW,CAAC,CAAC;IAC/D,CAAC;IAEM,QAAQ;QACb,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC5B,CAAC;CACF"}
@@ -1,32 +1,13 @@
1
- import HomeKitDevice from './index.js';
1
+ import HomeKitDevice from './baseDevice.js';
2
2
  import type KasaPythonPlatform from '../platform.js';
3
- import type { Plug } from './kasaDevices.js';
3
+ import type { Plug, CharacteristicDescriptor } from './deviceTypes.js';
4
4
  export default class HomeKitDevicePlug extends HomeKitDevice {
5
5
  kasaDevice: Plug;
6
- isUpdating: boolean;
7
- private previousKasaDevice;
8
- private getSysInfo;
9
- private pollingInterval;
10
- private updateEmitter;
11
- private static locks;
6
+ private hasEnergy;
12
7
  constructor(platform: KasaPythonPlatform, kasaDevice: Plug);
13
8
  initialize(): Promise<void>;
14
- private withLock;
15
- private checkService;
16
- private getServiceType;
17
- private checkCharacteristics;
18
- private getCharacteristics;
19
- private getOrAddCharacteristic;
20
- private handleOnGet;
21
- private getInitialValue;
22
- private handleOnSet;
23
- private getCharacteristicKey;
24
- protected updateState(): Promise<void>;
25
- private getService;
26
- private updateDeviceState;
27
- updateAfterPeriodicDiscovery(): void;
28
- private updateCharacteristics;
29
- startPolling(): Promise<void>;
30
- stopPolling(): Promise<void>;
9
+ protected getPrimaryServiceType(): typeof import("hap-nodejs/dist/lib/definitions/ServiceDefinitions.js").Outlet;
10
+ protected buildPrimaryDescriptors(): CharacteristicDescriptor[];
11
+ protected updateAllServicesAndCharacteristics(forceUpdate: boolean): Promise<void>;
31
12
  identify(): void;
32
13
  }