@switchbot/homebridge-switchbot 4.1.1-beta.3 → 4.1.1-beta.4
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 +14 -0
- package/dist/device/blindtilt.js +3 -3
- package/dist/device/blindtilt.js.map +1 -1
- package/dist/device/bot.js +1 -1
- package/dist/device/bot.js.map +1 -1
- package/dist/device/ceilinglight.js +1 -1
- package/dist/device/ceilinglight.js.map +1 -1
- package/dist/device/colorbulb.js +1 -1
- package/dist/device/colorbulb.js.map +1 -1
- package/dist/device/contact.js +3 -3
- package/dist/device/contact.js.map +1 -1
- package/dist/device/curtain.d.ts +1 -1
- package/dist/device/curtain.d.ts.map +1 -1
- package/dist/device/curtain.js +11 -9
- package/dist/device/curtain.js.map +1 -1
- package/dist/device/device.d.ts +3 -3
- package/dist/device/device.d.ts.map +1 -1
- package/dist/device/device.js +3 -3
- package/dist/device/device.js.map +1 -1
- package/dist/device/fan.js +1 -1
- package/dist/device/fan.js.map +1 -1
- package/dist/device/hub.js +3 -3
- package/dist/device/hub.js.map +1 -1
- package/dist/device/lightstrip.js +1 -1
- package/dist/device/lightstrip.js.map +1 -1
- package/dist/device/lock.js +1 -1
- package/dist/device/lock.js.map +1 -1
- package/dist/device/motion.js +2 -2
- package/dist/device/motion.js.map +1 -1
- package/dist/device/plug.d.ts.map +1 -1
- package/dist/device/plug.js +1 -1
- package/dist/device/plug.js.map +1 -1
- package/dist/device/robotvacuumcleaner.js +1 -1
- package/dist/device/robotvacuumcleaner.js.map +1 -1
- package/package.json +9 -9
- package/src/device/blindtilt.ts +3 -3
- package/src/device/bot.ts +1 -1
- package/src/device/ceilinglight.ts +1 -1
- package/src/device/colorbulb.ts +1 -1
- package/src/device/contact.ts +3 -3
- package/src/device/curtain.ts +11 -9
- package/src/device/device.ts +3 -3
- package/src/device/fan.ts +1 -1
- package/src/device/hub.ts +3 -3
- package/src/device/lightstrip.ts +1 -1
- package/src/device/lock.ts +1 -1
- package/src/device/motion.ts +2 -2
- package/src/device/plug.ts +3 -3
- package/src/device/robotvacuumcleaner.ts +1 -1
package/src/device/device.ts
CHANGED
|
@@ -129,8 +129,8 @@ export abstract class deviceBase {
|
|
|
129
129
|
})
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
maxRetryBLE(): number {
|
|
133
|
-
return this.device.maxRetry ? this.device.maxRetry : 5
|
|
132
|
+
async maxRetryBLE(): Promise<number> {
|
|
133
|
+
return this.device.maxRetry !== undefined ? this.device.maxRetry : 5
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
async getDeviceScanDuration(accessory: PlatformAccessory, device: device & devicesConfig): Promise<void> {
|
|
@@ -253,7 +253,7 @@ export abstract class deviceBase {
|
|
|
253
253
|
* @param spaceBetweenLevels number
|
|
254
254
|
* @returns CurrentAmbientLightLevel
|
|
255
255
|
*/
|
|
256
|
-
|
|
256
|
+
getLightLevel(lightLevel: number, set_minLux: number, set_maxLux: number, spaceBetweenLevels: number): number {
|
|
257
257
|
const numberOfLevels = spaceBetweenLevels + 1
|
|
258
258
|
this.debugLog(`LightLevel: ${lightLevel}, set_minLux: ${set_minLux}, set_maxLux: ${set_maxLux}, spaceBetweenLevels: ${spaceBetweenLevels}, numberOfLevels: ${numberOfLevels}`)
|
|
259
259
|
const CurrentAmbientLightLevel = lightLevel === 1
|
package/src/device/fan.ts
CHANGED
|
@@ -462,7 +462,7 @@ export class Fan extends deviceBase {
|
|
|
462
462
|
.then(async (device_list: SwitchbotDevice[]) => {
|
|
463
463
|
const deviceList = device_list as unknown as SwitchbotDevice[]
|
|
464
464
|
return await this.retryBLE({
|
|
465
|
-
max: this.maxRetryBLE(),
|
|
465
|
+
max: await this.maxRetryBLE(),
|
|
466
466
|
fn: async () => {
|
|
467
467
|
if (this.Fan.Active) {
|
|
468
468
|
return await deviceList[0].turnOn()
|
package/src/device/hub.ts
CHANGED
|
@@ -194,7 +194,7 @@ export class Hub extends deviceBase {
|
|
|
194
194
|
const set_minLux = (this.device as hubConfig).set_minLux ?? 1
|
|
195
195
|
const set_maxLux = (this.device as hubConfig).set_maxLux ?? 6001
|
|
196
196
|
const lightLevel = this.serviceData.lightLevel
|
|
197
|
-
this.LightSensor.CurrentAmbientLightLevel =
|
|
197
|
+
this.LightSensor.CurrentAmbientLightLevel = this.getLightLevel(lightLevel, set_minLux, set_maxLux, 19)
|
|
198
198
|
this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`)
|
|
199
199
|
}
|
|
200
200
|
}
|
|
@@ -220,7 +220,7 @@ export class Hub extends deviceBase {
|
|
|
220
220
|
const set_minLux = (this.device as hubConfig).set_minLux ?? 1
|
|
221
221
|
const set_maxLux = (this.device as hubConfig).set_maxLux ?? 6001
|
|
222
222
|
const lightLevel = this.deviceStatus.lightLevel
|
|
223
|
-
this.LightSensor.CurrentAmbientLightLevel =
|
|
223
|
+
this.LightSensor.CurrentAmbientLightLevel = this.getLightLevel(lightLevel, set_minLux, set_maxLux, 19)
|
|
224
224
|
this.debugLog(`LightLevel: ${this.deviceStatus.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor!.CurrentAmbientLightLevel}`)
|
|
225
225
|
}
|
|
226
226
|
|
|
@@ -264,7 +264,7 @@ export class Hub extends deviceBase {
|
|
|
264
264
|
if (!(this.device as hubConfig).hide_lightsensor && this.LightSensor?.Service) {
|
|
265
265
|
const set_minLux = (this.device as hubConfig).set_minLux ?? 1
|
|
266
266
|
const set_maxLux = (this.device as hubConfig).set_maxLux ?? 6001
|
|
267
|
-
this.LightSensor.CurrentAmbientLightLevel =
|
|
267
|
+
this.LightSensor.CurrentAmbientLightLevel = this.getLightLevel(this.webhookContext.lightLevel, set_minLux, set_maxLux, 19)
|
|
268
268
|
this.debugLog(`CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`)
|
|
269
269
|
}
|
|
270
270
|
}
|
package/src/device/lightstrip.ts
CHANGED
|
@@ -468,7 +468,7 @@ export class StripLight extends deviceBase {
|
|
|
468
468
|
const deviceList = device_list as unknown as WoStrip[]
|
|
469
469
|
this.infoLog(`On: ${this.LightBulb.On}`)
|
|
470
470
|
return await this.retryBLE({
|
|
471
|
-
max: this.maxRetryBLE(),
|
|
471
|
+
max: await this.maxRetryBLE(),
|
|
472
472
|
fn: async () => {
|
|
473
473
|
if (this.LightBulb.On) {
|
|
474
474
|
return await deviceList[0].turnOn()
|
package/src/device/lock.ts
CHANGED
|
@@ -447,7 +447,7 @@ export class Lock extends deviceBase {
|
|
|
447
447
|
.discover({ model: this.device.bleModel, id: this.device.bleMac })
|
|
448
448
|
.then(async (device_list: SwitchbotDevice[]) => {
|
|
449
449
|
return await this.retryBLE({
|
|
450
|
-
max: this.maxRetryBLE(),
|
|
450
|
+
max: await this.maxRetryBLE(),
|
|
451
451
|
fn: async () => {
|
|
452
452
|
if (this.LockMechanism.LockTargetState === this.hap.Characteristic.LockTargetState.SECURED) {
|
|
453
453
|
return await device_list[0].lock({ id: this.device.bleMac })
|
package/src/device/motion.ts
CHANGED
|
@@ -168,7 +168,7 @@ export class Motion extends deviceBase {
|
|
|
168
168
|
const set_minLux = (this.device as motionConfig).set_minLux ?? 1
|
|
169
169
|
const set_maxLux = (this.device as motionConfig).set_maxLux ?? 6001
|
|
170
170
|
const lightLevel = this.serviceData.lightLevel === 'bright' ? set_maxLux : set_minLux
|
|
171
|
-
this.LightSensor.CurrentAmbientLightLevel =
|
|
171
|
+
this.LightSensor.CurrentAmbientLightLevel = this.getLightLevel(lightLevel, set_minLux, set_maxLux, 2)
|
|
172
172
|
this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`)
|
|
173
173
|
}
|
|
174
174
|
|
|
@@ -196,7 +196,7 @@ export class Motion extends deviceBase {
|
|
|
196
196
|
const set_minLux = (this.device as motionConfig).set_minLux ?? 1
|
|
197
197
|
const set_maxLux = (this.device as motionConfig).set_maxLux ?? 6001
|
|
198
198
|
const lightLevel = this.deviceStatus.brightness === 'bright' ? set_maxLux : set_minLux
|
|
199
|
-
this.LightSensor.CurrentAmbientLightLevel =
|
|
199
|
+
this.LightSensor.CurrentAmbientLightLevel = this.getLightLevel(lightLevel, set_minLux, set_maxLux, 2)
|
|
200
200
|
this.debugLog(`LightLevel: ${this.deviceStatus.brightness}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`)
|
|
201
201
|
}
|
|
202
202
|
// BatteryLevel
|
package/src/device/plug.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* plug.ts: @switchbot/homebridge-switchbot.
|
|
4
4
|
*/
|
|
5
5
|
import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
|
|
6
|
-
import type { bodyChange, device, plugMiniJPServiceData, plugMiniJPWebhookContext, plugMiniStatus, plugMiniUSServiceData, plugMiniUSWebhookContext, plugStatus, plugWebhookContext, SwitchbotDevice,
|
|
6
|
+
import type { bodyChange, device, plugMiniJPServiceData, plugMiniJPWebhookContext, plugMiniStatus, plugMiniUSServiceData, plugMiniUSWebhookContext, plugStatus, plugWebhookContext, SwitchbotDevice, WoPlugMiniUS } from 'node-switchbot'
|
|
7
7
|
|
|
8
8
|
import type { SwitchBotPlatform } from '../platform.js'
|
|
9
9
|
import type { devicesConfig } from '../settings.js'
|
|
@@ -307,10 +307,10 @@ export class Plug extends deviceBase {
|
|
|
307
307
|
switchBotBLE
|
|
308
308
|
.discover({ model: this.device.bleModel, id: this.device.bleMac })
|
|
309
309
|
.then(async (device_list: SwitchbotDevice[]) => {
|
|
310
|
-
const deviceList = device_list as unknown as
|
|
310
|
+
const deviceList = device_list as unknown as WoPlugMiniUS[]
|
|
311
311
|
this.infoLog(`On: ${this.Outlet.On}`)
|
|
312
312
|
return await this.retryBLE({
|
|
313
|
-
max: this.maxRetryBLE(),
|
|
313
|
+
max: await this.maxRetryBLE(),
|
|
314
314
|
fn: async () => {
|
|
315
315
|
if (this.Outlet.On) {
|
|
316
316
|
return await deviceList[0].turnOn()
|
|
@@ -393,7 +393,7 @@ export class RobotVacuumCleaner extends deviceBase {
|
|
|
393
393
|
const deviceList = device_list as unknown as SwitchbotDevice[]
|
|
394
394
|
this.infoLog(`On: ${this.LightBulb.On}`)
|
|
395
395
|
return await this.retryBLE({
|
|
396
|
-
max: this.maxRetryBLE(),
|
|
396
|
+
max: await this.maxRetryBLE(),
|
|
397
397
|
fn: async () => {
|
|
398
398
|
if (this.LightBulb.On) {
|
|
399
399
|
return await deviceList[0].turnOn()
|