@switchbot/homebridge-switchbot 1.2.1-beta.4 → 1.2.2
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 +12 -2
- package/config.schema.json +2 -2
- package/dist/devices/bots.d.ts +3 -2
- package/dist/devices/bots.d.ts.map +1 -1
- package/dist/devices/bots.js +26 -11
- package/dist/devices/bots.js.map +1 -1
- package/dist/devices/colorbulb.d.ts +2 -2
- package/dist/devices/colorbulb.d.ts.map +1 -1
- package/dist/devices/colorbulb.js.map +1 -1
- package/dist/devices/contact.d.ts +3 -2
- package/dist/devices/contact.d.ts.map +1 -1
- package/dist/devices/contact.js +21 -8
- package/dist/devices/contact.js.map +1 -1
- package/dist/devices/curtains.d.ts +3 -2
- package/dist/devices/curtains.d.ts.map +1 -1
- package/dist/devices/curtains.js +21 -8
- package/dist/devices/curtains.js.map +1 -1
- package/dist/devices/humidifiers.d.ts +3 -2
- package/dist/devices/humidifiers.d.ts.map +1 -1
- package/dist/devices/humidifiers.js +21 -8
- package/dist/devices/humidifiers.js.map +1 -1
- package/dist/devices/indoorcam.d.ts +2 -2
- package/dist/devices/indoorcam.d.ts.map +1 -1
- package/dist/devices/indoorcam.js.map +1 -1
- package/dist/devices/meters.d.ts +3 -2
- package/dist/devices/meters.d.ts.map +1 -1
- package/dist/devices/meters.js +34 -13
- package/dist/devices/meters.js.map +1 -1
- package/dist/devices/motion.d.ts +3 -2
- package/dist/devices/motion.d.ts.map +1 -1
- package/dist/devices/motion.js +21 -8
- package/dist/devices/motion.js.map +1 -1
- package/dist/devices/plugs.d.ts +2 -2
- package/dist/devices/plugs.d.ts.map +1 -1
- package/dist/devices/plugs.js.map +1 -1
- package/dist/irdevices/airconditioners.d.ts +1 -1
- package/dist/irdevices/airconditioners.d.ts.map +1 -1
- package/dist/irdevices/airconditioners.js.map +1 -1
- package/dist/irdevices/airpurifiers.d.ts +1 -1
- package/dist/irdevices/airpurifiers.d.ts.map +1 -1
- package/dist/irdevices/airpurifiers.js.map +1 -1
- package/dist/irdevices/cameras.d.ts +1 -1
- package/dist/irdevices/cameras.d.ts.map +1 -1
- package/dist/irdevices/cameras.js.map +1 -1
- package/dist/irdevices/fans.d.ts +1 -1
- package/dist/irdevices/fans.d.ts.map +1 -1
- package/dist/irdevices/lights.d.ts +1 -1
- package/dist/irdevices/lights.d.ts.map +1 -1
- package/dist/irdevices/lights.js.map +1 -1
- package/dist/irdevices/others.d.ts +1 -1
- package/dist/irdevices/others.d.ts.map +1 -1
- package/dist/irdevices/others.js.map +1 -1
- package/dist/irdevices/tvs.d.ts +1 -1
- package/dist/irdevices/tvs.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts +1 -1
- package/dist/irdevices/vacuumcleaners.d.ts.map +1 -1
- package/dist/irdevices/vacuumcleaners.js.map +1 -1
- package/dist/irdevices/waterheaters.d.ts +1 -1
- package/dist/irdevices/waterheaters.d.ts.map +1 -1
- package/dist/irdevices/waterheaters.js.map +1 -1
- package/dist/platform.d.ts +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +8 -2
- package/dist/platform.js.map +1 -1
- package/package.json +66 -66
- package/src/devices/bots.ts +25 -13
- package/src/devices/colorbulb.ts +3 -3
- package/src/devices/contact.ts +19 -9
- package/src/devices/curtains.ts +21 -10
- package/src/devices/humidifiers.ts +20 -10
- package/src/devices/indoorcam.ts +3 -3
- package/src/devices/meters.ts +30 -14
- package/src/devices/motion.ts +19 -9
- package/src/devices/plugs.ts +4 -3
- package/src/irdevices/airconditioners.ts +1 -1
- package/src/irdevices/airpurifiers.ts +1 -1
- package/src/irdevices/cameras.ts +1 -1
- package/src/irdevices/fans.ts +1 -1
- package/src/irdevices/lights.ts +1 -1
- package/src/irdevices/others.ts +1 -1
- package/src/irdevices/tvs.ts +1 -1
- package/src/irdevices/vacuumcleaners.ts +1 -1
- package/src/irdevices/waterheaters.ts +1 -1
- package/src/platform.ts +10 -12
package/src/devices/curtains.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
|
|
2
|
+
import { AxiosResponse } from 'axios';
|
|
3
|
+
import Switchbot from 'node-switchbot';
|
|
3
4
|
import { interval, Subject } from 'rxjs';
|
|
5
|
+
import { SwitchBotPlatform } from '../platform';
|
|
4
6
|
import { debounceTime, skipWhile, tap } from 'rxjs/operators';
|
|
7
|
+
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
5
8
|
import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse, payload } from '../settings';
|
|
6
|
-
import { AxiosResponse } from 'axios';
|
|
7
9
|
|
|
8
10
|
export class Curtain {
|
|
9
11
|
// Services
|
|
@@ -23,6 +25,7 @@ export class Curtain {
|
|
|
23
25
|
deviceStatus!: deviceStatusResponse;
|
|
24
26
|
|
|
25
27
|
// BLE Others
|
|
28
|
+
connected?: boolean;
|
|
26
29
|
switchbot!: switchbot;
|
|
27
30
|
serviceData!: serviceData;
|
|
28
31
|
calibration: serviceData['calibration'];
|
|
@@ -188,12 +191,8 @@ export class Curtain {
|
|
|
188
191
|
}
|
|
189
192
|
|
|
190
193
|
private connectBLE() {
|
|
191
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
192
|
-
const Switchbot = require('node-switchbot');
|
|
193
194
|
const switchbot = new Switchbot();
|
|
194
|
-
|
|
195
|
-
const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
|
|
196
|
-
this.device.bleMac = bleMac.toLowerCase();
|
|
195
|
+
this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase();
|
|
197
196
|
this.platform.device(`Curtain: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
198
197
|
return switchbot;
|
|
199
198
|
}
|
|
@@ -415,14 +414,26 @@ export class Curtain {
|
|
|
415
414
|
this.platform.device(`Curtain: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
416
415
|
this.platform.device(`Curtain: ${this.accessory.displayName} calibration: ${ad.serviceData.calibration}, `
|
|
417
416
|
+ `position: ${ad.serviceData.position}, lightLevel: ${ad.serviceData.lightLevel}, battery: ${ad.serviceData.battery}`);
|
|
417
|
+
|
|
418
|
+
if (this.serviceData) {
|
|
419
|
+
this.connected = true;
|
|
420
|
+
this.platform.device(`Curtain: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
421
|
+
} else {
|
|
422
|
+
this.connected = false;
|
|
423
|
+
this.platform.device(`Curtain: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
424
|
+
}
|
|
418
425
|
};
|
|
419
426
|
// Wait 10 seconds
|
|
420
427
|
return switchbot.wait(10000);
|
|
421
428
|
}).then(() => {
|
|
422
429
|
// Stop to monitor
|
|
423
430
|
switchbot.stopScan();
|
|
424
|
-
this.
|
|
425
|
-
|
|
431
|
+
if (this.connected) {
|
|
432
|
+
this.parseStatus();
|
|
433
|
+
this.updateHomeKitCharacteristics();
|
|
434
|
+
} else {
|
|
435
|
+
this.platform.log.error(`Curtain: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
|
|
436
|
+
}
|
|
426
437
|
}).catch(async (e: any) => {
|
|
427
438
|
this.platform.log.error(`Curtain: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
428
439
|
if (this.deviceDebug) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
2
|
+
import Switchbot from 'node-switchbot';
|
|
3
3
|
import { interval, Subject } from 'rxjs';
|
|
4
|
+
import { SwitchBotPlatform } from '../platform';
|
|
4
5
|
import { debounceTime, skipWhile, tap } from 'rxjs/operators';
|
|
6
|
+
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
5
7
|
import { DeviceURL, device, devicesConfig, serviceData, ad, deviceStatusResponse, payload } from '../settings';
|
|
6
|
-
import { AxiosResponse } from 'axios';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Platform Accessory
|
|
@@ -28,6 +29,7 @@ export class Humidifier {
|
|
|
28
29
|
deviceStatus!: deviceStatusResponse;
|
|
29
30
|
|
|
30
31
|
// BLE Others
|
|
32
|
+
connected?: boolean;
|
|
31
33
|
serviceData!: serviceData;
|
|
32
34
|
onState!: serviceData['onState'];
|
|
33
35
|
autoMode!: serviceData['autoMode'];
|
|
@@ -290,12 +292,8 @@ export class Humidifier {
|
|
|
290
292
|
}
|
|
291
293
|
|
|
292
294
|
private connectBLE() {
|
|
293
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
294
|
-
const Switchbot = require('node-switchbot');
|
|
295
295
|
const switchbot = new Switchbot();
|
|
296
|
-
|
|
297
|
-
const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
|
|
298
|
-
this.device.bleMac = bleMac.toLowerCase();
|
|
296
|
+
this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase();
|
|
299
297
|
this.platform.device(`Humidifier: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
300
298
|
return switchbot;
|
|
301
299
|
}
|
|
@@ -318,14 +316,26 @@ export class Humidifier {
|
|
|
318
316
|
this.platform.device(`Humidifier: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
319
317
|
this.platform.device(`Humidifier: ${this.accessory.displayName} model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName},`
|
|
320
318
|
+ `autoMode: ${ad.serviceData.autoMode}, onState: ${ad.serviceData.onState}, percentage: ${ad.serviceData.percentage}`);
|
|
319
|
+
|
|
320
|
+
if (this.serviceData) {
|
|
321
|
+
this.connected = true;
|
|
322
|
+
this.platform.device(`Humidifier: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
323
|
+
} else {
|
|
324
|
+
this.connected = false;
|
|
325
|
+
this.platform.device(`Humidifier: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
326
|
+
}
|
|
321
327
|
};
|
|
322
328
|
// Wait 10 seconds
|
|
323
329
|
return switchbot.wait(10000);
|
|
324
330
|
}).then(() => {
|
|
325
331
|
// Stop to monitor
|
|
326
332
|
switchbot.stopScan();
|
|
327
|
-
this.
|
|
328
|
-
|
|
333
|
+
if (this.connected) {
|
|
334
|
+
this.parseStatus();
|
|
335
|
+
this.updateHomeKitCharacteristics();
|
|
336
|
+
} else {
|
|
337
|
+
this.platform.log.error(`Humidifier: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
|
|
338
|
+
}
|
|
329
339
|
}).catch(async (e: any) => {
|
|
330
340
|
this.platform.log.error(`Humidifier: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
331
341
|
if (this.deviceDebug) {
|
package/src/devices/indoorcam.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SwitchBotPlatform } from '../platform';
|
|
1
|
+
import { AxiosResponse } from 'axios';
|
|
3
2
|
import { interval, Subject } from 'rxjs';
|
|
3
|
+
import { SwitchBotPlatform } from '../platform';
|
|
4
4
|
import { debounceTime, skipWhile, tap } from 'rxjs/operators';
|
|
5
|
+
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
5
6
|
import { DeviceURL, device, devicesConfig, deviceStatusResponse, payload } from '../settings';
|
|
6
|
-
import { AxiosResponse } from 'axios';
|
|
7
7
|
|
|
8
8
|
export class IndoorCam {
|
|
9
9
|
// Services
|
package/src/devices/meters.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { SwitchBotPlatform } from '../platform';
|
|
1
|
+
import Switchbot from 'node-switchbot';
|
|
3
2
|
import { interval, Subject } from 'rxjs';
|
|
4
3
|
import { skipWhile } from 'rxjs/operators';
|
|
4
|
+
import { SwitchBotPlatform } from '../platform';
|
|
5
|
+
import { Service, PlatformAccessory, Units, CharacteristicValue } from 'homebridge';
|
|
5
6
|
import { DeviceURL, device, devicesConfig, serviceData, ad, switchbot, deviceStatusResponse } from '../settings';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -28,6 +29,7 @@ export class Meter {
|
|
|
28
29
|
deviceStatus!: deviceStatusResponse;
|
|
29
30
|
|
|
30
31
|
// BLE Others
|
|
32
|
+
connected?: boolean;
|
|
31
33
|
switchbot!: switchbot;
|
|
32
34
|
serviceData!: serviceData;
|
|
33
35
|
battery!: serviceData['battery'];
|
|
@@ -189,8 +191,14 @@ export class Meter {
|
|
|
189
191
|
|
|
190
192
|
// Current Temperature
|
|
191
193
|
if (!this.device.meter?.hide_temperature) {
|
|
192
|
-
this.
|
|
193
|
-
|
|
194
|
+
if (this.device.meter?.unit === 1) {
|
|
195
|
+
this.CurrentTemperature = this.toFahrenheit(this.temperature!.c);
|
|
196
|
+
} else if (this.device.meter?.unit === 0) {
|
|
197
|
+
this.CurrentTemperature = this.toCelsius(this.temperature!.c);
|
|
198
|
+
} else {
|
|
199
|
+
this.CurrentTemperature = Number(this.temperature?.c);
|
|
200
|
+
}
|
|
201
|
+
this.platform.debug(`Meter: ${this.accessory.displayName} Temperature: ${this.CurrentTemperature}°c`);
|
|
194
202
|
}
|
|
195
203
|
}
|
|
196
204
|
|
|
@@ -239,12 +247,8 @@ export class Meter {
|
|
|
239
247
|
}
|
|
240
248
|
|
|
241
249
|
private connectBLE() {
|
|
242
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
243
|
-
const Switchbot = require('node-switchbot');
|
|
244
250
|
const switchbot = new Switchbot();
|
|
245
|
-
|
|
246
|
-
const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
|
|
247
|
-
this.device.bleMac = bleMac.toLowerCase();
|
|
251
|
+
this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase();
|
|
248
252
|
this.platform.device(`Meter: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
249
253
|
return switchbot;
|
|
250
254
|
}
|
|
@@ -255,7 +259,7 @@ export class Meter {
|
|
|
255
259
|
const switchbot = this.connectBLE();
|
|
256
260
|
// Start to monitor advertisement packets
|
|
257
261
|
switchbot.startScan({
|
|
258
|
-
model: '
|
|
262
|
+
model: 'T',
|
|
259
263
|
id: this.device.bleMac,
|
|
260
264
|
}).then(() => {
|
|
261
265
|
// Set an event hander
|
|
@@ -267,16 +271,28 @@ export class Meter {
|
|
|
267
271
|
this.battery = ad.serviceData.battery;
|
|
268
272
|
this.platform.device(`Meter: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
269
273
|
this.platform.device(`Meter: ${this.accessory.displayName} model: ${ad.serviceData.model}, modelName: ${ad.serviceData.modelName}, `
|
|
270
|
-
+ `temperature: ${ad.serviceData.temperature}, fahrenheit: ${ad.serviceData.fahrenheit},
|
|
271
|
-
+ `battery: ${ad.serviceData.battery}`);
|
|
274
|
+
+ `temperature: ${JSON.stringify(ad.serviceData.temperature)}, fahrenheit: ${ad.serviceData.fahrenheit}, `
|
|
275
|
+
+ `humidity: ${ad.serviceData.humidity}, battery: ${ad.serviceData.battery}`);
|
|
276
|
+
|
|
277
|
+
if (this.serviceData) {
|
|
278
|
+
this.connected = true;
|
|
279
|
+
this.platform.device(`Meter: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
280
|
+
} else {
|
|
281
|
+
this.connected = false;
|
|
282
|
+
this.platform.device(`Meter: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
283
|
+
}
|
|
272
284
|
};
|
|
273
285
|
// Wait 10 seconds
|
|
274
286
|
return switchbot.wait(10000);
|
|
275
287
|
}).then(() => {
|
|
276
288
|
// Stop to monitor
|
|
277
289
|
switchbot.stopScan();
|
|
278
|
-
this.
|
|
279
|
-
|
|
290
|
+
if (this.connected) {
|
|
291
|
+
this.parseStatus();
|
|
292
|
+
this.updateHomeKitCharacteristics();
|
|
293
|
+
} else {
|
|
294
|
+
this.platform.log.error(`Meter: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
|
|
295
|
+
}
|
|
280
296
|
}).catch(async (e: any) => {
|
|
281
297
|
this.platform.log.error(`Meter: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
282
298
|
if (this.deviceDebug) {
|
package/src/devices/motion.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { SwitchBotPlatform } from '../platform';
|
|
1
|
+
import Switchbot from 'node-switchbot';
|
|
3
2
|
import { interval, Subject } from 'rxjs';
|
|
4
3
|
import { skipWhile } from 'rxjs/operators';
|
|
4
|
+
import { SwitchBotPlatform } from '../platform';
|
|
5
|
+
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
5
6
|
import { DeviceURL, device, devicesConfig, serviceData, switchbot, deviceStatusResponse } from '../settings';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -25,6 +26,7 @@ export class Motion {
|
|
|
25
26
|
deviceStatus!: deviceStatusResponse;
|
|
26
27
|
|
|
27
28
|
// BLE Others
|
|
29
|
+
connected?: boolean;
|
|
28
30
|
switchbot!: switchbot;
|
|
29
31
|
serviceData!: serviceData;
|
|
30
32
|
battery!: serviceData['battery'];
|
|
@@ -160,12 +162,8 @@ export class Motion {
|
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
private connectBLE() {
|
|
163
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
164
|
-
const Switchbot = require('node-switchbot');
|
|
165
165
|
const switchbot = new Switchbot();
|
|
166
|
-
|
|
167
|
-
const bleMac = colon!.join(':'); //returns 1A:23:B4:56:78:9A;
|
|
168
|
-
this.device.bleMac = bleMac.toLowerCase();
|
|
166
|
+
this.device.bleMac = ((this.device.deviceId!.match(/.{1,2}/g))!.join(':')).toLowerCase();
|
|
169
167
|
this.platform.device(`Motion Sensor: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`);
|
|
170
168
|
return switchbot;
|
|
171
169
|
}
|
|
@@ -188,14 +186,26 @@ export class Motion {
|
|
|
188
186
|
this.platform.device(`Motion Sensor: ${this.accessory.displayName} serviceData: ${JSON.stringify(ad.serviceData)}`);
|
|
189
187
|
this.platform.device(`Motion Sensor: ${this.accessory.displayName} movement: ${ad.serviceData.movement}, lightLevel: `
|
|
190
188
|
+ `${ad.serviceData.lightLevel}, battery: ${ad.serviceData.battery}`);
|
|
189
|
+
|
|
190
|
+
if (this.serviceData) {
|
|
191
|
+
this.connected = true;
|
|
192
|
+
this.platform.device(`Motion Sensor: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
193
|
+
} else {
|
|
194
|
+
this.connected = false;
|
|
195
|
+
this.platform.device(`Motion Sensor: ${this.accessory.displayName} connected: ${this.connected}`);
|
|
196
|
+
}
|
|
191
197
|
};
|
|
192
198
|
// Wait 10 seconds
|
|
193
199
|
return switchbot.wait(10000);
|
|
194
200
|
}).then(() => {
|
|
195
201
|
// Stop to monitor
|
|
196
202
|
switchbot.stopScan();
|
|
197
|
-
this.
|
|
198
|
-
|
|
203
|
+
if (this.connected) {
|
|
204
|
+
this.parseStatus();
|
|
205
|
+
this.updateHomeKitCharacteristics();
|
|
206
|
+
} else {
|
|
207
|
+
this.platform.log.error(`Motion Sensor: ${this.accessory.displayName} wasn't able to establish BLE Connection`);
|
|
208
|
+
}
|
|
199
209
|
}).catch(async (e: any) => {
|
|
200
210
|
this.platform.log.error(`Motion Sensor: ${this.accessory.displayName} failed refreshStatus with BLE Connection`);
|
|
201
211
|
if (this.deviceDebug) {
|
package/src/devices/plugs.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
|
|
2
|
+
import { AxiosResponse } from 'axios';
|
|
3
3
|
import { interval, Subject } from 'rxjs';
|
|
4
|
+
import { SwitchBotPlatform } from '../platform';
|
|
4
5
|
import { debounceTime, skipWhile, tap } from 'rxjs/operators';
|
|
6
|
+
import { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
|
|
5
7
|
import { DeviceURL, device, devicesConfig, deviceStatusResponse, payload } from '../settings';
|
|
6
|
-
import { AxiosResponse } from 'axios';
|
|
7
8
|
|
|
8
9
|
export class Plug {
|
|
9
10
|
// Services
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
2
|
import { SwitchBotPlatform } from '../platform';
|
|
4
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
2
|
import { SwitchBotPlatform } from '../platform';
|
|
4
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
package/src/irdevices/cameras.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
2
|
import { SwitchBotPlatform } from '../platform';
|
|
4
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
package/src/irdevices/fans.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
4
4
|
import { DeviceURL, irdevice, deviceStatusResponse, irDevicesConfig, payload } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
package/src/irdevices/lights.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
2
|
import { SwitchBotPlatform } from '../platform';
|
|
4
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
package/src/irdevices/others.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
2
|
import { SwitchBotPlatform } from '../platform';
|
|
4
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
package/src/irdevices/tvs.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
2
|
import { SwitchBotPlatform } from '../platform';
|
|
3
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
4
4
|
import { DeviceURL, irdevice, deviceStatusResponse, irDevicesConfig, payload } from '../settings';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
2
|
import { SwitchBotPlatform } from '../platform';
|
|
4
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
3
2
|
import { SwitchBotPlatform } from '../platform';
|
|
4
3
|
import { irDevicesConfig, DeviceURL, irdevice, payload } from '../settings';
|
|
4
|
+
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Platform Accessory
|
package/src/platform.ts
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
3
|
-
import {
|
|
4
|
-
PLATFORM_NAME,
|
|
5
|
-
PLUGIN_NAME,
|
|
6
|
-
DeviceURL,
|
|
7
|
-
irdevice,
|
|
8
|
-
device,
|
|
9
|
-
SwitchBotPlatformConfig,
|
|
10
|
-
deviceResponses,
|
|
11
|
-
devicesConfig,
|
|
12
|
-
} from './settings';
|
|
1
|
+
|
|
13
2
|
import { Bot } from './devices/bots';
|
|
14
3
|
import { Plug } from './devices/plugs';
|
|
15
4
|
import { Meter } from './devices/meters';
|
|
@@ -28,6 +17,9 @@ import { AirPurifier } from './irdevices/airpurifiers';
|
|
|
28
17
|
import { WaterHeater } from './irdevices/waterheaters';
|
|
29
18
|
import { VacuumCleaner } from './irdevices/vacuumcleaners';
|
|
30
19
|
import { AirConditioner } from './irdevices/airconditioners';
|
|
20
|
+
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
21
|
+
import { API, DynamicPlatformPlugin, Logger, PlatformAccessory, Service, Characteristic } from 'homebridge';
|
|
22
|
+
import { PLATFORM_NAME, PLUGIN_NAME, DeviceURL, irdevice, device, SwitchBotPlatformConfig, deviceResponses, devicesConfig } from './settings';
|
|
31
23
|
|
|
32
24
|
/**
|
|
33
25
|
* HomebridgePlatform
|
|
@@ -200,6 +192,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
200
192
|
const devices = deviceLists.map((v: any) => v);
|
|
201
193
|
for (const device of devices) {
|
|
202
194
|
if (device.deviceType) {
|
|
195
|
+
if (device.configDeviceName) {
|
|
196
|
+
device.deviceName = device.configDeviceName;
|
|
197
|
+
}
|
|
203
198
|
this.createDevice(device);
|
|
204
199
|
}
|
|
205
200
|
}
|
|
@@ -217,6 +212,9 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
217
212
|
this.debug(`SwitchBot Devices: ${JSON.stringify(devices)}`);
|
|
218
213
|
for (const device of devices) {
|
|
219
214
|
if (device.deviceType) {
|
|
215
|
+
if (device.configDeviceName) {
|
|
216
|
+
device.deviceName = device.configDeviceName;
|
|
217
|
+
}
|
|
220
218
|
this.createDevice(device);
|
|
221
219
|
}
|
|
222
220
|
}
|