From 1071eea00f26abde0682329a7077adba58928aee Mon Sep 17 00:00:00 2001 From: Dave Nicolson Date: Sun, 4 Feb 2024 22:09:45 +0100 Subject: [PATCH] Fix BLE curtain mode (#908) ## :recycle: Current situation If the curtain mode was not defined in the settings the following error would occur: ``` Curtain: Curtain failed BLEpushChanges with BLE Connection, Error Message: "The type of running mode is incorrect: object" ``` ## :bulb: Proposed solution - Set position mode to strings - Remove redundant code - Set proper values for node-switchbot Co-authored-by: Donavan Becker --- src/device/curtain.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/device/curtain.ts b/src/device/curtain.ts index 42e42a84..997487fc 100644 --- a/src/device/curtain.ts +++ b/src/device/curtain.ts @@ -36,9 +36,9 @@ export class Curtain { OpenAPI_CurrentPosition: deviceStatus['slidePosition']; OpenAPI_CurrentAmbientLightLevel: deviceStatus['brightness']; - // OpenAPI Others + // Others Mode!: string; - setPositionMode?: string | number; + setPositionMode?: string; // BLE Status BLE_InMotion: serviceData['inMotion']; @@ -662,10 +662,7 @@ export class Curtain { .toLowerCase(); this.debugLog(`${this.device.deviceType}: ${this.accessory.displayName} BLE Address: ${this.device.bleMac}`); this.SilentPerformance(); - const adjustedMode = this.setPositionMode || null; - if (adjustedMode === null) { - this.Mode = 'Default Mode'; - } + const adjustedMode = this.setPositionMode == '1' ? 0x01 : 0xff; this.debugLog(`${this.accessory.displayName} Mode: ${this.Mode}`); if (switchbot !== false) { try { @@ -1016,18 +1013,18 @@ export class Curtain { async SilentPerformance() { if (Number(this.TargetPosition) > 50) { if (this.device.curtain?.setOpenMode === '1') { - this.setPositionMode = 1; + this.setPositionMode = '1'; this.Mode = 'Silent Mode'; } else { - this.setPositionMode = 0; + this.setPositionMode = '0'; this.Mode = 'Performance Mode'; } } else { if (this.device.curtain?.setCloseMode === '1') { - this.setPositionMode = 1; + this.setPositionMode = '1'; this.Mode = 'Silent Mode'; } else { - this.setPositionMode = 0; + this.setPositionMode = '0'; this.Mode = 'Performance Mode'; } }