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.
- package/README.md +343 -562
- package/config.schema.json +23 -1
- package/dist/accessoryInformation.js +28 -13
- package/dist/accessoryInformation.js.map +1 -1
- package/dist/config.d.ts +8 -3
- package/dist/config.js +37 -42
- package/dist/config.js.map +1 -1
- package/dist/devices/create.js +15 -9
- package/dist/devices/create.js.map +1 -1
- package/dist/devices/deviceManager.d.ts +5 -3
- package/dist/devices/deviceManager.js +32 -66
- package/dist/devices/deviceManager.js.map +1 -1
- package/dist/devices/homekitLightBulb.d.ts +11 -1
- package/dist/devices/homekitLightBulb.js +221 -116
- package/dist/devices/homekitLightBulb.js.map +1 -1
- package/dist/devices/homekitPlug.d.ts +10 -0
- package/dist/devices/homekitPlug.js +184 -80
- package/dist/devices/homekitPlug.js.map +1 -1
- package/dist/devices/homekitPowerStrip.d.ts +10 -0
- package/dist/devices/homekitPowerStrip.js +199 -91
- package/dist/devices/homekitPowerStrip.js.map +1 -1
- package/dist/devices/homekitSwitch.d.ts +11 -1
- package/dist/devices/homekitSwitch.js +190 -89
- package/dist/devices/homekitSwitch.js.map +1 -1
- package/dist/devices/homekitSwitchWithChildren.d.ts +34 -0
- package/dist/devices/homekitSwitchWithChildren.js +365 -0
- package/dist/devices/homekitSwitchWithChildren.js.map +1 -0
- package/dist/devices/index.d.ts +5 -6
- package/dist/devices/index.js +18 -17
- package/dist/devices/index.js.map +1 -1
- package/dist/devices/kasaDevices.d.ts +4 -11
- package/dist/devices/kasaDevices.js +83 -95
- package/dist/devices/kasaDevices.js.map +1 -1
- package/dist/platform.d.ts +8 -2
- package/dist/platform.js +111 -46
- package/dist/platform.js.map +1 -1
- package/dist/python/kasaApi.py +349 -171
- package/dist/python/pythonChecker.d.ts +6 -4
- package/dist/python/pythonChecker.js +53 -20
- package/dist/python/pythonChecker.js.map +1 -1
- package/dist/python/startKasaApi.py +25 -0
- package/dist/taskQueue.d.ts +11 -0
- package/dist/taskQueue.js +44 -0
- package/dist/taskQueue.js.map +1 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +8 -4
- package/dist/utils.js.map +1 -1
- package/package.json +15 -23
- package/requirements.txt +3 -3
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import HomeKitDevice from './index.js';
|
|
3
|
+
import { deferAndCombine } from '../utils.js';
|
|
4
|
+
export default class HomeKitDeviceSwitchWithChildren extends HomeKitDevice {
|
|
5
|
+
kasaDevice;
|
|
6
|
+
isUpdating = false;
|
|
7
|
+
previousKasaDevice;
|
|
8
|
+
getSysInfo;
|
|
9
|
+
pollingInterval;
|
|
10
|
+
updateEmitter = new EventEmitter();
|
|
11
|
+
static locks = new Map();
|
|
12
|
+
constructor(platform, kasaDevice) {
|
|
13
|
+
super(platform, kasaDevice, 8 /* Categories.SWITCH */, 'SWITCH');
|
|
14
|
+
this.kasaDevice = kasaDevice;
|
|
15
|
+
this.log.debug(`Initializing HomeKitDeviceSwitchWithChildren for device: ${kasaDevice.sys_info.alias}`);
|
|
16
|
+
this.kasaDevice.sys_info.children?.forEach((child, index) => {
|
|
17
|
+
this.checkService(child, index);
|
|
18
|
+
});
|
|
19
|
+
this.getSysInfo = deferAndCombine(async () => {
|
|
20
|
+
if (this.deviceManager) {
|
|
21
|
+
this.previousKasaDevice = JSON.parse(JSON.stringify(this.kasaDevice));
|
|
22
|
+
this.kasaDevice.sys_info = await this.deviceManager.getSysInfo(this.kasaDevice.sys_info.host);
|
|
23
|
+
this.log.debug(`Updated sys_info for device: ${this.kasaDevice.sys_info.alias}`);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
this.log.warn('Device manager is not available');
|
|
27
|
+
}
|
|
28
|
+
}, platform.config.advancedOptions.waitTimeUpdate);
|
|
29
|
+
this.startPolling();
|
|
30
|
+
platform.periodicDeviceDiscoveryEmitter.on('periodicDeviceDiscoveryComplete', () => {
|
|
31
|
+
this.updateEmitter.emit('periodicDeviceDiscoveryComplete');
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async withLock(key, action) {
|
|
35
|
+
let lock = HomeKitDeviceSwitchWithChildren.locks.get(key);
|
|
36
|
+
if (!lock) {
|
|
37
|
+
lock = Promise.resolve();
|
|
38
|
+
}
|
|
39
|
+
const currentLock = lock.then(async () => {
|
|
40
|
+
try {
|
|
41
|
+
return await action();
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
if (HomeKitDeviceSwitchWithChildren.locks.get(key) === currentLock) {
|
|
45
|
+
HomeKitDeviceSwitchWithChildren.locks.delete(key);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
HomeKitDeviceSwitchWithChildren.locks.set(key, currentLock.then(() => { }));
|
|
50
|
+
return currentLock;
|
|
51
|
+
}
|
|
52
|
+
checkService(child, index) {
|
|
53
|
+
const serviceType = this.getServiceType(child);
|
|
54
|
+
const service = this.homebridgeAccessory.getServiceById(serviceType, `child-${index + 1}`) ??
|
|
55
|
+
this.addService(serviceType, child.alias, `child-${index + 1}`);
|
|
56
|
+
this.checkCharacteristics(service, child);
|
|
57
|
+
}
|
|
58
|
+
getServiceType(child) {
|
|
59
|
+
const { Lightbulb, Fanv2 } = this.platform.Service;
|
|
60
|
+
return child.fan_speed_level !== undefined ? Fanv2 : Lightbulb;
|
|
61
|
+
}
|
|
62
|
+
checkCharacteristics(service, child) {
|
|
63
|
+
const characteristics = this.getCharacteristics(child);
|
|
64
|
+
characteristics.forEach(({ type, name }) => {
|
|
65
|
+
this.getOrAddCharacteristic(service, type, name, child);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
getCharacteristics(child) {
|
|
69
|
+
const characteristics = [];
|
|
70
|
+
if (child.fan_speed_level !== undefined) {
|
|
71
|
+
characteristics.push({
|
|
72
|
+
type: this.platform.Characteristic.RotationSpeed,
|
|
73
|
+
name: this.platform.getCharacteristicName(this.platform.Characteristic.RotationSpeed),
|
|
74
|
+
}, {
|
|
75
|
+
type: this.platform.Characteristic.Active,
|
|
76
|
+
name: this.platform.getCharacteristicName(this.platform.Characteristic.Active),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (child.brightness !== undefined) {
|
|
80
|
+
characteristics.push({
|
|
81
|
+
type: this.platform.Characteristic.On,
|
|
82
|
+
name: this.platform.getCharacteristicName(this.platform.Characteristic.On),
|
|
83
|
+
}, {
|
|
84
|
+
type: this.platform.Characteristic.Brightness,
|
|
85
|
+
name: this.platform.getCharacteristicName(this.platform.Characteristic.Brightness),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
return characteristics;
|
|
89
|
+
}
|
|
90
|
+
getOrAddCharacteristic(service, characteristicType, characteristicName, child) {
|
|
91
|
+
const characteristic = service.getCharacteristic(characteristicType) ??
|
|
92
|
+
service.addCharacteristic(characteristicType);
|
|
93
|
+
characteristic.onGet(this.handleOnGet.bind(this, service, characteristicType, characteristicName, child));
|
|
94
|
+
characteristic.onSet(this.handleOnSet.bind(this, service, characteristicType, characteristicName, child));
|
|
95
|
+
}
|
|
96
|
+
async handleOnGet(service, characteristicType, characteristicName, child) {
|
|
97
|
+
if (this.kasaDevice.offline || this.platform.isShuttingDown) {
|
|
98
|
+
this.log.warn(`Device is offline or platform is shutting down, cannot get value for characteristic ${characteristicName}`);
|
|
99
|
+
return this.getDefaultValue(characteristicType);
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
let characteristicValue = service.getCharacteristic(characteristicType).value;
|
|
103
|
+
if (!characteristicValue) {
|
|
104
|
+
characteristicValue = this.getInitialValue(characteristicType, child);
|
|
105
|
+
service.getCharacteristic(characteristicType).updateValue(characteristicValue);
|
|
106
|
+
}
|
|
107
|
+
this.log.debug(`Got value for characteristic ${characteristicName}: ${characteristicValue}`);
|
|
108
|
+
return characteristicValue ?? this.getDefaultValue(characteristicType);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
this.log.error(`Error getting current value for characteristic ${characteristicName} for device: ${child.alias}:`, error);
|
|
112
|
+
this.kasaDevice.offline = true;
|
|
113
|
+
this.stopPolling();
|
|
114
|
+
return this.getDefaultValue(characteristicType);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
getDefaultValue(characteristicType) {
|
|
118
|
+
const zeroValueCharacteristics = [
|
|
119
|
+
this.platform.Characteristic.Brightness,
|
|
120
|
+
this.platform.Characteristic.RotationSpeed,
|
|
121
|
+
];
|
|
122
|
+
if (zeroValueCharacteristics.includes(characteristicType)) {
|
|
123
|
+
return 0;
|
|
124
|
+
}
|
|
125
|
+
else if (characteristicType === this.platform.Characteristic.Active) {
|
|
126
|
+
return this.platform.Characteristic.Active.INACTIVE;
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
getInitialValue(characteristicType, child) {
|
|
131
|
+
if (characteristicType === this.platform.Characteristic.Active) {
|
|
132
|
+
return child.state ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE;
|
|
133
|
+
}
|
|
134
|
+
else if (characteristicType === this.platform.Characteristic.Brightness) {
|
|
135
|
+
return child.brightness ?? 0;
|
|
136
|
+
}
|
|
137
|
+
else if (characteristicType === this.platform.Characteristic.RotationSpeed) {
|
|
138
|
+
return this.mapRotationSpeedToValue(child.fan_speed_level) ?? 0;
|
|
139
|
+
}
|
|
140
|
+
else if (characteristicType === this.platform.Characteristic.On) {
|
|
141
|
+
return child.state ?? false;
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
mapRotationSpeedToValue(value) {
|
|
146
|
+
return value * 25;
|
|
147
|
+
}
|
|
148
|
+
async handleOnSet(service, characteristicType, characteristicName, child, value) {
|
|
149
|
+
const lockKey = `${this.kasaDevice.sys_info.device_id}:${child.id}`;
|
|
150
|
+
await this.withLock(lockKey, async () => {
|
|
151
|
+
if (this.kasaDevice.offline || this.platform.isShuttingDown) {
|
|
152
|
+
this.log.warn(`Device is offline or platform is shutting down, cannot set value for characteristic ${characteristicName}`);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (this.isUpdating || this.platform.periodicDeviceDiscovering) {
|
|
156
|
+
await Promise.race([
|
|
157
|
+
new Promise((resolve) => this.updateEmitter.once('updateComplete', resolve)),
|
|
158
|
+
new Promise((resolve) => this.updateEmitter.once('periodicDeviceDiscoveryComplete', resolve)),
|
|
159
|
+
]);
|
|
160
|
+
}
|
|
161
|
+
const task = async () => {
|
|
162
|
+
if (this.deviceManager) {
|
|
163
|
+
try {
|
|
164
|
+
this.isUpdating = true;
|
|
165
|
+
this.log.debug(`Setting value for characteristic ${characteristicName} to ${value}`);
|
|
166
|
+
const characteristicKey = this.getCharacteristicKey(characteristicName);
|
|
167
|
+
if (!characteristicKey) {
|
|
168
|
+
throw new Error(`Characteristic key not found for ${characteristicName}`);
|
|
169
|
+
}
|
|
170
|
+
const childNumber = parseInt(child.id.slice(-1), 10);
|
|
171
|
+
const controlValue = this.getControlValue(characteristicName, value);
|
|
172
|
+
await this.deviceManager.controlDevice(this.kasaDevice.sys_info.host, characteristicKey, controlValue, childNumber);
|
|
173
|
+
child[characteristicKey] = controlValue;
|
|
174
|
+
const childIndex = this.kasaDevice.sys_info.children?.findIndex(c => c.id === child.id);
|
|
175
|
+
if (childIndex !== undefined && childIndex !== -1) {
|
|
176
|
+
this.kasaDevice.sys_info.children[childIndex] = { ...child };
|
|
177
|
+
}
|
|
178
|
+
this.updateValue(service, service.getCharacteristic(characteristicType), child.alias, value);
|
|
179
|
+
this.previousKasaDevice = JSON.parse(JSON.stringify(this.kasaDevice));
|
|
180
|
+
this.log.debug(`Set value for characteristic ${characteristicName} to ${value} successfully`);
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
this.log.error(`Error setting current value for characteristic ${characteristicName} for device: ${child.alias}:`, error);
|
|
184
|
+
this.kasaDevice.offline = true;
|
|
185
|
+
this.stopPolling();
|
|
186
|
+
}
|
|
187
|
+
finally {
|
|
188
|
+
this.isUpdating = false;
|
|
189
|
+
this.updateEmitter.emit('updateComplete');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
throw new Error('Device manager is undefined.');
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
await task();
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
getCharacteristicKey(characteristicName) {
|
|
200
|
+
const characteristicMap = {
|
|
201
|
+
Active: 'state',
|
|
202
|
+
Brightness: 'brightness',
|
|
203
|
+
RotationSpeed: 'fan_speed_level',
|
|
204
|
+
On: 'state',
|
|
205
|
+
};
|
|
206
|
+
return characteristicMap[characteristicName ?? ''];
|
|
207
|
+
}
|
|
208
|
+
getControlValue(characteristicName, value) {
|
|
209
|
+
if (characteristicName === 'Active') {
|
|
210
|
+
return value === 1 ? true : false;
|
|
211
|
+
}
|
|
212
|
+
else if (characteristicName === 'RotationSpeed') {
|
|
213
|
+
return this.mapRotationSpeedToValue(value);
|
|
214
|
+
}
|
|
215
|
+
return value;
|
|
216
|
+
}
|
|
217
|
+
async updateState() {
|
|
218
|
+
const lockKey = `${this.kasaDevice.sys_info.device_id}`;
|
|
219
|
+
await this.withLock(lockKey, async () => {
|
|
220
|
+
if (this.kasaDevice.offline || this.platform.isShuttingDown) {
|
|
221
|
+
this.stopPolling();
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (this.isUpdating || this.platform.periodicDeviceDiscovering) {
|
|
225
|
+
let periodicDiscoveryComplete = false;
|
|
226
|
+
await Promise.race([
|
|
227
|
+
new Promise((resolve) => this.updateEmitter.once('updateComplete', resolve)),
|
|
228
|
+
new Promise((resolve) => {
|
|
229
|
+
this.updateEmitter.once('periodicDeviceDiscoveryComplete', () => {
|
|
230
|
+
periodicDiscoveryComplete = true;
|
|
231
|
+
resolve();
|
|
232
|
+
});
|
|
233
|
+
}),
|
|
234
|
+
]);
|
|
235
|
+
if (periodicDiscoveryComplete) {
|
|
236
|
+
if (this.pollingInterval) {
|
|
237
|
+
await new Promise((resolve) => setTimeout(resolve, this.platform.config.discoveryOptions.pollingInterval));
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
this.isUpdating = true;
|
|
245
|
+
const task = async () => {
|
|
246
|
+
try {
|
|
247
|
+
await this.getSysInfo();
|
|
248
|
+
this.kasaDevice.sys_info.children?.forEach((child) => {
|
|
249
|
+
const childNumber = parseInt(child.id.slice(-1), 10);
|
|
250
|
+
const service = this.getService(child, childNumber);
|
|
251
|
+
if (service && this.previousKasaDevice) {
|
|
252
|
+
this.updateChildState(service, child);
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
this.log.warn(`Service not found for child device: ${child.alias} or previous Kasa device is undefined`);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
this.log.error('Error updating device state:', error);
|
|
261
|
+
this.kasaDevice.offline = true;
|
|
262
|
+
this.stopPolling();
|
|
263
|
+
}
|
|
264
|
+
finally {
|
|
265
|
+
this.isUpdating = false;
|
|
266
|
+
this.updateEmitter.emit('updateComplete');
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
await task();
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
getService(child, childNumber) {
|
|
273
|
+
if (child.brightness !== undefined) {
|
|
274
|
+
return this.homebridgeAccessory.getServiceById(this.platform.Service.Lightbulb, `child-${childNumber + 1}`);
|
|
275
|
+
}
|
|
276
|
+
else if (child.fan_speed_level !== undefined) {
|
|
277
|
+
return this.homebridgeAccessory.getServiceById(this.platform.Service.Fanv2, `child-${childNumber + 1}`);
|
|
278
|
+
}
|
|
279
|
+
return undefined;
|
|
280
|
+
}
|
|
281
|
+
updateChildState(service, child) {
|
|
282
|
+
const previousChild = this.previousKasaDevice?.sys_info.children?.find(c => c.id === child.id);
|
|
283
|
+
if (previousChild) {
|
|
284
|
+
if (previousChild.state !== child.state) {
|
|
285
|
+
if (service.UUID === this.platform.Service.Lightbulb.UUID) {
|
|
286
|
+
this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.On), child.alias, child.state);
|
|
287
|
+
this.log.debug(`Updated state for child device: ${child.alias} to ${child.state}`);
|
|
288
|
+
}
|
|
289
|
+
else if (service.UUID === this.platform.Service.Fanv2.UUID) {
|
|
290
|
+
this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.Active), child.alias, child.state ? this.platform.Characteristic.Active.ACTIVE : this.platform.Characteristic.Active.INACTIVE);
|
|
291
|
+
this.log.debug(`Updated active state for child device: ${child.alias} to ${child.state ? 'ACTIVE' : 'INACTIVE'}`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
if (child.brightness !== undefined && previousChild.brightness !== child.brightness) {
|
|
295
|
+
this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.Brightness), child.alias, child.brightness);
|
|
296
|
+
this.log.debug(`Updated brightness for child device: ${child.alias} to ${child.brightness}`);
|
|
297
|
+
}
|
|
298
|
+
if (child.fan_speed_level !== undefined && previousChild.fan_speed_level !== child.fan_speed_level) {
|
|
299
|
+
const updateValue = this.mapRotationSpeedToValue(child.fan_speed_level);
|
|
300
|
+
this.updateValue(service, service.getCharacteristic(this.platform.Characteristic.RotationSpeed), child.alias, updateValue);
|
|
301
|
+
this.log.debug(`Updated fan speed for child device: ${child.alias} to ${updateValue}`);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
updateAfterPeriodicDiscovery() {
|
|
306
|
+
this.kasaDevice.sys_info.children?.forEach((child, index) => {
|
|
307
|
+
const serviceType = this.getServiceType(child);
|
|
308
|
+
const service = this.homebridgeAccessory.getServiceById(serviceType, `child-${index + 1}`);
|
|
309
|
+
if (service) {
|
|
310
|
+
this.updateCharacteristics(service, child);
|
|
311
|
+
}
|
|
312
|
+
else {
|
|
313
|
+
this.log.debug(`Service not found for child device: ${child.alias}`);
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
updateCharacteristics(service, child) {
|
|
318
|
+
const characteristics = this.getCharacteristics(child);
|
|
319
|
+
characteristics.forEach(({ type, name }) => {
|
|
320
|
+
const characteristic = service.getCharacteristic(type);
|
|
321
|
+
if (characteristic) {
|
|
322
|
+
const characteristicKey = this.getCharacteristicKey(name);
|
|
323
|
+
if (child[characteristicKey] !== undefined) {
|
|
324
|
+
const value = child[characteristicKey];
|
|
325
|
+
const controlValue = this.getControlValue(name, value);
|
|
326
|
+
this.log.debug(`Setting value for characteristic ${name} to ${controlValue}`);
|
|
327
|
+
this.updateValue(service, characteristic, child.alias, controlValue);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
startPolling() {
|
|
333
|
+
if (this.kasaDevice.offline || this.platform.isShuttingDown) {
|
|
334
|
+
this.stopPolling();
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if (this.pollingInterval) {
|
|
338
|
+
clearInterval(this.pollingInterval);
|
|
339
|
+
}
|
|
340
|
+
this.log.debug('Starting polling for device:', this.name);
|
|
341
|
+
this.pollingInterval = setInterval(async () => {
|
|
342
|
+
if (this.kasaDevice.offline || this.platform.isShuttingDown) {
|
|
343
|
+
if (this.isUpdating) {
|
|
344
|
+
this.isUpdating = false;
|
|
345
|
+
this.updateEmitter.emit('updateComplete');
|
|
346
|
+
}
|
|
347
|
+
this.stopPolling();
|
|
348
|
+
}
|
|
349
|
+
else {
|
|
350
|
+
await this.updateState();
|
|
351
|
+
}
|
|
352
|
+
}, this.platform.config.discoveryOptions.pollingInterval);
|
|
353
|
+
}
|
|
354
|
+
stopPolling() {
|
|
355
|
+
if (this.pollingInterval) {
|
|
356
|
+
clearInterval(this.pollingInterval);
|
|
357
|
+
this.pollingInterval = undefined;
|
|
358
|
+
this.log.debug('Stopped polling');
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
identify() {
|
|
362
|
+
this.log.info('identify');
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
//# sourceMappingURL=homekitSwitchWithChildren.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"homekitSwitchWithChildren.js","sourceRoot":"","sources":["../../src/devices/homekitSwitchWithChildren.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,+BAAgC,SAAQ,aAAa;IAU/D;IATF,UAAU,GAAY,KAAK,CAAC;IAC3B,kBAAkB,CAAyB;IAC3C,UAAU,CAAsB;IAChC,eAAe,CAA6B;IAC5C,aAAa,GAAiB,IAAI,YAAY,EAAE,CAAC;IACjD,MAAM,CAAC,KAAK,GAA+B,IAAI,GAAG,EAAE,CAAC;IAE7D,YACE,QAA4B,EACrB,UAAkB;QAEzB,KAAK,CACH,QAAQ,EACR,UAAU,6BAEV,QAAQ,CACT,CAAC;QAPK,eAAU,GAAV,UAAU,CAAQ;QAQzB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,4DAA4D,UAAU,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;QACxG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,KAAkB,EAAE,KAAa,EAAE,EAAE;YAC/E,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC,KAAK,IAAI,EAAE;YAC3C,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;gBACvB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C,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"}
|
package/dist/devices/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Categories, Characteristic, CharacteristicValue, HapStatusError, Logger, Nullable, PlatformAccessory, Service } from 'homebridge';
|
|
1
|
+
import { Categories, Characteristic, CharacteristicValue, HapStatusError, Logger, Nullable, PlatformAccessory, Service, WithUUID } from 'homebridge';
|
|
2
2
|
import DeviceManager from './deviceManager.js';
|
|
3
3
|
import type KasaPythonPlatform from '../platform.js';
|
|
4
|
-
import type {
|
|
4
|
+
import type { KasaDevice } from './kasaDevices.js';
|
|
5
5
|
import type { KasaPythonAccessoryContext } from '../platform.js';
|
|
6
6
|
export default abstract class HomeKitDevice {
|
|
7
7
|
readonly platform: KasaPythonPlatform;
|
|
@@ -9,14 +9,13 @@ export default abstract class HomeKitDevice {
|
|
|
9
9
|
readonly category: Categories;
|
|
10
10
|
readonly categoryName: string;
|
|
11
11
|
readonly log: Logger;
|
|
12
|
-
readonly deviceConfig: DeviceConfig;
|
|
13
12
|
protected deviceManager: DeviceManager | undefined;
|
|
14
13
|
homebridgeAccessory: PlatformAccessory<KasaPythonAccessoryContext>;
|
|
15
14
|
isUpdating: boolean;
|
|
16
15
|
constructor(platform: KasaPythonPlatform, kasaDevice: KasaDevice, category: Categories, categoryName: string);
|
|
17
16
|
private initializeAccessory;
|
|
18
17
|
private updateAccessory;
|
|
19
|
-
private
|
|
18
|
+
private correctAccessoryProperties;
|
|
20
19
|
get id(): string;
|
|
21
20
|
get name(): string;
|
|
22
21
|
get manufacturer(): string;
|
|
@@ -24,8 +23,8 @@ export default abstract class HomeKitDevice {
|
|
|
24
23
|
get serialNumber(): string;
|
|
25
24
|
get firmwareRevision(): string;
|
|
26
25
|
abstract identify(): void;
|
|
26
|
+
abstract updateAfterPeriodicDiscovery(): void;
|
|
27
27
|
abstract startPolling(): void;
|
|
28
|
-
addService(serviceConstructor: typeof this.platform.Service
|
|
28
|
+
addService(serviceConstructor: WithUUID<typeof this.platform.Service>, name: string, subType?: string): Service;
|
|
29
29
|
updateValue(service: Service, characteristic: Characteristic, deviceAlias: string, value: Nullable<CharacteristicValue> | Error | HapStatusError): void;
|
|
30
|
-
logRejection(reason: unknown): void;
|
|
31
30
|
}
|
package/dist/devices/index.js
CHANGED
|
@@ -6,7 +6,6 @@ export default class HomeKitDevice {
|
|
|
6
6
|
category;
|
|
7
7
|
categoryName;
|
|
8
8
|
log;
|
|
9
|
-
deviceConfig;
|
|
10
9
|
deviceManager;
|
|
11
10
|
homebridgeAccessory;
|
|
12
11
|
isUpdating = false;
|
|
@@ -15,7 +14,6 @@ export default class HomeKitDevice {
|
|
|
15
14
|
this.kasaDevice = kasaDevice;
|
|
16
15
|
this.category = category;
|
|
17
16
|
this.categoryName = categoryName;
|
|
18
|
-
this.deviceConfig = kasaDevice.device_config;
|
|
19
17
|
this.deviceManager = platform.deviceManager;
|
|
20
18
|
this.log = prefixLogger(platform.log, `[${this.name}]`);
|
|
21
19
|
this.homebridgeAccessory = this.initializeAccessory();
|
|
@@ -46,18 +44,24 @@ export default class HomeKitDevice {
|
|
|
46
44
|
return platformAccessory;
|
|
47
45
|
}
|
|
48
46
|
updateAccessory(platformAccessory) {
|
|
49
|
-
this.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
this.correctAccessoryProperties(platformAccessory, {
|
|
48
|
+
displayName: this.name,
|
|
49
|
+
category: this.category,
|
|
50
|
+
context: {
|
|
51
|
+
deviceId: this.id,
|
|
52
|
+
lastSeen: this.kasaDevice.last_seen,
|
|
53
|
+
offline: this.kasaDevice.offline,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
54
56
|
this.platform.configuredAccessories.set(platformAccessory.UUID, platformAccessory);
|
|
55
57
|
this.platform.api.updatePlatformAccessories([platformAccessory]);
|
|
56
58
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
correctAccessoryProperties(obj, properties) {
|
|
60
|
+
for (const [key, expectedValue] of Object.entries(properties)) {
|
|
61
|
+
if (obj[key] !== expectedValue) {
|
|
62
|
+
this.log.debug(`Correcting Platform Accessory ${key} from: ${String(obj[key])} to: ${String(expectedValue)}`);
|
|
63
|
+
obj[key] = expectedValue;
|
|
64
|
+
}
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
67
|
get id() {
|
|
@@ -70,25 +74,22 @@ export default class HomeKitDevice {
|
|
|
70
74
|
return 'TP-Link';
|
|
71
75
|
}
|
|
72
76
|
get model() {
|
|
73
|
-
return `${this.kasaDevice.
|
|
77
|
+
return `${this.kasaDevice.sys_info.model} ${this.kasaDevice.sys_info.hw_ver}`;
|
|
74
78
|
}
|
|
75
79
|
get serialNumber() {
|
|
76
80
|
return this.kasaDevice.sys_info.mac;
|
|
77
81
|
}
|
|
78
82
|
get firmwareRevision() {
|
|
79
|
-
return
|
|
83
|
+
return this.kasaDevice.sys_info.sw_ver;
|
|
80
84
|
}
|
|
81
85
|
addService(serviceConstructor, name, subType) {
|
|
82
86
|
const serviceName = this.platform.getServiceName(serviceConstructor);
|
|
83
87
|
this.log.debug(`Creating new ${serviceName} Service on ${name}${subType ? ` [${subType}]` : ''}`);
|
|
84
|
-
return this.homebridgeAccessory.addService(serviceConstructor, name, subType);
|
|
88
|
+
return this.homebridgeAccessory.addService(serviceConstructor, name, subType ? subType : '');
|
|
85
89
|
}
|
|
86
90
|
updateValue(service, characteristic, deviceAlias, value) {
|
|
87
91
|
this.log.info(`Updating ${this.platform.lsc(service, characteristic)} on ${deviceAlias} to ${value}`);
|
|
88
92
|
characteristic.updateValue(value);
|
|
89
93
|
}
|
|
90
|
-
logRejection(reason) {
|
|
91
|
-
this.log.error(`Rejection: ${JSON.stringify(reason)}`);
|
|
92
|
-
}
|
|
93
94
|
}
|
|
94
95
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/devices/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/devices/index.ts"],"names":[],"mappings":"AAaA,OAAO,oBAAoB,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,MAAM,CAAC,OAAO,OAAgB,aAAa;IAO9B;IACF;IACE;IACA;IATF,GAAG,CAAS;IACX,aAAa,CAA4B;IACnD,mBAAmB,CAAgD;IAC5D,UAAU,GAAY,KAAK,CAAC;IAEnC,YACW,QAA4B,EAC9B,UAAsB,EACpB,QAAoB,EACpB,YAAoB;QAHpB,aAAQ,GAAR,QAAQ,CAAoB;QAC9B,eAAU,GAAV,UAAU,CAAY;QACpB,aAAQ,GAAR,QAAQ,CAAY;QACpB,iBAAY,GAAZ,YAAY,CAAQ;QAE7B,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC;QAC5C,IAAI,CAAC,GAAG,GAAG,YAAY,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACxD,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACtD,IAAI,CAAC,mBAAmB,CAAC,EAAE,mDAAkC,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtF,CAAC;IAEO,mBAAmB;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,QAA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
9
9
|
device_type: string;
|
|
10
|
+
fan_speed_level?: number;
|
|
10
11
|
host: string;
|
|
11
12
|
hw_ver: string;
|
|
12
13
|
hsv?: HSV;
|
|
13
14
|
mac: string;
|
|
15
|
+
model: string;
|
|
14
16
|
state?: boolean;
|
|
15
17
|
sw_ver: string;
|
|
16
18
|
[key: string]: string | number | boolean | ChildDevice[] | HSV | undefined;
|
|
17
19
|
}
|
|
18
|
-
export interface DiscoveryInfo {
|
|
19
|
-
model: string;
|
|
20
|
-
}
|
|
21
20
|
export interface FeatureInfo {
|
|
22
21
|
brightness?: boolean;
|
|
23
22
|
color_temp?: boolean;
|
|
24
23
|
hsv?: boolean;
|
|
24
|
+
fan?: boolean;
|
|
25
25
|
}
|
|
26
26
|
export interface ChildDevice {
|
|
27
27
|
alias: string;
|
|
28
28
|
brightness?: number;
|
|
29
29
|
color_temp?: number;
|
|
30
|
+
fan_speed_level?: number;
|
|
30
31
|
hsv?: HSV;
|
|
31
32
|
id: string;
|
|
32
33
|
state: boolean;
|
|
@@ -56,33 +57,25 @@ export interface ConfigDevice {
|
|
|
56
57
|
}
|
|
57
58
|
export interface LightBulb {
|
|
58
59
|
sys_info: SysInfo;
|
|
59
|
-
disc_info: DiscoveryInfo;
|
|
60
60
|
feature_info: FeatureInfo;
|
|
61
|
-
device_config: DeviceConfig;
|
|
62
61
|
last_seen: Date;
|
|
63
62
|
offline: boolean;
|
|
64
63
|
}
|
|
65
64
|
export interface Plug {
|
|
66
65
|
sys_info: SysInfo;
|
|
67
|
-
disc_info: DiscoveryInfo;
|
|
68
66
|
feature_info: FeatureInfo;
|
|
69
|
-
device_config: DeviceConfig;
|
|
70
67
|
last_seen: Date;
|
|
71
68
|
offline: boolean;
|
|
72
69
|
}
|
|
73
70
|
export interface PowerStrip {
|
|
74
71
|
sys_info: SysInfo;
|
|
75
|
-
disc_info: DiscoveryInfo;
|
|
76
72
|
feature_info: FeatureInfo;
|
|
77
|
-
device_config: DeviceConfig;
|
|
78
73
|
last_seen: Date;
|
|
79
74
|
offline: boolean;
|
|
80
75
|
}
|
|
81
76
|
export interface Switch {
|
|
82
77
|
sys_info: SysInfo;
|
|
83
|
-
disc_info: DiscoveryInfo;
|
|
84
78
|
feature_info: FeatureInfo;
|
|
85
|
-
device_config: DeviceConfig;
|
|
86
79
|
last_seen: Date;
|
|
87
80
|
offline: boolean;
|
|
88
81
|
}
|