@switchbot/homebridge-switchbot 2.0.0-beta.17 → 2.0.0-beta.19
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/CHANGELOG.md +1 -1
- package/config.schema.json +14 -4
- package/dist/device/bot.d.ts +2 -0
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +201 -163
- package/dist/device/bot.js.map +1 -1
- package/dist/device/colorbulb.d.ts +2 -0
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +250 -218
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +2 -0
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +85 -66
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +2 -0
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +166 -136
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +126 -115
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/lock.d.ts +2 -0
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +156 -130
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +2 -0
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +85 -64
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +2 -0
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +78 -59
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +2 -0
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +76 -57
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +2 -0
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +133 -107
- package/dist/device/plug.js.map +1 -1
- package/dist/device/striplight.d.ts +2 -0
- package/dist/device/striplight.d.ts.map +1 -1
- package/dist/device/striplight.js +224 -195
- package/dist/device/striplight.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +2 -0
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +127 -105
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +2 -0
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js +83 -66
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +8 -6
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +83 -68
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +7 -5
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +90 -75
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/light.d.ts +8 -6
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +83 -68
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +8 -6
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +93 -78
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +8 -6
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +68 -52
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +8 -6
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +83 -69
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +2 -0
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +75 -60
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/settings.d.ts +12 -11
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/package.json +1 -1
- package/src/device/bot.ts +200 -163
- package/src/device/colorbulb.ts +252 -221
- package/src/device/contact.ts +85 -66
- package/src/device/curtain.ts +165 -136
- package/src/device/humidifier.ts +126 -115
- package/src/device/lock.ts +156 -131
- package/src/device/meter.ts +85 -64
- package/src/device/meterplus.ts +78 -59
- package/src/device/motion.ts +76 -57
- package/src/device/plug.ts +132 -107
- package/src/device/striplight.ts +226 -198
- package/src/irdevice/airconditioner.ts +126 -103
- package/src/irdevice/airpurifier.ts +84 -66
- package/src/irdevice/camera.ts +84 -68
- package/src/irdevice/fan.ts +91 -75
- package/src/irdevice/light.ts +84 -68
- package/src/irdevice/other.ts +94 -78
- package/src/irdevice/tv.ts +69 -53
- package/src/irdevice/vacuumcleaner.ts +83 -68
- package/src/irdevice/waterheater.ts +76 -60
- package/src/settings.ts +12 -11
package/dist/irdevice/light.js
CHANGED
|
@@ -61,7 +61,7 @@ class Light {
|
|
|
61
61
|
});*/
|
|
62
62
|
}
|
|
63
63
|
async OnSet(value) {
|
|
64
|
-
this.debugLog(
|
|
64
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
|
|
65
65
|
this.On = value;
|
|
66
66
|
if (this.On) {
|
|
67
67
|
await this.pushLightOnChanges();
|
|
@@ -72,22 +72,22 @@ class Light {
|
|
|
72
72
|
}
|
|
73
73
|
async updateHomeKitCharacteristics() {
|
|
74
74
|
if (this.On === undefined) {
|
|
75
|
-
this.debugLog(
|
|
75
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${this.On}`);
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
78
|
this.lightBulbService?.updateCharacteristic(this.platform.Characteristic.On, this.On);
|
|
79
|
-
this.debugLog(
|
|
79
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic On: ${this.On}`);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
83
|
* Pushes the requested changes to the SwitchBot API
|
|
84
84
|
* deviceType commandType Command command parameter Description
|
|
85
|
-
* Light
|
|
86
|
-
* Light
|
|
87
|
-
* Light
|
|
88
|
-
* Light
|
|
89
|
-
* Light
|
|
90
|
-
* Light
|
|
85
|
+
* Light - "command" "turnOff" "default" = set to OFF state
|
|
86
|
+
* Light - "command" "turnOn" "default" = set to ON state
|
|
87
|
+
* Light - "command" "volumeAdd" "default" = volume up
|
|
88
|
+
* Light - "command" "volumeSub" "default" = volume down
|
|
89
|
+
* Light - "command" "channelAdd" "default" = next channel
|
|
90
|
+
* Light - "command" "channelSub" "default" = previous channel
|
|
91
91
|
*/
|
|
92
92
|
async pushLightOnChanges() {
|
|
93
93
|
if (this.On) {
|
|
@@ -126,88 +126,100 @@ class Light {
|
|
|
126
126
|
await this.pushChanges(body);
|
|
127
127
|
}
|
|
128
128
|
async pushChanges(body) {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
129
|
+
if (this.OpenAPI) {
|
|
130
|
+
try {
|
|
131
|
+
// Make Push On request to the API
|
|
132
|
+
const t = Date.now();
|
|
133
|
+
const nonce = 'requestID';
|
|
134
|
+
const data = this.platform.config.credentials?.token + t + nonce;
|
|
135
|
+
const signTerm = crypto_1.default.createHmac('sha256', this.platform.config.credentials?.secret)
|
|
136
|
+
.update(Buffer.from(data, 'utf-8'))
|
|
137
|
+
.digest();
|
|
138
|
+
const sign = signTerm.toString('base64');
|
|
139
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
140
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
|
|
141
|
+
const options = {
|
|
142
|
+
hostname: settings_1.HostDomain,
|
|
143
|
+
port: 443,
|
|
144
|
+
path: `${settings_1.DevicePath}/${this.device.deviceId}/commands`,
|
|
145
|
+
method: 'POST',
|
|
146
|
+
headers: {
|
|
147
|
+
'Authorization': this.platform.config.credentials?.token,
|
|
148
|
+
'sign': sign,
|
|
149
|
+
'nonce': nonce,
|
|
150
|
+
't': t,
|
|
151
|
+
'Content-Type': 'application/json',
|
|
152
|
+
'Content-Length': body.length,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
const req = https_1.default.request(options, res => {
|
|
156
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
|
|
157
|
+
this.statusCode({ res });
|
|
158
|
+
res.on('data', d => {
|
|
159
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} d: ${d}`);
|
|
160
|
+
});
|
|
159
161
|
});
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
162
|
+
req.on('error', (e) => {
|
|
163
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
164
|
+
});
|
|
165
|
+
req.write(body);
|
|
166
|
+
req.end();
|
|
167
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges: ${(0, super_stringify_1.default)(req)}`);
|
|
168
|
+
this.OnCached = this.On;
|
|
169
|
+
this.accessory.context.On = this.OnCached;
|
|
170
|
+
this.updateHomeKitCharacteristics();
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
174
|
+
if (this.deviceLogging.includes('debug')) {
|
|
175
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
176
|
+
+ ` Error Message: ${(0, super_stringify_1.default)(e.message)}`);
|
|
177
|
+
}
|
|
178
|
+
this.apiError(e);
|
|
175
179
|
}
|
|
176
|
-
this.apiError(e);
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
182
|
async statusCode({ res }) {
|
|
180
183
|
switch (res.statusCode) {
|
|
181
184
|
case 151:
|
|
182
|
-
this.errorLog(
|
|
185
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
183
186
|
break;
|
|
184
187
|
case 152:
|
|
185
|
-
this.errorLog(
|
|
188
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found.`);
|
|
186
189
|
break;
|
|
187
190
|
case 160:
|
|
188
|
-
this.errorLog(
|
|
191
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported.`);
|
|
189
192
|
break;
|
|
190
193
|
case 161:
|
|
191
|
-
this.errorLog(
|
|
194
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`);
|
|
192
195
|
break;
|
|
193
196
|
case 171:
|
|
194
|
-
this.errorLog(
|
|
197
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
195
198
|
break;
|
|
196
199
|
case 190:
|
|
197
|
-
this.errorLog(
|
|
200
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
|
|
198
201
|
` with server, Or command: ${(0, super_stringify_1.default)(res)} format is invalid`);
|
|
199
202
|
break;
|
|
200
203
|
case 100:
|
|
201
|
-
this.debugLog(
|
|
204
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
|
|
202
205
|
break;
|
|
203
206
|
default:
|
|
204
|
-
this.debugLog(
|
|
207
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode.`);
|
|
205
208
|
}
|
|
206
209
|
}
|
|
207
210
|
async apiError(e) {
|
|
208
211
|
this.lightBulbService.updateCharacteristic(this.platform.Characteristic.On, e);
|
|
209
212
|
//throw new this.platform.api.hap.HapStatusError(HAPStatus.SERVICE_COMMUNICATION_FAILURE);
|
|
210
213
|
}
|
|
214
|
+
async openAPI() {
|
|
215
|
+
if (!this.device.openAPI) {
|
|
216
|
+
this.OpenAPI = true;
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
this.OpenAPI = this.device.openAPI;
|
|
220
|
+
}
|
|
221
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using OpenAPI: ${this.OpenAPI}`);
|
|
222
|
+
}
|
|
211
223
|
async config(device) {
|
|
212
224
|
let config = {};
|
|
213
225
|
if (device.irlight) {
|
|
@@ -216,26 +228,29 @@ class Light {
|
|
|
216
228
|
if (device.logging !== undefined) {
|
|
217
229
|
config['logging'] = device.logging;
|
|
218
230
|
}
|
|
231
|
+
if (device.openAPI !== undefined) {
|
|
232
|
+
config['openAPI'] = device.openAPI;
|
|
233
|
+
}
|
|
219
234
|
if (Object.entries(config).length !== 0) {
|
|
220
|
-
this.infoLog(
|
|
235
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${(0, super_stringify_1.default)(config)}`);
|
|
221
236
|
}
|
|
222
237
|
}
|
|
223
238
|
async logs(device) {
|
|
224
239
|
if (this.platform.debugMode) {
|
|
225
240
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
226
|
-
this.debugLog(
|
|
241
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
227
242
|
}
|
|
228
243
|
else if (device.logging) {
|
|
229
244
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
230
|
-
this.debugLog(
|
|
245
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
231
246
|
}
|
|
232
247
|
else if (this.platform.config.options?.logging) {
|
|
233
248
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
234
|
-
this.debugLog(
|
|
249
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
235
250
|
}
|
|
236
251
|
else {
|
|
237
252
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
238
|
-
this.debugLog(
|
|
253
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
239
254
|
}
|
|
240
255
|
}
|
|
241
256
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"light.js","sourceRoot":"","sources":["../../src/irdevice/light.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,oDAA4B;AAE5B,sEAA6C;AAE7C,0CAAgF;AAGhF;;;;GAIG;AACH,MAAa,KAAK;
|
|
1
|
+
{"version":3,"file":"light.js","sourceRoot":"","sources":["../../src/irdevice/light.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,oDAA4B;AAE5B,sEAA6C;AAE7C,0CAAgF;AAGhF;;;;GAIG;AACH,MAAa,KAAK;IAYhB,YAA6B,QAA2B,EAAU,SAA4B,EAAS,MAAkC;QAA5G,aAAQ,GAAR,QAAQ,CAAmB;QAAU,cAAS,GAAT,SAAS,CAAmB;QAAS,WAAM,GAAN,MAAM,CAA4B;QACvI,uBAAuB;QACvB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACpB,IAAI,IAAI,CAAC,EAAE,KAAK,SAAS,EAAE;YACzB,IAAI,CAA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declare class Others {
|
|
|
17
17
|
ActiveCached: CharacteristicValue;
|
|
18
18
|
deviceLogging: string;
|
|
19
19
|
otherDeviceType?: string;
|
|
20
|
+
OpenAPI?: boolean;
|
|
20
21
|
constructor(platform: SwitchBotPlatform, accessory: PlatformAccessory, device: irdevice & irDevicesConfig);
|
|
21
22
|
ActiveSet(value: CharacteristicValue): Promise<void>;
|
|
22
23
|
updateHomeKitCharacteristics(): Promise<void>;
|
|
23
24
|
/**
|
|
24
25
|
* Pushes the requested changes to the SwitchBot API
|
|
25
26
|
* deviceType commandType Command command parameter Description
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
27
|
+
* Other - "command" "turnOff" "default" = set to OFF state
|
|
28
|
+
* Other - "command" "turnOn" "default" = set to ON state
|
|
29
|
+
* Other - "command" "volumeAdd" "default" = volume up
|
|
30
|
+
* Other - "command" "volumeSub" "default" = volume down
|
|
31
|
+
* Other - "command" "channelAdd" "default" = next channel
|
|
32
|
+
* Other - "command" "channelSub" "default" = previous channel
|
|
32
33
|
*/
|
|
33
34
|
pushOnChanges(): Promise<void>;
|
|
34
35
|
pushOffChanges(): Promise<void>;
|
|
@@ -38,6 +39,7 @@ export declare class Others {
|
|
|
38
39
|
}): Promise<void>;
|
|
39
40
|
apiError(e: any): Promise<void>;
|
|
40
41
|
deviceType(device: irdevice & irDevicesConfig): Promise<void>;
|
|
42
|
+
openAPI(): Promise<void>;
|
|
41
43
|
config(device: irdevice & irDevicesConfig): Promise<void>;
|
|
42
44
|
logs(device: irdevice & irDevicesConfig): Promise<void>;
|
|
43
45
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"other.d.ts","sourceRoot":"","sources":["../../src/irdevice/other.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC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,CAAC,EAAE,GAAG,EAAE,EAAE;QAAE,GAAG,EAAE,eAAe,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA+B5D,QAAQ,CAAC,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAK/B,UAAU,CAAC,MAAM,EAAE,QAAQ,GAAG,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAW7D,OAAO;IASP,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAgBzD,IAAI,CAAC,MAAM,EAAE,QAAQ,GAAG,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB7D;;OAEG;IACH,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM5B,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM5B,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAM7B,QAAQ,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;IAU7B,qBAAqB,IAAI,OAAO;CAGjC"}
|
package/dist/irdevice/other.js
CHANGED
|
@@ -37,26 +37,26 @@ class Others {
|
|
|
37
37
|
// get the Television service if it exists, otherwise create a new Television service
|
|
38
38
|
// you can create multiple services for each accessory
|
|
39
39
|
if (this.otherDeviceType !== 'Fan') {
|
|
40
|
-
this.debugLog(
|
|
40
|
+
this.debugLog(`${this.device.remoteType}: ${accessory.displayName} Removing Fanv2 Service`);
|
|
41
41
|
if (this.otherDeviceType === undefined) {
|
|
42
|
-
this.errorLog(
|
|
42
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} No Device Type Set, deviceType: ${device.other?.deviceType}`);
|
|
43
43
|
}
|
|
44
44
|
this.fanService = this.accessory.getService(this.platform.Service.Fanv2);
|
|
45
45
|
accessory.removeService(this.fanService);
|
|
46
46
|
}
|
|
47
47
|
else if (!this.fanService && this.otherDeviceType === 'Fan') {
|
|
48
|
-
this.debugLog(
|
|
48
|
+
this.debugLog(`${this.device.remoteType}: ${accessory.displayName} Add Fanv2 Service`);
|
|
49
49
|
(this.fanService = this.accessory.getService(this.platform.Service.Fanv2) || this.accessory.addService(this.platform.Service.Fanv2)),
|
|
50
50
|
`${accessory.displayName} Fan`;
|
|
51
51
|
this.fanService.setCharacteristic(this.platform.Characteristic.Name, `${accessory.displayName} Fan`);
|
|
52
52
|
this.fanService.getCharacteristic(this.platform.Characteristic.Active).onSet(this.ActiveSet.bind(this));
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
|
-
this.debugLog(
|
|
55
|
+
this.debugLog(`${this.device.remoteType}: ${accessory.displayName} Fanv2 Service Not Added, deviceType: ${device.other?.deviceType}`);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
async ActiveSet(value) {
|
|
59
|
-
this.debugLog(
|
|
59
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} On: ${value}`);
|
|
60
60
|
if (value) {
|
|
61
61
|
await this.pushOnChanges();
|
|
62
62
|
}
|
|
@@ -69,22 +69,22 @@ class Others {
|
|
|
69
69
|
}
|
|
70
70
|
async updateHomeKitCharacteristics() {
|
|
71
71
|
if (this.Active === undefined) {
|
|
72
|
-
this.debugLog(
|
|
72
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Active: ${this.Active}`);
|
|
73
73
|
}
|
|
74
74
|
else {
|
|
75
75
|
this.fanService?.updateCharacteristic(this.platform.Characteristic.Active, this.Active);
|
|
76
|
-
this.debugLog(
|
|
76
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} updateCharacteristic Active: ${this.Active}`);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Pushes the requested changes to the SwitchBot API
|
|
81
81
|
* deviceType commandType Command command parameter Description
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
82
|
+
* Other - "command" "turnOff" "default" = set to OFF state
|
|
83
|
+
* Other - "command" "turnOn" "default" = set to ON state
|
|
84
|
+
* Other - "command" "volumeAdd" "default" = volume up
|
|
85
|
+
* Other - "command" "volumeSub" "default" = volume down
|
|
86
|
+
* Other - "command" "channelAdd" "default" = next channel
|
|
87
|
+
* Other - "command" "channelSub" "default" = previous channel
|
|
88
88
|
*/
|
|
89
89
|
async pushOnChanges() {
|
|
90
90
|
if (this.platform.config.options) {
|
|
@@ -100,15 +100,15 @@ class Others {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
|
-
this.errorLog(
|
|
103
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set, commandOn: ${this.device.other.commandOn}`);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
else {
|
|
107
|
-
this.errorLog(
|
|
107
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set, other: ${this.device.other}`);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
else {
|
|
111
|
-
this.errorLog(
|
|
111
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} On Command not set`);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
async pushOffChanges() {
|
|
@@ -125,92 +125,95 @@ class Others {
|
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
else {
|
|
128
|
-
this.errorLog(
|
|
128
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set, commandOff: ${this.device.other.commandOff}`);
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
else {
|
|
132
|
-
this.errorLog(
|
|
132
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set, other: ${this.device.other}`);
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
else {
|
|
136
|
-
this.errorLog(
|
|
136
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Off Command not set.`);
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
async pushChanges(body) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
140
|
+
if (this.OpenAPI) {
|
|
141
|
+
try {
|
|
142
|
+
// Make Push On request to the API
|
|
143
|
+
const t = Date.now();
|
|
144
|
+
const nonce = 'requestID';
|
|
145
|
+
const data = this.platform.config.credentials?.token + t + nonce;
|
|
146
|
+
const signTerm = crypto_1.default.createHmac('sha256', this.platform.config.credentials?.secret)
|
|
147
|
+
.update(Buffer.from(data, 'utf-8'))
|
|
148
|
+
.digest();
|
|
149
|
+
const sign = signTerm.toString('base64');
|
|
150
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} sign: ${sign}`);
|
|
151
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Sending request to SwitchBot API. body: ${body},`);
|
|
152
|
+
const options = {
|
|
153
|
+
hostname: settings_1.HostDomain,
|
|
154
|
+
port: 443,
|
|
155
|
+
path: `${settings_1.DevicePath}/${this.device.deviceId}/commands`,
|
|
156
|
+
method: 'POST',
|
|
157
|
+
headers: {
|
|
158
|
+
'Authorization': this.platform.config.credentials?.token,
|
|
159
|
+
'sign': sign,
|
|
160
|
+
'nonce': nonce,
|
|
161
|
+
't': t,
|
|
162
|
+
'Content-Type': 'application/json',
|
|
163
|
+
'Content-Length': body.length,
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
const req = https_1.default.request(options, res => {
|
|
167
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} statusCode: ${res.statusCode}`);
|
|
168
|
+
this.statusCode({ res });
|
|
169
|
+
res.on('data', d => {
|
|
170
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} d: ${d}`);
|
|
171
|
+
});
|
|
170
172
|
});
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
173
|
+
req.on('error', (e) => {
|
|
174
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} error message: ${e.message}`);
|
|
175
|
+
});
|
|
176
|
+
req.write(body);
|
|
177
|
+
req.end();
|
|
178
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} pushchanges: ${(0, super_stringify_1.default)(req)}`);
|
|
179
|
+
this.updateHomeKitCharacteristics();
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection`);
|
|
183
|
+
if (this.deviceLogging.includes('debug')) {
|
|
184
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} failed pushChanges with OpenAPI Connection,`
|
|
185
|
+
+ ` Error Message: ${(0, super_stringify_1.default)(e.message)}`);
|
|
186
|
+
}
|
|
187
|
+
this.apiError(e);
|
|
184
188
|
}
|
|
185
|
-
this.apiError(e);
|
|
186
189
|
}
|
|
187
190
|
}
|
|
188
191
|
async statusCode({ res }) {
|
|
189
192
|
switch (res.statusCode) {
|
|
190
193
|
case 151:
|
|
191
|
-
this.errorLog(
|
|
194
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command not supported by this device type.`);
|
|
192
195
|
break;
|
|
193
196
|
case 152:
|
|
194
|
-
this.errorLog(
|
|
197
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device not found.`);
|
|
195
198
|
break;
|
|
196
199
|
case 160:
|
|
197
|
-
this.errorLog(
|
|
200
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Command is not supported.`);
|
|
198
201
|
break;
|
|
199
202
|
case 161:
|
|
200
|
-
this.errorLog(
|
|
203
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device is offline.`);
|
|
201
204
|
break;
|
|
202
205
|
case 171:
|
|
203
|
-
this.errorLog(
|
|
206
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Hub Device is offline. Hub: ${this.device.hubDeviceId}`);
|
|
204
207
|
break;
|
|
205
208
|
case 190:
|
|
206
|
-
this.errorLog(
|
|
209
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} Device internal error due to device states not synchronized` +
|
|
207
210
|
` with server, Or command: ${(0, super_stringify_1.default)(res)} format is invalid`);
|
|
208
211
|
break;
|
|
209
212
|
case 100:
|
|
210
|
-
this.debugLog(
|
|
213
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Command successfully sent.`);
|
|
211
214
|
break;
|
|
212
215
|
default:
|
|
213
|
-
this.debugLog(
|
|
216
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Unknown statusCode.`);
|
|
214
217
|
}
|
|
215
218
|
}
|
|
216
219
|
async apiError(e) {
|
|
@@ -221,13 +224,22 @@ class Others {
|
|
|
221
224
|
if (device.other?.deviceType) {
|
|
222
225
|
this.otherDeviceType = this.accessory.context.deviceType = device.other.deviceType;
|
|
223
226
|
if (this.deviceLogging.includes('debug') || this.deviceLogging === 'standard') {
|
|
224
|
-
this.warnLog(
|
|
227
|
+
this.warnLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Type: ${this.otherDeviceType}`);
|
|
225
228
|
}
|
|
226
229
|
}
|
|
227
230
|
else {
|
|
228
|
-
this.errorLog(
|
|
231
|
+
this.errorLog(`${this.device.remoteType}: ${this.accessory.displayName} No Device Type Set, deviceType: ${this.device.other?.deviceType}`);
|
|
229
232
|
}
|
|
230
233
|
}
|
|
234
|
+
async openAPI() {
|
|
235
|
+
if (!this.device.openAPI) {
|
|
236
|
+
this.OpenAPI = true;
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
this.OpenAPI = this.device.openAPI;
|
|
240
|
+
}
|
|
241
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using OpenAPI: ${this.OpenAPI}`);
|
|
242
|
+
}
|
|
231
243
|
async config(device) {
|
|
232
244
|
let config = {};
|
|
233
245
|
if (device.other) {
|
|
@@ -236,26 +248,29 @@ class Others {
|
|
|
236
248
|
if (device.logging !== undefined) {
|
|
237
249
|
config['logging'] = device.logging;
|
|
238
250
|
}
|
|
251
|
+
if (device.openAPI !== undefined) {
|
|
252
|
+
config['openAPI'] = device.openAPI;
|
|
253
|
+
}
|
|
239
254
|
if (Object.entries(config).length !== 0) {
|
|
240
|
-
this.infoLog(
|
|
255
|
+
this.infoLog(`${this.device.remoteType}: ${this.accessory.displayName} Config: ${(0, super_stringify_1.default)(config)}`);
|
|
241
256
|
}
|
|
242
257
|
}
|
|
243
258
|
async logs(device) {
|
|
244
259
|
if (this.platform.debugMode) {
|
|
245
260
|
this.deviceLogging = this.accessory.context.logging = 'debugMode';
|
|
246
|
-
this.debugLog(
|
|
261
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Debug Mode Logging: ${this.deviceLogging}`);
|
|
247
262
|
}
|
|
248
263
|
else if (device.logging) {
|
|
249
264
|
this.deviceLogging = this.accessory.context.logging = device.logging;
|
|
250
|
-
this.debugLog(
|
|
265
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Device Config Logging: ${this.deviceLogging}`);
|
|
251
266
|
}
|
|
252
267
|
else if (this.platform.config.options?.logging) {
|
|
253
268
|
this.deviceLogging = this.accessory.context.logging = this.platform.config.options?.logging;
|
|
254
|
-
this.debugLog(
|
|
269
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Using Platform Config Logging: ${this.deviceLogging}`);
|
|
255
270
|
}
|
|
256
271
|
else {
|
|
257
272
|
this.deviceLogging = this.accessory.context.logging = 'standard';
|
|
258
|
-
this.debugLog(
|
|
273
|
+
this.debugLog(`${this.device.remoteType}: ${this.accessory.displayName} Logging Not Set, Using: ${this.deviceLogging}`);
|
|
259
274
|
}
|
|
260
275
|
}
|
|
261
276
|
/**
|