node-switchbot
    Preparing search index...

    Class WoSmartLock

    Class representing a WoSmartLock device.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    encryption_key: null | Buffer<ArrayBufferLike> = null
    iv: null | Buffer<ArrayBufferLike> = null
    key_id: string = ''
    Result: { ERROR: number; SUCCESS: number; SUCCESS_LOW_BATTERY: number } = ...

    Accessors

    • get address(): string

      Returns string

    • get connectionState(): string

      Returns string

    • get id(): string

      Returns string

    • get onConnectHandler(): () => Promise<void>

      Returns () => Promise<void>

    • set onConnectHandler(func: () => Promise<void>): void

      Parameters

      • func: () => Promise<void>

      Returns void

    • get onDisconnectHandler(): () => Promise<void>

      Returns () => Promise<void>

    • set onDisconnectHandler(func: () => Promise<void>): void

      Parameters

      • func: () => Promise<void>

      Returns void

    Methods

    • Sends a command to the device and awaits a response.

      Parameters

      • reqBuf: Buffer

        The command buffer.

      Returns Promise<Buffer<ArrayBufferLike>>

      A Promise that resolves with the response buffer.

    • Decrypts a buffer using AES-128-CTR.

      Parameters

      • data: Buffer

        The data to decrypt.

      Returns Promise<Buffer<ArrayBufferLike>>

      • The decrypted data.
    • Encrypts a string using AES-128-CTR.

      Parameters

      • str: string

        The string to encrypt.

      Returns Promise<string>

      • The encrypted string in hex format.
    • Sends an encrypted command to the device.

      Parameters

      • key: string

        The command key.

      Returns Promise<Buffer<ArrayBufferLike>>

      • The response buffer.
    • Retrieves the IV from the device.

      Returns Promise<Buffer<ArrayBufferLike>>

      • The IV buffer.
    • Gets general state info from the Smart Lock.

      Returns Promise<null | object>

      • The state object or null if an error occurred.
    • Locks the Smart Lock.

      Returns Promise<number>

      • The result of the lock operation.
    • Logs a message with the specified log level.

      Parameters

      • level: string

        The severity level of the log (e.g., 'info', 'warn', 'error').

      • message: string

        The log message to be emitted.

      Returns Promise<void>

    • Operates the lock with the given command.

      Parameters

      • key: string

        The command key.

      • Optionalencrypt: boolean = true

        Whether to encrypt the command.

      Returns Promise<Buffer<ArrayBufferLike>>

      • The response buffer.
    • Sets the device name.

      Parameters

      • name: string

        The new device name.

      Returns Promise<void>

      A Promise that resolves when the name is set.

    • Initializes the encryption key info for valid lock communication.

      Parameters

      • keyId: string

        The key ID.

      • encryptionKey: string

        The encryption key.

      Returns Promise<void>

    • Unlocks the Smart Lock.

      Returns Promise<number>

      • The result of the unlock operation.
    • Unlocks the Smart Lock without unlatching the door.

      Returns Promise<number>

      • The result of the unlock operation.
    • Parameters

      • code: number

      Returns string

    • Parses the service data from the SwitchBot Strip Light.

      Parameters

      • serviceData: Buffer

        The service data buffer.

      • manufacturerData: Buffer

        The manufacturer data buffer.

      • emitLog: (level: string, message: string) => void

        The function to emit log messages.

      Returns Promise<null | lockServiceData>

      • Parsed service data or null if invalid.
    • Parameters

      • res: Buffer

      Returns Promise<number>