@switchbot/homebridge-switchbot 3.5.1-beta.2 → 3.5.1-beta.3
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/dist/device/blindtilt.d.ts +15 -6
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +203 -255
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +9 -4
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +196 -218
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +9 -4
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +202 -247
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +10 -5
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +329 -378
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +9 -4
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +99 -142
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +19 -7
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +203 -264
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +28 -32
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +186 -225
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +9 -4
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +198 -227
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +9 -5
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +106 -231
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +12 -4
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +192 -232
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +9 -4
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +91 -157
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +10 -5
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +287 -367
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +10 -5
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +171 -216
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +9 -4
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +93 -158
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +9 -4
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +94 -155
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +9 -4
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +84 -142
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +9 -4
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +99 -124
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +9 -6
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +170 -253
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +12 -4
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +102 -128
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts +2 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.d.ts +2 -1
- package/dist/irdevice/airpurifier.d.ts.map +1 -1
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts +2 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts +2 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +2 -1
- package/dist/irdevice/irdevice.d.ts.map +1 -1
- package/dist/irdevice/irdevice.js +1 -1
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts +2 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.d.ts +2 -1
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts +2 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts +2 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts +2 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +5 -7
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +51 -34
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +49 -191
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js +19 -0
- package/dist/settings.js.map +1 -1
- package/dist/types/bledevicestatus.d.ts +279 -0
- package/dist/types/bledevicestatus.d.ts.map +1 -0
- package/dist/types/bledevicestatus.js +2 -0
- package/dist/types/bledevicestatus.js.map +1 -0
- package/dist/types/devicelist.d.ts +89 -0
- package/dist/types/devicelist.d.ts.map +1 -0
- package/dist/types/devicelist.js +6 -0
- package/dist/types/devicelist.js.map +1 -0
- package/dist/types/deviceresponse.d.ts +13 -0
- package/dist/types/deviceresponse.d.ts.map +1 -0
- package/dist/types/deviceresponse.js +2 -0
- package/dist/types/deviceresponse.js.map +1 -0
- package/dist/types/devicestatus.d.ts +149 -0
- package/dist/types/devicestatus.d.ts.map +1 -0
- package/dist/types/devicestatus.js +3 -0
- package/dist/types/devicestatus.js.map +1 -0
- package/dist/types/devicewebhookstatus.d.ts +156 -0
- package/dist/types/devicewebhookstatus.d.ts.map +1 -0
- package/dist/types/devicewebhookstatus.js +2 -0
- package/dist/types/devicewebhookstatus.js.map +1 -0
- package/dist/types/irdevicelist.d.ts +10 -0
- package/dist/types/irdevicelist.d.ts.map +1 -0
- package/dist/types/irdevicelist.js +2 -0
- package/dist/types/irdevicelist.js.map +1 -0
- package/dist/types/pushbody.d.ts +6 -0
- package/dist/types/pushbody.d.ts.map +1 -0
- package/dist/types/pushbody.js +2 -0
- package/dist/types/pushbody.js.map +1 -0
- package/dist/utils.d.ts +25 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +28 -0
- package/dist/utils.js.map +1 -1
- package/package.json +10 -10
- package/src/device/blindtilt.ts +223 -263
- package/src/device/bot.ts +208 -221
- package/src/device/ceilinglight.ts +210 -257
- package/src/device/colorbulb.ts +334 -397
- package/src/device/contact.ts +111 -146
- package/src/device/curtain.ts +220 -283
- package/src/device/device.ts +194 -245
- package/src/device/fan.ts +214 -230
- package/src/device/hub.ts +126 -246
- package/src/device/humidifier.ts +216 -243
- package/src/device/iosensor.ts +114 -166
- package/src/device/lightstrip.ts +302 -377
- package/src/device/lock.ts +187 -221
- package/src/device/meter.ts +116 -177
- package/src/device/meterplus.ts +117 -174
- package/src/device/motion.ts +99 -144
- package/src/device/plug.ts +110 -128
- package/src/device/robotvacuumcleaner.ts +189 -252
- package/src/device/waterdetector.ts +120 -138
- package/src/irdevice/airconditioner.ts +2 -1
- package/src/irdevice/airpurifier.ts +2 -1
- package/src/irdevice/camera.ts +2 -1
- package/src/irdevice/fan.ts +2 -1
- package/src/irdevice/irdevice.ts +3 -2
- package/src/irdevice/light.ts +2 -1
- package/src/irdevice/other.ts +2 -1
- package/src/irdevice/tv.ts +2 -1
- package/src/irdevice/vacuumcleaner.ts +2 -1
- package/src/irdevice/waterheater.ts +2 -1
- package/src/platform.ts +52 -34
- package/src/settings.ts +30 -239
- package/src/types/bledevicestatus.ts +305 -0
- package/src/types/devicelist.ts +124 -0
- package/src/types/deviceresponse.ts +15 -0
- package/src/types/devicestatus.ts +178 -0
- package/src/types/devicewebhookstatus.ts +196 -0
- package/src/types/irdevicelist.ts +15 -0
- package/src/types/pushbody.ts +9 -0
- package/src/utils.ts +33 -0
package/src/platform.ts
CHANGED
|
@@ -34,7 +34,7 @@ import { AirConditioner } from './irdevice/airconditioner.js';
|
|
|
34
34
|
import { Buffer } from 'buffer';
|
|
35
35
|
import { request } from 'undici';
|
|
36
36
|
import asyncmqtt from 'async-mqtt';
|
|
37
|
-
import { sleep } from './utils.js';
|
|
37
|
+
import { isBlindTiltDevice, isCurtainDevice, sleep } from './utils.js';
|
|
38
38
|
import { createServer } from 'http';
|
|
39
39
|
import { queueScheduler } from 'rxjs';
|
|
40
40
|
import fakegato from 'fakegato-history';
|
|
@@ -48,7 +48,9 @@ import type { MqttClient } from 'mqtt';
|
|
|
48
48
|
import type { Dispatcher } from 'undici';
|
|
49
49
|
import type { Server, IncomingMessage, ServerResponse } from 'http';
|
|
50
50
|
import type { API, DynamicPlatformPlugin, Logging, PlatformAccessory } from 'homebridge';
|
|
51
|
-
import type {
|
|
51
|
+
import type { SwitchBotPlatformConfig, devicesConfig, irDevicesConfig } from './settings.js';
|
|
52
|
+
import type { irdevice } from './types/irdevicelist.js';
|
|
53
|
+
import type { blindTilt, curtain, curtain3, device } from './types/devicelist.js';
|
|
52
54
|
|
|
53
55
|
/**
|
|
54
56
|
* HomebridgePlatform
|
|
@@ -74,7 +76,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
74
76
|
|
|
75
77
|
public readonly fakegatoAPI: any;
|
|
76
78
|
public readonly eve: any;
|
|
77
|
-
public readonly webhookEventHandler
|
|
79
|
+
public readonly webhookEventHandler;
|
|
78
80
|
|
|
79
81
|
constructor(
|
|
80
82
|
log: Logging,
|
|
@@ -164,7 +166,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
164
166
|
try {
|
|
165
167
|
this.debugLog(`Received Webhook via MQTT: ${topic}=${message}`);
|
|
166
168
|
const context = JSON.parse(message.toString());
|
|
167
|
-
|
|
169
|
+
this.webhookEventHandler[context.deviceMac]?.(context);
|
|
168
170
|
} catch (e: any) {
|
|
169
171
|
this.errorLog(`Failed to handle webhook event. Error:${e}`);
|
|
170
172
|
}
|
|
@@ -201,7 +203,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
201
203
|
const options = this.config.options?.mqttPubOptions || {};
|
|
202
204
|
this.mqttClient?.publish(`homebridge-switchbot/webhook/${mac}`, `${JSON.stringify(body.context)}`, options);
|
|
203
205
|
}
|
|
204
|
-
|
|
206
|
+
this.webhookEventHandler[body.context.deviceMac]?.(body.context);
|
|
205
207
|
} catch (e: any) {
|
|
206
208
|
this.errorLog(`Failed to handle webhook event. Error:${e}`);
|
|
207
209
|
}
|
|
@@ -1402,15 +1404,17 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1402
1404
|
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1403
1405
|
}
|
|
1404
1406
|
|
|
1405
|
-
if (device
|
|
1406
|
-
|
|
1407
|
-
|
|
1407
|
+
if (isBlindTiltDevice(device)) {
|
|
1408
|
+
if (device.group && !device.curtain?.disable_group) {
|
|
1409
|
+
this.debugLog(
|
|
1410
|
+
'Your Curtains are grouped, ' +
|
|
1408
1411
|
`, Secondary curtain automatically hidden. Main Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
|
|
1409
|
-
} else {
|
|
1410
|
-
if (device.master) {
|
|
1411
|
-
this.warnLog(`Main Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
|
|
1412
1412
|
} else {
|
|
1413
|
-
|
|
1413
|
+
if (device.master) {
|
|
1414
|
+
this.warnLog(`Main Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
|
|
1415
|
+
} else {
|
|
1416
|
+
this.errorLog(`Secondary Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
|
|
1417
|
+
}
|
|
1414
1418
|
}
|
|
1415
1419
|
}
|
|
1416
1420
|
|
|
@@ -1474,15 +1478,18 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1474
1478
|
this.infoLog(`Adding new accessory: ${device.deviceName} ${device.deviceType} DeviceID: ${device.deviceId}`);
|
|
1475
1479
|
}
|
|
1476
1480
|
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1481
|
+
|
|
1482
|
+
if (isCurtainDevice(device)) {
|
|
1483
|
+
if (device.group && !device.curtain?.disable_group) {
|
|
1484
|
+
this.debugLog(
|
|
1485
|
+
'Your Curtains are grouped, ' +
|
|
1480
1486
|
`, Secondary curtain automatically hidden. Main Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
|
|
1481
|
-
} else {
|
|
1482
|
-
if (device.master) {
|
|
1483
|
-
this.warnLog(`Main Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
|
|
1484
1487
|
} else {
|
|
1485
|
-
|
|
1488
|
+
if (device.master) {
|
|
1489
|
+
this.warnLog(`Main Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
|
|
1490
|
+
} else {
|
|
1491
|
+
this.errorLog(`Secondary Curtain: ${device.deviceName}, DeviceID: ${device.deviceId}`);
|
|
1492
|
+
}
|
|
1486
1493
|
}
|
|
1487
1494
|
}
|
|
1488
1495
|
|
|
@@ -1944,9 +1951,6 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
1944
1951
|
existingAccessory.context.model = device.remoteType;
|
|
1945
1952
|
existingAccessory.context.deviceID = device.deviceId;
|
|
1946
1953
|
existingAccessory.displayName = device.configDeviceName || device.deviceName;
|
|
1947
|
-
if (device.version && !device.firmware) {
|
|
1948
|
-
existingAccessory.context.version = device.version;
|
|
1949
|
-
}
|
|
1950
1954
|
existingAccessory.context.deviceType = `IR: ${device.remoteType}`;
|
|
1951
1955
|
this.infoLog(`Restoring existing accessory from cache: ${existingAccessory.displayName} DeviceID: ${device.deviceId}`);
|
|
1952
1956
|
existingAccessory.context.connectionType = device.connectionType;
|
|
@@ -2466,18 +2470,32 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2466
2470
|
}
|
|
2467
2471
|
}
|
|
2468
2472
|
|
|
2469
|
-
async registerCurtains(device: device & devicesConfig) {
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2473
|
+
async registerCurtains(device: device & devicesConfig): Promise<boolean> {
|
|
2474
|
+
/*function isCurtainDevice(device: device & devicesConfig): device is (curtain | curtain3) & devicesConfig {
|
|
2475
|
+
return device.deviceType === 'Curtain' || device.deviceType === 'Curtain3';
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
function isBlindTiltDevice(device: device & devicesConfig): device is blindTilt & devicesConfig {
|
|
2479
|
+
return device.deviceType === 'Blind Tilt';
|
|
2480
|
+
}*/
|
|
2481
|
+
let registerWindowCovering: boolean;
|
|
2482
|
+
if (isCurtainDevice(device)) {
|
|
2483
|
+
this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, curtainDevicesIds: ${device.curtainDevicesIds}, master: `
|
|
2484
|
+
+ `${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group}, connectionType: ${device.connectionType}`);
|
|
2485
|
+
registerWindowCovering = await this.registerWindowCovering(device);
|
|
2486
|
+
} else if (isBlindTiltDevice(device)) {
|
|
2487
|
+
this.debugWarnLog(`deviceName: ${device.deviceName} deviceId: ${device.deviceId}, blindTiltDevicesIds: ${device.blindTiltDevicesIds},`
|
|
2488
|
+
+ ` master: ${device.master}, group: ${device.group}, disable_group: ${device.curtain?.disable_group},`
|
|
2489
|
+
+ ` connectionType: ${device.connectionType}`);
|
|
2490
|
+
registerWindowCovering =await this.registerWindowCovering(device);
|
|
2491
|
+
} else {
|
|
2492
|
+
registerWindowCovering = false;
|
|
2479
2493
|
}
|
|
2494
|
+
return registerWindowCovering;
|
|
2495
|
+
}
|
|
2480
2496
|
|
|
2497
|
+
async registerWindowCovering(device: ((curtain | curtain3) & devicesConfig) | (blindTilt & devicesConfig)) {
|
|
2498
|
+
this.debugLog(device.master);
|
|
2481
2499
|
let registerCurtain: boolean;
|
|
2482
2500
|
if (device.master && device.group) {
|
|
2483
2501
|
// OpenAPI: Master Curtains/Blind Tilt in Group
|
|
@@ -2731,14 +2749,14 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2731
2749
|
}
|
|
2732
2750
|
|
|
2733
2751
|
// BLE Connection
|
|
2734
|
-
async connectBLE() {
|
|
2752
|
+
async connectBLE(accessory: PlatformAccessory, device: device & devicesConfig) {
|
|
2735
2753
|
let switchbot: any;
|
|
2736
2754
|
try {
|
|
2737
2755
|
const SwitchBot = (await import('node-switchbot')).SwitchBot;
|
|
2738
2756
|
queueScheduler.schedule(() => (switchbot = new SwitchBot()));
|
|
2739
2757
|
} catch (e: any) {
|
|
2740
2758
|
switchbot = false;
|
|
2741
|
-
this.errorLog(
|
|
2759
|
+
this.errorLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' found: ${switchbot}, Error: ${e}`);
|
|
2742
2760
|
}
|
|
2743
2761
|
return switchbot;
|
|
2744
2762
|
}
|
package/src/settings.ts
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
* settings.ts: @switchbot/homebridge-switchbot platform class.
|
|
4
4
|
*/
|
|
5
5
|
import type { IClientOptions } from 'async-mqtt';
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
6
|
+
import type { PlatformConfig } from 'homebridge';
|
|
7
|
+
import type { device } from './types/devicelist';
|
|
8
|
+
import type { irdevice } from './types/irdevicelist';
|
|
9
|
+
import type { SwitchBotBLEModel, SwitchBotBLEModelName, SwitchBotBLEModelFriendlyName } from 'node-switchbot';
|
|
8
10
|
/**
|
|
9
11
|
* This is the name of the platform that users will use to register the plugin in the Homebridge config.json
|
|
10
12
|
*/
|
|
@@ -40,20 +42,20 @@ export const updateWebhook = 'https://api.switch-bot.com/v1.1/webhook/updateWebh
|
|
|
40
42
|
*/
|
|
41
43
|
export const deleteWebhook = 'https://api.switch-bot.com/v1.1/webhook/deleteWebhook';
|
|
42
44
|
|
|
45
|
+
|
|
43
46
|
//Config
|
|
44
47
|
export interface SwitchBotPlatformConfig extends PlatformConfig {
|
|
45
48
|
credentials?: credentials;
|
|
46
|
-
options?: options
|
|
49
|
+
options?: options;
|
|
47
50
|
}
|
|
48
|
-
|
|
49
|
-
export type credentials = {
|
|
51
|
+
interface credentials {
|
|
50
52
|
token?: any;
|
|
51
53
|
secret?: any;
|
|
52
54
|
notice?: any;
|
|
53
55
|
openToken?: any;
|
|
54
|
-
}
|
|
56
|
+
}
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
interface options {
|
|
57
59
|
refreshRate?: number;
|
|
58
60
|
updateRate?: number;
|
|
59
61
|
pushRate?: number;
|
|
@@ -71,8 +73,9 @@ export type options = {
|
|
|
71
73
|
export interface devicesConfig extends device {
|
|
72
74
|
bleMac?: string;
|
|
73
75
|
model?: string;
|
|
74
|
-
bleModel
|
|
75
|
-
bleModelName
|
|
76
|
+
bleModel: SwitchBotBLEModel;
|
|
77
|
+
bleModelName: SwitchBotBLEModelName;
|
|
78
|
+
bleModelFriednlyName: SwitchBotBLEModelFriendlyName;
|
|
76
79
|
configDeviceType: string;
|
|
77
80
|
configDeviceName?: string;
|
|
78
81
|
deviceId: string;
|
|
@@ -113,19 +116,19 @@ export interface devicesConfig extends device {
|
|
|
113
116
|
hub?: hub;
|
|
114
117
|
}
|
|
115
118
|
|
|
116
|
-
|
|
119
|
+
interface meter {
|
|
117
120
|
hide_temperature?: boolean;
|
|
118
121
|
convertUnitTo?: string;
|
|
119
122
|
hide_humidity?: boolean;
|
|
120
123
|
};
|
|
121
124
|
|
|
122
|
-
|
|
125
|
+
interface iosensor {
|
|
123
126
|
hide_temperature?: boolean;
|
|
124
127
|
convertUnitTo?: string;
|
|
125
128
|
hide_humidity?: boolean;
|
|
126
129
|
};
|
|
127
130
|
|
|
128
|
-
|
|
131
|
+
interface bot {
|
|
129
132
|
mode?: string;
|
|
130
133
|
deviceType?: string;
|
|
131
134
|
doublePress?: number;
|
|
@@ -134,12 +137,12 @@ export type bot = {
|
|
|
134
137
|
multiPress?: boolean;
|
|
135
138
|
};
|
|
136
139
|
|
|
137
|
-
|
|
140
|
+
interface humidifier {
|
|
138
141
|
hide_temperature?: boolean;
|
|
139
142
|
set_minStep?: number;
|
|
140
143
|
};
|
|
141
144
|
|
|
142
|
-
|
|
145
|
+
interface curtain {
|
|
143
146
|
disable_group?: boolean;
|
|
144
147
|
hide_lightsensor?: boolean;
|
|
145
148
|
set_minLux?: number;
|
|
@@ -151,7 +154,7 @@ export type curtain = {
|
|
|
151
154
|
setOpenMode?: string;
|
|
152
155
|
};
|
|
153
156
|
|
|
154
|
-
|
|
157
|
+
interface blindTilt {
|
|
155
158
|
mode?: string;
|
|
156
159
|
hide_lightsensor?: boolean;
|
|
157
160
|
set_minLux?: number;
|
|
@@ -163,44 +166,44 @@ export type blindTilt = {
|
|
|
163
166
|
setOpenMode?: string;
|
|
164
167
|
};
|
|
165
168
|
|
|
166
|
-
|
|
169
|
+
interface contact {
|
|
167
170
|
hide_lightsensor?: boolean;
|
|
168
171
|
set_minLux?: number;
|
|
169
172
|
set_maxLux?: number;
|
|
170
173
|
hide_motionsensor?: boolean;
|
|
171
174
|
};
|
|
172
175
|
|
|
173
|
-
|
|
176
|
+
interface motion {
|
|
174
177
|
hide_lightsensor?: boolean;
|
|
175
178
|
set_minLux?: number;
|
|
176
179
|
set_maxLux?: number;
|
|
177
180
|
};
|
|
178
181
|
|
|
179
|
-
|
|
182
|
+
interface waterdetector {
|
|
180
183
|
hide_leak?: boolean;
|
|
181
184
|
};
|
|
182
185
|
|
|
183
|
-
|
|
186
|
+
interface colorbulb {
|
|
184
187
|
set_minStep?: number;
|
|
185
188
|
adaptiveLightingShift?: number;
|
|
186
189
|
};
|
|
187
190
|
|
|
188
|
-
|
|
191
|
+
interface striplight {
|
|
189
192
|
set_minStep?: number;
|
|
190
193
|
adaptiveLightingShift?: number;
|
|
191
194
|
};
|
|
192
195
|
|
|
193
|
-
|
|
196
|
+
interface ceilinglight {
|
|
194
197
|
set_minStep?: number;
|
|
195
198
|
adaptiveLightingShift?: number;
|
|
196
199
|
};
|
|
197
200
|
|
|
198
|
-
|
|
201
|
+
interface lock {
|
|
199
202
|
hide_contactsensor?: boolean;
|
|
200
203
|
activate_latchbutton?: boolean;
|
|
201
204
|
};
|
|
202
205
|
|
|
203
|
-
|
|
206
|
+
interface hub {
|
|
204
207
|
hide_temperature?: boolean;
|
|
205
208
|
convertUnitTo?: string;
|
|
206
209
|
hide_humidity?: boolean;
|
|
@@ -233,7 +236,7 @@ export interface irDevicesConfig extends irdevice {
|
|
|
233
236
|
other?: other;
|
|
234
237
|
}
|
|
235
238
|
|
|
236
|
-
|
|
239
|
+
interface irfan {
|
|
237
240
|
swing_mode?: boolean;
|
|
238
241
|
rotation_speed?: boolean;
|
|
239
242
|
set_minStep?: number;
|
|
@@ -241,11 +244,11 @@ export type irfan = {
|
|
|
241
244
|
set_min?: number;
|
|
242
245
|
};
|
|
243
246
|
|
|
244
|
-
|
|
247
|
+
interface irlight {
|
|
245
248
|
stateless?: boolean;
|
|
246
249
|
};
|
|
247
250
|
|
|
248
|
-
|
|
251
|
+
interface irair {
|
|
249
252
|
hide_automode?: boolean;
|
|
250
253
|
set_max_heat?: number;
|
|
251
254
|
set_min_heat?: number;
|
|
@@ -256,218 +259,6 @@ export type irair = {
|
|
|
256
259
|
meterUuid?: string;
|
|
257
260
|
};
|
|
258
261
|
|
|
259
|
-
|
|
262
|
+
interface other {
|
|
260
263
|
deviceType?: string;
|
|
261
264
|
};
|
|
262
|
-
|
|
263
|
-
export type body = {
|
|
264
|
-
command: string;
|
|
265
|
-
parameter: string;
|
|
266
|
-
commandType: string;
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
//a list of physical devices.
|
|
270
|
-
export type deviceList = {
|
|
271
|
-
device: device[];
|
|
272
|
-
};
|
|
273
|
-
|
|
274
|
-
export type device = {
|
|
275
|
-
//device ID.
|
|
276
|
-
deviceId?: string;
|
|
277
|
-
//device name.
|
|
278
|
-
deviceName: string;
|
|
279
|
-
//device type.
|
|
280
|
-
deviceType: string;
|
|
281
|
-
//determines if Cloud Service is enabled or not for the current device.
|
|
282
|
-
enableCloudService: boolean;
|
|
283
|
-
//device's parent Hub ID.
|
|
284
|
-
hubDeviceId: string;
|
|
285
|
-
//only available for Curtain devices. a list of Curtain device IDs such that the Curtain devices are being paired or grouped.
|
|
286
|
-
curtainDevicesIds?: string[];
|
|
287
|
-
//only available for Blind Titl devices. a list of Blind Tilt device IDs such that the Blind Tilt devices are being paired or grouped.
|
|
288
|
-
blindTiltDevicesIds?: string[];
|
|
289
|
-
//only available for Curtain/Lock devices. determines if the open position and the close position of a device have been properly calibrated or not
|
|
290
|
-
calibrate?: boolean;
|
|
291
|
-
//only available for Curtain devices. determines if a Curtain is paired with or grouped with another Curtain or not.
|
|
292
|
-
group?: boolean;
|
|
293
|
-
//only available for Curtain devices. determines if a Curtain is the master device or not when paired with or grouped with another Curtain.
|
|
294
|
-
master?: boolean;
|
|
295
|
-
//only available for Curtain devices. the opening direction of a Curtain.
|
|
296
|
-
openDirection?: string;
|
|
297
|
-
//the opening direction of a Blind Tilt device
|
|
298
|
-
direction?: string;
|
|
299
|
-
//the current position, 0-100
|
|
300
|
-
slidePosition?: string;
|
|
301
|
-
//the version of the device
|
|
302
|
-
version?: string;
|
|
303
|
-
// Fan Mode: direct mode: direct; natural mode: "natural"; sleep mode: "sleep"; ultra quiet mode: "baby"
|
|
304
|
-
mode: string;
|
|
305
|
-
//the current battery level
|
|
306
|
-
battery: number;
|
|
307
|
-
//ON/OFF state
|
|
308
|
-
power: string;
|
|
309
|
-
//set nightlight status. turn off: off; mode 1: 1; mode 2: 2
|
|
310
|
-
nightStatus: number;
|
|
311
|
-
//set horizontal oscillation. turn on: on; turn off: off
|
|
312
|
-
oscillation: string;
|
|
313
|
-
//set vertical oscillation. turn on: on; turn off: off
|
|
314
|
-
verticalOscillation: string;
|
|
315
|
-
//battery charge status. charging or uncharged
|
|
316
|
-
chargingStatus: string;
|
|
317
|
-
//fan speed. 1~100
|
|
318
|
-
fanSpeed: number;
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
//a list of virtual infrared remote devices.
|
|
322
|
-
export type infraredRemoteList = {
|
|
323
|
-
device: irdevice[];
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
export type irdevice = {
|
|
327
|
-
deviceId?: string; //device ID
|
|
328
|
-
deviceName: string; //device name
|
|
329
|
-
remoteType: string; //device type
|
|
330
|
-
hubDeviceId: string; //remote device's parent Hub ID
|
|
331
|
-
model: string; //device model
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
export type deviceStatus = {
|
|
335
|
-
statusCode: number;
|
|
336
|
-
message: string;
|
|
337
|
-
body: deviceStatusBody;
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
export type deviceStatusBody = {
|
|
341
|
-
//v1.1 of API
|
|
342
|
-
deviceId: string;
|
|
343
|
-
deviceType: string;
|
|
344
|
-
hubDeviceId: string;
|
|
345
|
-
power?: string;
|
|
346
|
-
calibrate?: boolean;
|
|
347
|
-
group?: boolean;
|
|
348
|
-
moving?: boolean;
|
|
349
|
-
slidePosition?: number;
|
|
350
|
-
temperature?: number;
|
|
351
|
-
humidity?: number;
|
|
352
|
-
lockState?: string;
|
|
353
|
-
doorState?: string;
|
|
354
|
-
moveDetected?: boolean;
|
|
355
|
-
brightness?: string | number;
|
|
356
|
-
openState?: string;
|
|
357
|
-
colorTemperature?: number;
|
|
358
|
-
voltage?: number;
|
|
359
|
-
weight?: number;
|
|
360
|
-
electricityOfDay?: number;
|
|
361
|
-
electricCurrent?: number;
|
|
362
|
-
color?: string;
|
|
363
|
-
workingStatus?: string;
|
|
364
|
-
onlineStatus?: string;
|
|
365
|
-
battery?: number;
|
|
366
|
-
deviceName?: string;
|
|
367
|
-
nebulizationEfficiency?: number;
|
|
368
|
-
auto?: boolean;
|
|
369
|
-
childLock?: boolean;
|
|
370
|
-
sound?: boolean;
|
|
371
|
-
lackWater?: boolean;
|
|
372
|
-
version?: number;
|
|
373
|
-
direction?: string;
|
|
374
|
-
runStatus?: string;
|
|
375
|
-
mode?: number | string;
|
|
376
|
-
speed?: number;
|
|
377
|
-
shaking?: boolean;
|
|
378
|
-
shakeCenter?: string;
|
|
379
|
-
shakeRange?: string;
|
|
380
|
-
status?: number;
|
|
381
|
-
lightLevel?: number;
|
|
382
|
-
nightStatus: number;
|
|
383
|
-
oscillation: string;
|
|
384
|
-
verticalOscillation: string;
|
|
385
|
-
chargingStatus: string;
|
|
386
|
-
fanSpeed: number;
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
export type ad = {
|
|
390
|
-
id: string;
|
|
391
|
-
address: string;
|
|
392
|
-
rssi: number;
|
|
393
|
-
serviceData: serviceData;
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
export type serviceData = {
|
|
397
|
-
//Model of BLE SwitchBot Device
|
|
398
|
-
model: string;
|
|
399
|
-
//Model Name of BLE SwitchBot Device
|
|
400
|
-
modelName: string;
|
|
401
|
-
//Mode for Bot either Press or Switch
|
|
402
|
-
mode?: boolean;
|
|
403
|
-
//Bot/ColorBulb State
|
|
404
|
-
state?: string | boolean;
|
|
405
|
-
//Lock door open
|
|
406
|
-
door_open?: string;
|
|
407
|
-
//Lock Status
|
|
408
|
-
status?: string;
|
|
409
|
-
//ColorBulb Power
|
|
410
|
-
power?: boolean;
|
|
411
|
-
//ColorBulb R
|
|
412
|
-
red?: number;
|
|
413
|
-
//ColorBulb G
|
|
414
|
-
green?: number;
|
|
415
|
-
//ColorBulb B
|
|
416
|
-
blue?: number;
|
|
417
|
-
//ColorBulb Color temperature
|
|
418
|
-
color_temperature?: number;
|
|
419
|
-
//Battery percentage left on Bot, Meter, Motion, Contact, PlugMini, and Curtain
|
|
420
|
-
battery?: number;
|
|
421
|
-
//Humidifier's humidity level percentage
|
|
422
|
-
percentage?: boolean | string;
|
|
423
|
-
//Humidifier's state
|
|
424
|
-
onState?: boolean;
|
|
425
|
-
//Humidifier's AutoMode
|
|
426
|
-
autoMode?: boolean;
|
|
427
|
-
//Meter Temperature Levels
|
|
428
|
-
temperature?: temperature;
|
|
429
|
-
// Fahrenheit enabled for Meter
|
|
430
|
-
fahrenheit?: boolean;
|
|
431
|
-
// Humidity level for Meter
|
|
432
|
-
humidity?: number;
|
|
433
|
-
//Motion Detected for Contact or Motion Sensors
|
|
434
|
-
movement?: boolean;
|
|
435
|
-
//Motion ((lightLevel == 1) ? 'dark' : ((lightLevel == 2) ? 'bright' : 'unknown'))
|
|
436
|
-
//Contact ((lightLevel == 0) ? 'dark' : 'bright')
|
|
437
|
-
//Curtain (light sensor level (1-10))
|
|
438
|
-
//Light Level
|
|
439
|
-
lightLevel?: number | string | boolean;
|
|
440
|
-
//Contact DoorState
|
|
441
|
-
doorState?: number | string;
|
|
442
|
-
//Is Curtain Calibrated
|
|
443
|
-
calibration?: boolean;
|
|
444
|
-
//Current Curtain Positon %
|
|
445
|
-
position?: number;
|
|
446
|
-
//Is Curtain Moving?
|
|
447
|
-
inMotion?: boolean;
|
|
448
|
-
//PlugMini - Is there a delay?
|
|
449
|
-
delay?: boolean;
|
|
450
|
-
//PlugMini - Is there a Timer?
|
|
451
|
-
timer?: boolean;
|
|
452
|
-
//PlugMini - Is the UTC time has been synchronized?
|
|
453
|
-
syncUtcTime?: boolean;
|
|
454
|
-
//PlugMini - The Wifi RSSI Signal
|
|
455
|
-
wifiRssi?: number;
|
|
456
|
-
//PlugMini - Whether the Plug Mini is overloaded, more than 15A current overload
|
|
457
|
-
overload?: boolean;
|
|
458
|
-
//PlugMini - Plug Mini current power value of the load
|
|
459
|
-
currentPower?: number;
|
|
460
|
-
//Color Bulb's brightness level
|
|
461
|
-
brightness?: boolean | string;
|
|
462
|
-
};
|
|
463
|
-
|
|
464
|
-
export type temperature = {
|
|
465
|
-
c: number;
|
|
466
|
-
f: number;
|
|
467
|
-
};
|
|
468
|
-
|
|
469
|
-
export type switchbot = {
|
|
470
|
-
discover: (arg0: { duration?: any; model: string; quick: boolean; id?: MacAddress }) => Promise<any>;
|
|
471
|
-
wait: (arg0: number) => any;
|
|
472
|
-
};
|
|
473
|
-
|