@switchbot/homebridge-switchbot 3.5.1-beta.12 → 3.5.1-beta.14
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/config.schema.json +19 -3
- package/dist/device/blindtilt.d.ts +6 -4
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +56 -44
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +6 -3
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +37 -23
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +6 -3
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +39 -20
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +6 -3
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +41 -30
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts +6 -3
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +39 -27
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +6 -4
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +34 -21
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +6 -3
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +54 -125
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts +6 -3
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +47 -28
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts +6 -3
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +42 -25
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts +6 -3
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +42 -25
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts +6 -3
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +38 -23
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +6 -3
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +42 -26
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts +6 -3
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +32 -21
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts +6 -3
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +37 -23
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts +6 -3
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +36 -23
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts +6 -3
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +32 -21
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts +6 -3
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +26 -15
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts +6 -3
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +33 -20
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts +6 -3
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +37 -22
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/airconditioner.d.ts.map +1 -1
- package/dist/irdevice/airconditioner.js +19 -72
- package/dist/irdevice/airconditioner.js.map +1 -1
- package/dist/irdevice/airpurifier.js +4 -4
- package/dist/irdevice/airpurifier.js.map +1 -1
- package/dist/irdevice/camera.d.ts.map +1 -1
- package/dist/irdevice/camera.js +3 -10
- package/dist/irdevice/camera.js.map +1 -1
- package/dist/irdevice/fan.d.ts.map +1 -1
- package/dist/irdevice/fan.js +7 -25
- package/dist/irdevice/fan.js.map +1 -1
- package/dist/irdevice/irdevice.d.ts +1 -1
- package/dist/irdevice/irdevice.js +2 -2
- package/dist/irdevice/irdevice.js.map +1 -1
- package/dist/irdevice/light.d.ts.map +1 -1
- package/dist/irdevice/light.js +9 -27
- package/dist/irdevice/light.js.map +1 -1
- package/dist/irdevice/other.js +1 -1
- package/dist/irdevice/other.js.map +1 -1
- package/dist/irdevice/tv.d.ts.map +1 -1
- package/dist/irdevice/tv.js +3 -18
- package/dist/irdevice/tv.js.map +1 -1
- package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
- package/dist/irdevice/vacuumcleaner.js +2 -9
- package/dist/irdevice/vacuumcleaner.js.map +1 -1
- package/dist/irdevice/waterheater.d.ts.map +1 -1
- package/dist/irdevice/waterheater.js +2 -9
- package/dist/irdevice/waterheater.js.map +1 -1
- package/dist/platform.d.ts +3 -5
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +13 -13
- package/dist/platform.js.map +1 -1
- package/dist/settings.d.ts +9 -8
- package/dist/settings.d.ts.map +1 -1
- package/dist/settings.js.map +1 -1
- package/dist/types/bledevicestatus.d.ts +2 -1
- package/dist/types/bledevicestatus.d.ts.map +1 -1
- package/dist/types/devicestatus.d.ts +1 -1
- package/dist/types/devicestatus.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/device/blindtilt.ts +59 -46
- package/src/device/bot.ts +46 -24
- package/src/device/ceilinglight.ts +51 -20
- package/src/device/colorbulb.ts +44 -30
- package/src/device/contact.ts +42 -27
- package/src/device/curtain.ts +44 -22
- package/src/device/device.ts +56 -112
- package/src/device/fan.ts +60 -29
- package/src/device/hub.ts +54 -28
- package/src/device/humidifier.ts +54 -30
- package/src/device/iosensor.ts +44 -26
- package/src/device/lightstrip.ts +47 -27
- package/src/device/lock.ts +48 -22
- package/src/device/meter.ts +53 -25
- package/src/device/meterplus.ts +49 -25
- package/src/device/motion.ts +44 -23
- package/src/device/plug.ts +33 -16
- package/src/device/robotvacuumcleaner.ts +48 -22
- package/src/device/waterdetector.ts +55 -24
- package/src/irdevice/airconditioner.ts +19 -65
- package/src/irdevice/airpurifier.ts +4 -4
- package/src/irdevice/camera.ts +4 -9
- package/src/irdevice/fan.ts +10 -22
- package/src/irdevice/irdevice.ts +2 -2
- package/src/irdevice/light.ts +10 -24
- package/src/irdevice/other.ts +1 -1
- package/src/irdevice/tv.ts +5 -16
- package/src/irdevice/vacuumcleaner.ts +3 -8
- package/src/irdevice/waterheater.ts +3 -8
- package/src/platform.ts +14 -14
- package/src/settings.ts +10 -8
- package/src/types/bledevicestatus.ts +4 -2
- package/src/types/devicestatus.ts +1 -1
package/src/platform.ts
CHANGED
|
@@ -40,17 +40,17 @@ import fakegato from 'fakegato-history';
|
|
|
40
40
|
import crypto, { randomUUID } from 'crypto';
|
|
41
41
|
import { readFileSync, writeFileSync } from 'fs';
|
|
42
42
|
import { EveHomeKitTypes } from 'homebridge-lib/EveHomeKitTypes';
|
|
43
|
+
import { PLATFORM_NAME, PLUGIN_NAME, Devices, deleteWebhook, queryWebhook, setupWebhook, updateWebhook } from './settings.js';
|
|
43
44
|
import { isBlindTiltDevice, isCurtainDevice, sleep } from './utils.js';
|
|
44
|
-
import { PLATFORM_NAME, PLUGIN_NAME, Devices, setupWebhook, updateWebhook, deleteWebhook, queryWebhook } from './settings.js';
|
|
45
45
|
|
|
46
46
|
import type { UrlObject } from 'url';
|
|
47
47
|
import type { MqttClient } from 'mqtt';
|
|
48
48
|
import type { Dispatcher } from 'undici';
|
|
49
49
|
import type { irdevice } from './types/irdevicelist.js';
|
|
50
|
-
import type { Server, IncomingMessage, ServerResponse } from 'http';
|
|
51
50
|
import type { blindTilt, curtain, curtain3, device } from './types/devicelist.js';
|
|
52
51
|
import type { API, DynamicPlatformPlugin, Logging, PlatformAccessory } from 'homebridge';
|
|
53
52
|
import type { SwitchBotPlatformConfig, devicesConfig, irDevicesConfig } from './settings.js';
|
|
53
|
+
import type { IncomingMessage, Server, ServerResponse } from 'http';
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* HomebridgePlatform
|
|
@@ -71,11 +71,11 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
71
71
|
platformLogging!: SwitchBotPlatformConfig['logging'];
|
|
72
72
|
config!: SwitchBotPlatformConfig;
|
|
73
73
|
|
|
74
|
-
webhookEventListener: Server | null = null;
|
|
75
74
|
mqttClient: MqttClient | null = null;
|
|
75
|
+
webhookEventListener: Server | null = null;
|
|
76
76
|
|
|
77
|
-
public readonly fakegatoAPI: any;
|
|
78
77
|
public readonly eve: any;
|
|
78
|
+
public readonly fakegatoAPI: any;
|
|
79
79
|
public readonly webhookEventHandler: { [x: string]: (context: any) => void } = {};
|
|
80
80
|
|
|
81
81
|
constructor(
|
|
@@ -2678,10 +2678,10 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2678
2678
|
await this.errorLog(`Requests reached the daily limit, statusCode: ${statusCode}`);
|
|
2679
2679
|
break;
|
|
2680
2680
|
case 100:
|
|
2681
|
-
await
|
|
2681
|
+
await this.debugLog(`Command successfully sent, statusCode: ${statusCode}`);
|
|
2682
2682
|
break;
|
|
2683
2683
|
case 200:
|
|
2684
|
-
await
|
|
2684
|
+
await this.debugLog(`Request successful, statusCode: ${statusCode}`);
|
|
2685
2685
|
break;
|
|
2686
2686
|
case 400:
|
|
2687
2687
|
await this.errorLog('Bad Request, The client has issued an invalid request. This is commonly used to specify validation errors in a request '
|
|
@@ -2735,13 +2735,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2735
2735
|
if (statusCode === 200 || statusCode === 100) {
|
|
2736
2736
|
return { body, statusCode };
|
|
2737
2737
|
} else {
|
|
2738
|
-
await
|
|
2738
|
+
await this.debugLog(`Received status code: ${statusCode}`);
|
|
2739
2739
|
}
|
|
2740
2740
|
} catch (error: any) {
|
|
2741
2741
|
await this.errorLog(`Error making request: ${error.message}`);
|
|
2742
2742
|
}
|
|
2743
2743
|
retryCount++;
|
|
2744
|
-
await
|
|
2744
|
+
await this.debugLog(`Retry attempt ${retryCount} of ${maxRetries}`);
|
|
2745
2745
|
await sleep(delayBetweenRetries);
|
|
2746
2746
|
}
|
|
2747
2747
|
return { body: null, statusCode: -1 };
|
|
@@ -2753,7 +2753,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2753
2753
|
try {
|
|
2754
2754
|
const SwitchBot = (await import('node-switchbot')).SwitchBot;
|
|
2755
2755
|
queueScheduler.schedule(() => (switchbot = new SwitchBot()));
|
|
2756
|
-
await
|
|
2756
|
+
await this.debugLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' found: ${switchbot}`);
|
|
2757
2757
|
} catch (e: any) {
|
|
2758
2758
|
switchbot = false;
|
|
2759
2759
|
await this.errorLog(`${device.deviceType}: ${accessory.displayName} 'node-switchbot' found: ${switchbot}, Error: ${e}`);
|
|
@@ -2768,7 +2768,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2768
2768
|
'utf-8',
|
|
2769
2769
|
),
|
|
2770
2770
|
);
|
|
2771
|
-
await
|
|
2771
|
+
await this.debugLog(`Plugin Version: ${json.version}`);
|
|
2772
2772
|
this.version = json.version;
|
|
2773
2773
|
}
|
|
2774
2774
|
|
|
@@ -2804,7 +2804,7 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2804
2804
|
platformConfig.delayBetweenRetries = this.delayBetweenRetries / 1000;
|
|
2805
2805
|
}
|
|
2806
2806
|
if (Object.entries(platformConfig).length !== 0) {
|
|
2807
|
-
await
|
|
2807
|
+
await this.debugLog(`Platform Config: ${JSON.stringify(platformConfig)}`);
|
|
2808
2808
|
}
|
|
2809
2809
|
this.platformConfig = platformConfig;
|
|
2810
2810
|
}
|
|
@@ -2814,13 +2814,13 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
2814
2814
|
this.debugMode = process.argv.includes('-D') || process.argv.includes('--debug');
|
|
2815
2815
|
if (this.config.options?.logging === 'debug' || this.config.options?.logging === 'standard' || this.config.options?.logging === 'none') {
|
|
2816
2816
|
this.platformLogging = this.config.options.logging;
|
|
2817
|
-
await
|
|
2817
|
+
await this.debugWarnLog(`Using Config Logging: ${this.platformLogging}`);
|
|
2818
2818
|
} else if (this.debugMode) {
|
|
2819
2819
|
this.platformLogging = 'debugMode';
|
|
2820
|
-
await
|
|
2820
|
+
await this.debugWarnLog(`Using ${this.platformLogging} Logging`);
|
|
2821
2821
|
} else {
|
|
2822
2822
|
this.platformLogging = 'standard';
|
|
2823
|
-
await
|
|
2823
|
+
await this.debugWarnLog(`Using ${this.platformLogging} Logging`);
|
|
2824
2824
|
}
|
|
2825
2825
|
}
|
|
2826
2826
|
|
package/src/settings.ts
CHANGED
|
@@ -56,18 +56,18 @@ interface credentials {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
interface options {
|
|
59
|
-
refreshRate?: number;
|
|
60
|
-
updateRate?: number;
|
|
61
|
-
pushRate?: number;
|
|
62
|
-
maxRetries?: number;
|
|
63
|
-
delayBetweenRetries?: number;
|
|
64
|
-
logging?: string;
|
|
65
59
|
devices?: devicesConfig[];
|
|
66
60
|
irdevices?: irDevicesConfig[];
|
|
67
|
-
webhookURL?: string;
|
|
68
61
|
mqttURL?: string;
|
|
69
62
|
mqttOptions?: IClientOptions;
|
|
70
63
|
mqttPubOptions?: IClientOptions;
|
|
64
|
+
webhookURL?: string;
|
|
65
|
+
maxRetries?: number;
|
|
66
|
+
delayBetweenRetries?: number;
|
|
67
|
+
refreshRate?: number;
|
|
68
|
+
updateRate?: number;
|
|
69
|
+
pushRate?: number;
|
|
70
|
+
logging?: string;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
export interface devicesConfig extends device {
|
|
@@ -111,7 +111,7 @@ export interface devicesConfig extends device {
|
|
|
111
111
|
colorbulb?: colorbulb;
|
|
112
112
|
striplight?: striplight;
|
|
113
113
|
ceilinglight?: ceilinglight;
|
|
114
|
-
plug?:
|
|
114
|
+
plug?: plug;
|
|
115
115
|
lock?: lock;
|
|
116
116
|
hub?: hub;
|
|
117
117
|
}
|
|
@@ -198,6 +198,8 @@ interface ceilinglight {
|
|
|
198
198
|
adaptiveLightingShift?: number;
|
|
199
199
|
};
|
|
200
200
|
|
|
201
|
+
type plug = object;
|
|
202
|
+
|
|
201
203
|
interface lock {
|
|
202
204
|
hide_contactsensor?: boolean;
|
|
203
205
|
activate_latchbutton?: boolean;
|
|
@@ -16,8 +16,9 @@ export type ad = {
|
|
|
16
16
|
rssi: number;
|
|
17
17
|
serviceData: botServiceData | colorBulbServiceData | contactSensorServiceData |
|
|
18
18
|
curtainServiceData | curtain3ServiceData | stripLightServiceData | lockServiceData |
|
|
19
|
-
lockProServiceData | meterServiceData | meterPlusServiceData | motionSensorServiceData |
|
|
20
|
-
plugMiniUSServiceData | plugMiniJPServiceData | blindTiltServiceData
|
|
19
|
+
lockProServiceData | meterServiceData | meterPlusServiceData | motionSensorServiceData | outdoorMeterServiceData |
|
|
20
|
+
plugMiniUSServiceData | plugMiniJPServiceData | blindTiltServiceData | ceilingLightServiceData | ceilingLightProServiceData |
|
|
21
|
+
hub2ServiceData | batteryCirculatorFanServiceData | waterLeakDetectorServiceData | humidifierServiceData | robotVacuumCleanerServiceData;
|
|
21
22
|
};
|
|
22
23
|
|
|
23
24
|
type serviceData = {
|
|
@@ -271,6 +272,7 @@ export type batteryCirculatorFanServiceData = serviceData & {
|
|
|
271
272
|
modelName: SwitchBotBLEModelName.Unknown,
|
|
272
273
|
modelFriendlyName: SwitchBotBLEModelFriendlyName.Unknown,
|
|
273
274
|
state: string;
|
|
275
|
+
fanSpeed: number;
|
|
274
276
|
};
|
|
275
277
|
|
|
276
278
|
export type waterLeakDetectorServiceData = serviceData & {
|
|
@@ -154,7 +154,7 @@ export type humidifierStatus = deviceStatus & {
|
|
|
154
154
|
|
|
155
155
|
export type blindTiltStatus = deviceStatus & {
|
|
156
156
|
calibrate: boolean;
|
|
157
|
-
battery:
|
|
157
|
+
battery: number;
|
|
158
158
|
direction: string;
|
|
159
159
|
slidePosition: string;
|
|
160
160
|
lightLevel?: 'bright' | 'dim';
|