homebridge-kasa-python 1.0.2 → 2.0.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 +21 -6
- package/config.schema.json +2 -33
- package/dist/accessoryInformation.d.ts +1 -1
- package/dist/accessoryInformation.js +14 -18
- package/dist/accessoryInformation.js.map +1 -1
- package/dist/categoriesParse.d.ts +8 -0
- package/dist/categoriesParse.js +44 -0
- package/dist/categoriesParse.js.map +1 -0
- package/dist/config.d.ts +12 -155
- package/dist/config.js +52 -100
- package/dist/config.js.map +1 -1
- package/dist/devices/create.d.ts +3 -9
- package/dist/devices/create.js +6 -7
- package/dist/devices/create.js.map +1 -1
- package/dist/devices/deviceManager.d.ts +6 -8
- package/dist/devices/deviceManager.js +47 -126
- package/dist/devices/deviceManager.js.map +1 -1
- package/dist/devices/homekitPlug.d.ts +10 -16
- package/dist/devices/homekitPlug.js +93 -74
- package/dist/devices/homekitPlug.js.map +1 -1
- package/dist/devices/homekitPowerstrip.d.ts +11 -17
- package/dist/devices/homekitPowerstrip.js +106 -73
- package/dist/devices/homekitPowerstrip.js.map +1 -1
- package/dist/devices/index.d.ts +12 -19
- package/dist/devices/index.js +44 -71
- package/dist/devices/index.js.map +1 -1
- package/dist/devices/kasaDevices.d.ts +4 -5
- package/dist/platform.d.ts +22 -29
- package/dist/platform.js +127 -131
- package/dist/platform.js.map +1 -1
- package/dist/python/kasaApi.py +109 -0
- package/dist/python/pythonChecker.d.ts +2 -2
- package/dist/python/pythonChecker.js +24 -89
- package/dist/python/pythonChecker.js.map +1 -1
- package/dist/utils.d.ts +3 -18
- package/dist/utils.js +72 -116
- package/dist/utils.js.map +1 -1
- package/package.json +20 -19
- package/requirements.txt +4 -1
- package/dist/python/discover.py +0 -38
- package/dist/python/getSysInfo.py +0 -39
- package/dist/python/turnOff.py +0 -20
- package/dist/python/turnOffChild.py +0 -22
- package/dist/python/turnOn.py +0 -20
- package/dist/python/turnOnChild.py +0 -22
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,GAAoB,MAAM,KAAK,CAAC;AACvC,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,IAAI,WAA6B,CAAC;AAElC,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAGhC;IACA;IAHT,YACE,OAAe,EACR,MAAuE,EACvE,YAAsB;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,WAAM,GAAN,MAAM,CAAiE;QACvE,iBAAY,GAAZ,YAAY,CAAU;QAG7B,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;QACjE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAEO,aAAa,CACnB,OAAe,EACf,MAAuE,EACvE,YAAsB;QAEtB,IAAI,gBAAgB,GAAG,OAAO,CAAC;QAC/B,IAAI,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;gBACtC,MAAM,aAAa,GAAG,eAAe,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,qBAAqB,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC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,IAAI,aAAa,CAAC,QAAQ;QAC9C,UAAU,EAAE,CAAC,CAAC,UAAU,IAAI,aAAa,CAAC,UAAU;QACpD,iBAAiB,EAAE,CAAC,CAAC,iBAAiB,IAAI,aAAa,CAAC,iBAAiB;QACzE,gBAAgB,EAAE,CAAC,CAAC,gBAAgB,IAAI,aAAa,CAAC,gBAAgB;QACtE,cAAc,EAAE,CAAC,CAAC,cAAc,IAAI,aAAa,CAAC,cAAc;QAChE,gBAAgB,EAAE;YAChB,eAAe,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,eAAe,IAAI,aAAa,CAAC,gBAAgB,CAAC,eAAe,CAAC,GAAG,IAAI;YAC9G,iBAAiB,EAAE,CAAC,CAAC,gBAAgB,CAAC,iBAAiB,IAAI,aAAa,CAAC,gBAAgB,CAAC,iBAAiB;YAC3G,mBAAmB,EAAE,CAAC,CAAC,gBAAgB,CAAC,mBAAmB,IAAI,aAAa,CAAC,gBAAgB,CAAC,mBAAmB;YACjH,OAAO,EAAE,CAAC,CAAC,gBAAgB,CAAC,OAAO,IAAI,aAAa,CAAC,gBAAgB,CAAC,OAAO;SAC9E;KACF,CAAC;AACJ,CAAC"}
|
package/dist/devices/create.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import type { PlatformAccessory } from 'homebridge';
|
|
2
|
-
import { KasaPythonConfig } from '../config.js';
|
|
3
|
-
import type KasaPythonPlatform from '../platform.js';
|
|
4
|
-
import type { KasaPythonAccessoryContext } from '../platform.js';
|
|
5
|
-
import type { KasaDevice } from '../utils.js';
|
|
6
1
|
import HomekitDevice from './index.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export default function create(platform: KasaPythonPlatform, config: KasaPythonConfig, homebridgeAccessory: PlatformAccessory<KasaPythonAccessoryContext> | undefined, KasaDevice: KasaDevice): HomekitDevice | undefined;
|
|
2
|
+
import type KasaPythonPlatform from '../platform.js';
|
|
3
|
+
import type { KasaDevice } from './kasaDevices.js';
|
|
4
|
+
export default function create(platform: KasaPythonPlatform, KasaDevice: KasaDevice): HomekitDevice | undefined;
|
package/dist/devices/create.js
CHANGED
|
@@ -6,15 +6,14 @@ function isPlug(device) {
|
|
|
6
6
|
function isPowerStrip(device) {
|
|
7
7
|
return device.sys_info.child_num !== undefined && device.sys_info.child_num > 1 && Array.isArray(device.sys_info.children);
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
* Factory method to create a HomeKitDevicePlug or HomeKitDevicePowerstrip.
|
|
11
|
-
*/
|
|
12
|
-
export default function create(platform, config, homebridgeAccessory, KasaDevice) {
|
|
9
|
+
export default function create(platform, KasaDevice) {
|
|
13
10
|
if (isPowerStrip(KasaDevice)) {
|
|
14
|
-
return new HomeKitDevicePowerStrip(platform,
|
|
11
|
+
return new HomeKitDevicePowerStrip(platform, KasaDevice);
|
|
15
12
|
}
|
|
16
|
-
|
|
17
|
-
return new HomeKitDevicePlug(platform,
|
|
13
|
+
if (isPlug(KasaDevice)) {
|
|
14
|
+
return new HomeKitDevicePlug(platform, KasaDevice);
|
|
18
15
|
}
|
|
16
|
+
platform.log.error('Unknown device type:', KasaDevice);
|
|
17
|
+
return undefined;
|
|
19
18
|
}
|
|
20
19
|
//# sourceMappingURL=create.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/devices/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/devices/create.ts"],"names":[],"mappings":"AACA,OAAO,iBAAiB,MAAM,kBAAkB,CAAC;AACjD,OAAO,uBAAuB,MAAM,wBAAwB,CAAC;AAI7D,SAAS,MAAM,CAAC,MAAkB;IAChC,OAAO,UAAU,IAAI,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC;AAChG,CAAC;AAED,SAAS,YAAY,CAAC,MAAkB;IACtC,OAAO,MAAM,CAAC,QAAQ,CAAC,SAAS,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,GAAG,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC7H,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,MAAM,CAC5B,QAA4B,EAC5B,UAAsB;IAEtB,IAAI,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,uBAAuB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,iBAAiB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACrD,CAAC;IAED,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,sBAAsB,EAAE,UAAU,CAAC,CAAC;IACvD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import KasaPythonPlatform from '../platform.js';
|
|
2
|
-
import { KasaDevice } from '../utils.js';
|
|
3
1
|
import HomekitDevice from './index.js';
|
|
2
|
+
import KasaPythonPlatform from '../platform.js';
|
|
3
|
+
import type { KasaDevice } from './kasaDevices.js';
|
|
4
4
|
export default class DeviceManager {
|
|
5
|
-
private log;
|
|
6
5
|
private platform;
|
|
6
|
+
private log;
|
|
7
|
+
private apiUrl;
|
|
7
8
|
constructor(platform: KasaPythonPlatform);
|
|
8
|
-
private
|
|
9
|
+
private performDeviceAction;
|
|
9
10
|
discoverDevices(): Promise<void>;
|
|
10
11
|
getSysInfo(device: HomekitDevice): Promise<KasaDevice | undefined>;
|
|
11
|
-
|
|
12
|
-
turnOff(device: HomekitDevice): Promise<void>;
|
|
13
|
-
turnOnChild(device: HomekitDevice, child_num: number): Promise<void>;
|
|
14
|
-
turnOffChild(device: HomekitDevice, child_num: number): Promise<void>;
|
|
12
|
+
toggleDevice(device: HomekitDevice, state: boolean, child_num?: number): Promise<void>;
|
|
15
13
|
}
|
|
@@ -1,156 +1,77 @@
|
|
|
1
|
-
import
|
|
2
|
-
import * as util from 'util';
|
|
3
|
-
import { runCommand } from '../utils.js';
|
|
4
|
-
const readFileAsync = util.promisify(fs.readFile);
|
|
1
|
+
import axios from 'axios';
|
|
5
2
|
export default class DeviceManager {
|
|
6
|
-
log;
|
|
7
3
|
platform;
|
|
4
|
+
log;
|
|
5
|
+
apiUrl;
|
|
8
6
|
constructor(platform) {
|
|
9
|
-
this.log = platform.log;
|
|
10
7
|
this.platform = platform;
|
|
8
|
+
this.log = platform.log;
|
|
9
|
+
this.apiUrl = `http://127.0.0.1:${platform.port}`;
|
|
11
10
|
}
|
|
12
|
-
async
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
args.push(childNumber);
|
|
20
|
-
}
|
|
21
|
-
if (outputToFile) {
|
|
22
|
-
const outputFileName = deviceId ? `${deviceId}_${scriptName}_output.json` : `${scriptName}_output.json`;
|
|
23
|
-
args.push(`> ${this.platform.storagePath}/kasa-python/${outputFileName}`);
|
|
24
|
-
}
|
|
25
|
-
return await runCommand(this.log, this.platform.venvPythonExecutable, args);
|
|
26
|
-
}
|
|
27
|
-
async discoverDevices() {
|
|
28
|
-
this.log.info('Discovering devices...');
|
|
11
|
+
async performDeviceAction(device, action, childNumber) {
|
|
12
|
+
const url = `${this.apiUrl}/controlDevice`;
|
|
13
|
+
const data = {
|
|
14
|
+
device_config: device.deviceConfig,
|
|
15
|
+
action,
|
|
16
|
+
...(childNumber !== undefined && { child_num: childNumber }),
|
|
17
|
+
};
|
|
29
18
|
try {
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
this.log.error(`Error executing discovery script: ${stderr}. Output: ${stdout}`);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
if (fs.existsSync(outputPath)) {
|
|
37
|
-
try {
|
|
38
|
-
const data = await readFileAsync(outputPath, 'utf8');
|
|
39
|
-
const devices = JSON.parse(data);
|
|
40
|
-
let index = 0;
|
|
41
|
-
Object.keys(devices).forEach(ip => {
|
|
42
|
-
const device = devices[ip].device_info;
|
|
43
|
-
device.device_config = devices[ip].device_config;
|
|
44
|
-
this.platform.foundDevice(device);
|
|
45
|
-
index += 1;
|
|
46
|
-
});
|
|
47
|
-
this.log.info('Discovered %d devices.', index);
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
this.log.error(`An error occurred during device discovery: ${error}`);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
this.log.error(`Discovery script did not output to ${outputPath}`);
|
|
19
|
+
const response = await axios.post(url, data);
|
|
20
|
+
if (response.data.status !== 'success') {
|
|
21
|
+
this.log.error(`Error performing action: ${response.data.message}`);
|
|
55
22
|
}
|
|
56
23
|
}
|
|
57
24
|
catch (error) {
|
|
58
|
-
this.log.error(`
|
|
25
|
+
this.log.error(`Error performing action: ${axios.isAxiosError(error) ? error.message : 'An unknown error occurred'}`);
|
|
59
26
|
}
|
|
60
27
|
}
|
|
61
|
-
async
|
|
62
|
-
this.log.
|
|
28
|
+
async discoverDevices() {
|
|
29
|
+
this.log.debug('Discovering devices...');
|
|
63
30
|
try {
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
if (fs.existsSync(outputPath)) {
|
|
72
|
-
try {
|
|
73
|
-
const data = await readFileAsync(outputPath, 'utf8');
|
|
74
|
-
const device_info = JSON.parse(data);
|
|
75
|
-
const new_device = device_info.device_info;
|
|
76
|
-
return new_device;
|
|
31
|
+
const response = await axios.get(`${this.apiUrl}/discover`);
|
|
32
|
+
const devices = response.data;
|
|
33
|
+
Object.keys(devices).forEach(ip => {
|
|
34
|
+
const device = devices[ip].device_info;
|
|
35
|
+
if (device.alias.includes('TP-LINK_Power Strip_')) {
|
|
36
|
+
device.alias = `Power Strip ${device.alias.slice(-4)}`;
|
|
77
37
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
this.log.error(`GetSysInfo script did not output to ${outputPath}`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
this.log.error(`An error occurred during device getSysInfo: ${error}`);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
async turnOn(device) {
|
|
91
|
-
this.log.info('Turning on device: %s', device.name);
|
|
92
|
-
try {
|
|
93
|
-
const deviceConfigJson = JSON.stringify(device.deviceConfig);
|
|
94
|
-
const [stdout, stderr, exitCode] = await this.executePythonScript('turnOn', undefined, deviceConfigJson);
|
|
95
|
-
if (exitCode !== 0) {
|
|
96
|
-
this.log.error(`Error executing turnOn script: ${stderr}`);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const state = JSON.parse(stdout);
|
|
100
|
-
this.log.debug('Device %s turnOn is %s', device.name, state);
|
|
38
|
+
device.device_config = devices[ip].device_config;
|
|
39
|
+
this.platform.foundDevice(device);
|
|
40
|
+
});
|
|
41
|
+
this.log.debug(`Discovered ${Object.keys(devices).length} devices.`);
|
|
101
42
|
}
|
|
102
43
|
catch (error) {
|
|
103
|
-
this.log.error(
|
|
44
|
+
this.log.error(`An error occurred during device discovery: ${axios.isAxiosError(error) ? error.message : 'An unknown error occurred'}`);
|
|
104
45
|
}
|
|
105
46
|
}
|
|
106
|
-
async
|
|
107
|
-
this.log.
|
|
47
|
+
async getSysInfo(device) {
|
|
48
|
+
this.log.debug(`Getting system info for device: ${device.name}`);
|
|
108
49
|
try {
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
50
|
+
this.log.debug(`Requesting system info with config: ${JSON.stringify(device.deviceConfig)}`);
|
|
51
|
+
const response = await axios.post(`${this.apiUrl}/getSysInfo`, { device_config: device.deviceConfig });
|
|
52
|
+
const kasaDevice = response.data.device_info;
|
|
53
|
+
if (kasaDevice.alias.includes('TP-LINK_Power Strip_')) {
|
|
54
|
+
kasaDevice.alias = `Power Strip ${kasaDevice.alias.slice(-4)}`;
|
|
114
55
|
}
|
|
115
|
-
|
|
116
|
-
this.log.debug('Device %s turnOff is %s', device.name, state);
|
|
56
|
+
return kasaDevice;
|
|
117
57
|
}
|
|
118
58
|
catch (error) {
|
|
119
|
-
this.log.error(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
this.log.info('Turning on device %s: child %s', device.name, child_num);
|
|
124
|
-
try {
|
|
125
|
-
const childNumberJson = JSON.stringify(child_num);
|
|
126
|
-
const deviceConfigJson = JSON.stringify(device.deviceConfig);
|
|
127
|
-
const [stdout, stderr, exitCode] = await this.executePythonScript('turnOnChild', undefined, deviceConfigJson, childNumberJson);
|
|
128
|
-
if (exitCode !== 0) {
|
|
129
|
-
this.log.error(`Error executing turnOnChild script: ${stderr}`);
|
|
130
|
-
return;
|
|
59
|
+
this.log.error(`An error occurred during device getSysInfo: ${axios.isAxiosError(error) ? error.message : 'An unknown error occurred'}`);
|
|
60
|
+
if (axios.isAxiosError(error) && error.response) {
|
|
61
|
+
this.log.error(`Response status: ${error.response.status}`);
|
|
62
|
+
this.log.error(`Response data: ${JSON.stringify(error.response.data)}`);
|
|
131
63
|
}
|
|
132
|
-
const state = JSON.parse(stdout);
|
|
133
|
-
this.log.debug('Device %s Child %s turnOn is %s', device.name, child_num, state);
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
this.log.error('An error occurred turning on device %s child %s: %s', device.name, child_num, error);
|
|
137
64
|
}
|
|
138
65
|
}
|
|
139
|
-
async
|
|
140
|
-
|
|
66
|
+
async toggleDevice(device, state, child_num) {
|
|
67
|
+
const action = state ? 'turn_on' : 'turn_off';
|
|
68
|
+
const childText = child_num !== undefined ? ` child ${child_num}` : '';
|
|
141
69
|
try {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const [stdout, stderr, exitCode] = await this.executePythonScript('turnOffChild', undefined, deviceConfigJson, childNumberJson);
|
|
145
|
-
if (exitCode !== 0) {
|
|
146
|
-
this.log.error(`Error executing turnOffChild script: ${stderr}`);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
const state = JSON.parse(stdout);
|
|
150
|
-
this.log.debug('Device %s Child %s turnOff is %s', device.name, child_num, state);
|
|
70
|
+
await this.performDeviceAction(device, action, child_num);
|
|
71
|
+
this.log.debug(`Turned ${state ? 'on' : 'off'} device: ${device.name}${childText}`);
|
|
151
72
|
}
|
|
152
73
|
catch (error) {
|
|
153
|
-
this.log.error(
|
|
74
|
+
this.log.error(`An error occurred turning ${state ? 'on' : 'off'} device ${device.name}${childText}: ${axios.isAxiosError(error) ? error.message : 'An unknown error occurred'}`);
|
|
154
75
|
}
|
|
155
76
|
}
|
|
156
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceManager.js","sourceRoot":"","sources":["../../src/devices/deviceManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"deviceManager.js","sourceRoot":"","sources":["../../src/devices/deviceManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,MAAM,CAAC,OAAO,OAAO,aAAa;IAIZ;IAHZ,GAAG,CAAS;IACZ,MAAM,CAAS;IAEvB,YAAoB,QAA4B;QAA5B,aAAQ,GAAR,QAAQ,CAAoB;QAC9C,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,oBAAoB,QAAQ,CAAC,IAAI,EAAE,CAAC;IACpD,CAAC;IAEO,KAAK,CAAC,mBAAmB,CAAC,MAAqB,EAAE,MAAc,EAAE,WAAoB;QAC3F,MAAM,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,CAAC,CAAC,KAAK,WAAW,MAAM,CAAC,IAAI,GAAG,SAAS,KACjF,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,2BAC9C,EAAE,CACH,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,23 +1,17 @@
|
|
|
1
|
-
import type { PlatformAccessory } from 'homebridge';
|
|
2
1
|
import HomekitDevice from './index.js';
|
|
3
|
-
import { KasaPythonConfig } from '../config.js';
|
|
4
|
-
import DeviceManager from './deviceManager.js';
|
|
5
2
|
import type KasaPythonPlatform from '../platform.js';
|
|
6
|
-
import type {
|
|
7
|
-
import type { DeviceConfig, Plug } from './kasaDevices.js';
|
|
3
|
+
import type { Plug } from './kasaDevices.js';
|
|
8
4
|
export default class HomeKitDevicePlug extends HomekitDevice {
|
|
9
|
-
|
|
10
|
-
readonly kasaDevice: Plug;
|
|
11
|
-
readonly deviceConfig: DeviceConfig;
|
|
12
|
-
constructor(platform: KasaPythonPlatform, config: KasaPythonConfig, homebridgeAccessory: PlatformAccessory<KasaPythonAccessoryContext> | undefined, kasaDevice: Plug, deviceConfig: DeviceConfig, deviceManager?: DeviceManager);
|
|
13
|
-
/**
|
|
14
|
-
* Aggregates getSysInfo requests
|
|
15
|
-
*
|
|
16
|
-
* @private
|
|
17
|
-
*/
|
|
5
|
+
protected kasaDevice: Plug;
|
|
18
6
|
private getSysInfo;
|
|
7
|
+
private previousKasaDevice;
|
|
8
|
+
private isUpdating;
|
|
9
|
+
constructor(platform: KasaPythonPlatform, kasaDevice: Plug);
|
|
19
10
|
private addOutletService;
|
|
20
|
-
private
|
|
21
|
-
private
|
|
11
|
+
private addCharacteristic;
|
|
12
|
+
private handleOnGet;
|
|
13
|
+
private handleOnSet;
|
|
14
|
+
private updateState;
|
|
15
|
+
private startPolling;
|
|
22
16
|
identify(): void;
|
|
23
17
|
}
|
|
@@ -1,98 +1,117 @@
|
|
|
1
1
|
import HomekitDevice from './index.js';
|
|
2
2
|
import { deferAndCombine, getOrAddCharacteristic } from '../utils.js';
|
|
3
3
|
export default class HomeKitDevicePlug extends HomekitDevice {
|
|
4
|
-
config;
|
|
5
4
|
kasaDevice;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
getSysInfo;
|
|
6
|
+
previousKasaDevice;
|
|
7
|
+
isUpdating = false;
|
|
8
|
+
constructor(platform, kasaDevice) {
|
|
9
|
+
super(platform, kasaDevice, 7 /* Categories.OUTLET */);
|
|
10
10
|
this.kasaDevice = kasaDevice;
|
|
11
|
-
this.deviceConfig = deviceConfig;
|
|
12
11
|
this.addOutletService();
|
|
13
12
|
this.getSysInfo = deferAndCombine(async (requestCount) => {
|
|
14
13
|
this.log.debug(`executing deferred getSysInfo count: ${requestCount}`);
|
|
15
|
-
|
|
14
|
+
if (this.deviceManager) {
|
|
15
|
+
const newKasaDevice = await this.deviceManager.getSysInfo(this);
|
|
16
|
+
this.previousKasaDevice = this.kasaDevice;
|
|
17
|
+
this.kasaDevice = newKasaDevice;
|
|
18
|
+
return this.kasaDevice;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
16
21
|
}, platform.config.waitTimeUpdate);
|
|
22
|
+
this.startPolling();
|
|
17
23
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Aggregates getSysInfo requests
|
|
20
|
-
*
|
|
21
|
-
* @private
|
|
22
|
-
*/
|
|
23
|
-
getSysInfo;
|
|
24
24
|
addOutletService() {
|
|
25
25
|
const { Outlet } = this.platform.Service;
|
|
26
|
-
const outletService = this.homebridgeAccessory.getService(Outlet) ??
|
|
27
|
-
|
|
28
|
-
this.
|
|
29
|
-
this.addOutletInUseCharacteristic(outletService);
|
|
26
|
+
const outletService = this.homebridgeAccessory.getService(Outlet) ?? this.addService(Outlet, this.name);
|
|
27
|
+
this.addCharacteristic(outletService, this.platform.Characteristic.On);
|
|
28
|
+
this.addCharacteristic(outletService, this.platform.Characteristic.OutletInUse);
|
|
30
29
|
return outletService;
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
.
|
|
45
|
-
this.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
31
|
+
addCharacteristic(service, characteristicType) {
|
|
32
|
+
const characteristic = getOrAddCharacteristic(service, characteristicType);
|
|
33
|
+
characteristic.onGet(this.handleOnGet.bind(this, characteristicType));
|
|
34
|
+
if (characteristicType === this.platform.Characteristic.On) {
|
|
35
|
+
characteristic.onSet(this.handleOnSet.bind(this));
|
|
36
|
+
}
|
|
37
|
+
return service;
|
|
38
|
+
}
|
|
39
|
+
async handleOnGet(characteristicType) {
|
|
40
|
+
try {
|
|
41
|
+
const stateValue = this.kasaDevice.sys_info.relay_state === 1;
|
|
42
|
+
const characteristicName = this.platform.getCharacteristicName(characteristicType);
|
|
43
|
+
this.log.debug(`Current State of ${characteristicName} is: ${stateValue} for ${this.name}`);
|
|
44
|
+
return this.kasaDevice.sys_info.relay_state ?? 0;
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
this.log.error('Error getting device state:', error);
|
|
48
|
+
}
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
async handleOnSet(value) {
|
|
52
|
+
this.log.info(`Setting On to: ${value} for ${this.name}`);
|
|
53
|
+
if (typeof value === 'boolean') {
|
|
54
|
+
if (this.deviceManager) {
|
|
55
|
+
try {
|
|
56
|
+
this.isUpdating = true;
|
|
57
|
+
await this.deviceManager.toggleDevice(this, value);
|
|
58
|
+
this.kasaDevice.sys_info.relay_state = value ? 1 : 0;
|
|
59
|
+
this.previousKasaDevice = this.kasaDevice;
|
|
60
|
+
const service = this.homebridgeAccessory.getService(this.platform.Service.Outlet);
|
|
61
|
+
if (service) {
|
|
62
|
+
const onCharacteristic = service.getCharacteristic(this.platform.Characteristic.On);
|
|
63
|
+
const outletInUseCharacteristic = service.getCharacteristic(this.platform.Characteristic.OutletInUse);
|
|
64
|
+
this.updateValue(service, onCharacteristic, value);
|
|
65
|
+
this.updateValue(service, outletInUseCharacteristic, value);
|
|
66
|
+
}
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
this.logRejection(error);
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
this.isUpdating = false;
|
|
74
|
+
}
|
|
49
75
|
}
|
|
50
|
-
else
|
|
51
|
-
|
|
52
|
-
return;
|
|
76
|
+
else {
|
|
77
|
+
throw new Error('Device manager is undefined.');
|
|
53
78
|
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
54
81
|
this.log.warn('setValue: Invalid On:', value);
|
|
55
82
|
throw new Error(`setValue: Invalid On: ${value}`);
|
|
56
|
-
}
|
|
57
|
-
let oldState = this.kasaDevice.sys_info.relay_state;
|
|
58
|
-
setInterval(async () => {
|
|
59
|
-
const device = await this.getSysInfo().catch(this.logRejection.bind(this));
|
|
60
|
-
let newState;
|
|
61
|
-
if (device) {
|
|
62
|
-
newState = device.sys_info.relay_state;
|
|
63
|
-
}
|
|
64
|
-
if (newState !== undefined && newState !== oldState) {
|
|
65
|
-
this.updateValue(service, onCharacteristic, newState);
|
|
66
|
-
oldState = newState;
|
|
67
|
-
}
|
|
68
|
-
}, this.config.discoveryOptions.pollingInterval);
|
|
69
|
-
return service;
|
|
83
|
+
}
|
|
70
84
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
this.log.debug(`Current State of On is: ${state === 1 ? true : false} for ${this.name}`);
|
|
79
|
-
return state ?? 0;
|
|
80
|
-
}
|
|
81
|
-
return 0;
|
|
82
|
-
});
|
|
83
|
-
let oldState = this.kasaDevice.sys_info.relay_state;
|
|
84
|
-
setInterval(async () => {
|
|
85
|
-
const device = await this.getSysInfo().catch(this.logRejection.bind(this));
|
|
86
|
-
let newState;
|
|
85
|
+
async updateState() {
|
|
86
|
+
if (this.isUpdating) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
this.isUpdating = true;
|
|
90
|
+
try {
|
|
91
|
+
const device = await this.getSysInfo();
|
|
87
92
|
if (device) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
const service = this.homebridgeAccessory.getService(this.platform.Service.Outlet);
|
|
94
|
+
if (service && this.previousKasaDevice) {
|
|
95
|
+
const previousRelayState = this.previousKasaDevice.sys_info.relay_state;
|
|
96
|
+
if (previousRelayState !== device.sys_info.relay_state) {
|
|
97
|
+
this.kasaDevice.sys_info.relay_state = device.sys_info.relay_state;
|
|
98
|
+
const onCharacteristic = service.getCharacteristic(this.platform.Characteristic.On);
|
|
99
|
+
const outletInUseCharacteristic = service.getCharacteristic(this.platform.Characteristic.OutletInUse);
|
|
100
|
+
this.updateValue(service, onCharacteristic, device.sys_info.relay_state === 1);
|
|
101
|
+
this.updateValue(service, outletInUseCharacteristic, device.sys_info.relay_state === 1);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
93
104
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
this.log.error('Error updating device state:', error);
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
this.isUpdating = false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
startPolling() {
|
|
114
|
+
setInterval(this.updateState.bind(this), this.platform.config.discoveryOptions.pollingInterval);
|
|
96
115
|
}
|
|
97
116
|
identify() {
|
|
98
117
|
this.log.info('identify');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"homekitPlug.js","sourceRoot":"","sources":["../../src/devices/homekitPlug.ts"],"names":[],"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