@switchbot/homebridge-switchbot 3.6.1-beta.1 → 3.6.1-beta.10
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 +11 -0
- package/dist/device/blindtilt.d.ts.map +1 -1
- package/dist/device/blindtilt.js +35 -17
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.d.ts +1 -2
- package/dist/device/bot.d.ts.map +1 -1
- package/dist/device/bot.js +186 -396
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.d.ts +3 -2
- package/dist/device/ceilinglight.d.ts.map +1 -1
- package/dist/device/ceilinglight.js +56 -31
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.d.ts +3 -2
- package/dist/device/colorbulb.d.ts.map +1 -1
- package/dist/device/colorbulb.js +57 -29
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.d.ts.map +1 -1
- package/dist/device/contact.js +35 -18
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +7 -5
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +9 -0
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +30 -3
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.d.ts.map +1 -1
- package/dist/device/fan.js +35 -18
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.d.ts.map +1 -1
- package/dist/device/hub.js +37 -18
- package/dist/device/hub.js.map +1 -1
- package/dist/device/humidifier.d.ts.map +1 -1
- package/dist/device/humidifier.js +39 -20
- package/dist/device/humidifier.js.map +1 -1
- package/dist/device/iosensor.d.ts.map +1 -1
- package/dist/device/iosensor.js +37 -18
- package/dist/device/iosensor.js.map +1 -1
- package/dist/device/lightstrip.d.ts +4 -3
- package/dist/device/lightstrip.d.ts.map +1 -1
- package/dist/device/lightstrip.js +57 -31
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.d.ts.map +1 -1
- package/dist/device/lock.js +36 -17
- package/dist/device/lock.js.map +1 -1
- package/dist/device/meter.d.ts.map +1 -1
- package/dist/device/meter.js +37 -18
- package/dist/device/meter.js.map +1 -1
- package/dist/device/meterplus.d.ts.map +1 -1
- package/dist/device/meterplus.js +37 -18
- package/dist/device/meterplus.js.map +1 -1
- package/dist/device/motion.d.ts.map +1 -1
- package/dist/device/motion.js +35 -16
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +36 -17
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
- package/dist/device/robotvacuumcleaner.js +35 -16
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/dist/device/waterdetector.d.ts.map +1 -1
- package/dist/device/waterdetector.js +35 -16
- package/dist/device/waterdetector.js.map +1 -1
- package/dist/irdevice/other.d.ts +1 -0
- package/dist/irdevice/other.d.ts.map +1 -1
- package/dist/irdevice/other.js +186 -228
- package/dist/irdevice/other.js.map +1 -1
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +11 -2
- package/dist/platform.js.map +1 -1
- package/dist/types/bledevicestatus.d.ts +1 -0
- package/dist/types/bledevicestatus.d.ts.map +1 -1
- package/dist/utils.d.ts +8 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +16 -0
- package/dist/utils.js.map +1 -1
- package/package.json +6 -6
- package/src/device/blindtilt.ts +32 -17
- package/src/device/bot.ts +179 -406
- package/src/device/ceilinglight.ts +53 -33
- package/src/device/colorbulb.ts +55 -31
- package/src/device/contact.ts +32 -19
- package/src/device/curtain.ts +7 -6
- package/src/device/device.ts +36 -3
- package/src/device/fan.ts +32 -19
- package/src/device/hub.ts +34 -18
- package/src/device/humidifier.ts +36 -20
- package/src/device/iosensor.ts +34 -18
- package/src/device/lightstrip.ts +56 -33
- package/src/device/lock.ts +33 -17
- package/src/device/meter.ts +34 -18
- package/src/device/meterplus.ts +34 -18
- package/src/device/motion.ts +32 -16
- package/src/device/plug.ts +33 -17
- package/src/device/robotvacuumcleaner.ts +32 -16
- package/src/device/waterdetector.ts +32 -16
- package/src/irdevice/other.ts +214 -283
- package/src/platform.ts +11 -2
- package/src/types/bledevicestatus.ts +1 -0
- package/src/utils.ts +15 -0
package/src/platform.ts
CHANGED
|
@@ -330,12 +330,21 @@ export class SwitchBotPlatform implements DynamicPlatformPlugin {
|
|
|
330
330
|
// Set an event handler to monitor advertisement packets
|
|
331
331
|
switchbot.onadvertisement = async (ad: any) => {
|
|
332
332
|
try {
|
|
333
|
-
this.bleEventHandler[ad.
|
|
333
|
+
this.bleEventHandler[ad.address]?.(ad.serviceData);
|
|
334
334
|
} catch (e: any) {
|
|
335
|
-
this.errorLog(`Failed to handle BLE event. Error:${e}`);
|
|
335
|
+
await this.errorLog(`Failed to handle BLE event. Error:${e}`);
|
|
336
336
|
}
|
|
337
337
|
};
|
|
338
338
|
})();
|
|
339
|
+
|
|
340
|
+
this.api.on('shutdown', async () => {
|
|
341
|
+
try {
|
|
342
|
+
switchbot.stopScan();
|
|
343
|
+
this.infoLog('Stopped BLE scanning to close listening.');
|
|
344
|
+
} catch (e: any) {
|
|
345
|
+
this.errorLog(`Failed to stop Platform BLE scanning. Error:${e.message}`);
|
|
346
|
+
}
|
|
347
|
+
});
|
|
339
348
|
}
|
|
340
349
|
} else {
|
|
341
350
|
await this.debugLog('Platform BLE is not enabled');
|
package/src/utils.ts
CHANGED
|
@@ -129,6 +129,21 @@ export function isBlindTiltDevice(device: device & devicesConfig): device is bli
|
|
|
129
129
|
export function sleep(ms: number): Promise<void> {
|
|
130
130
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
131
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Check if the humidity is within the min and max range
|
|
134
|
+
* @param humidity - The humidity value
|
|
135
|
+
* @param min - The minimum humidity value
|
|
136
|
+
* @param max - The maximum humidity value
|
|
137
|
+
* @returns The humidity value
|
|
138
|
+
**/
|
|
139
|
+
export function validHumidity(humidity: number, min?: number, max?: number): number {
|
|
140
|
+
if (humidity < (min || 0)) {
|
|
141
|
+
return min ?? 0;
|
|
142
|
+
} else if (humidity > (max || 100)) {
|
|
143
|
+
return max ?? 100;
|
|
144
|
+
}
|
|
145
|
+
return humidity;
|
|
146
|
+
}
|
|
132
147
|
|
|
133
148
|
/**
|
|
134
149
|
* Converts the value to celsius if the temperature units are in Fahrenheit
|