Class WoSmartLockPro

Class representing a WoSmartLockPro device.

Hierarchy (view full)

Constructors

Properties

encryption_key: null | Buffer = null
iv: null | Buffer = 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>)

      • (): Promise<void>
      • Returns Promise<void>

  • set onConnectHandler(func): void
  • Parameters

    • func: (() => Promise<void>)
        • (): Promise<void>
        • Returns Promise<void>

    Returns void

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

      • (): Promise<void>
      • Returns Promise<void>

  • set onDisconnectHandler(func): void
  • Parameters

    • func: (() => Promise<void>)
        • (): Promise<void>
        • Returns Promise<void>

    Returns void

Methods

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

    Parameters

    • reqBuf: Buffer

      The command buffer.

    Returns Promise<Buffer>

    A Promise that resolves with the response buffer.

  • Connects to the device.

    Returns Promise<void>

    A Promise that resolves when the connection is complete.

  • Decrypts a buffer using AES-128-CTR.

    Parameters

    • data: Buffer

      The data to decrypt.

    Returns Promise<Buffer>

    • The decrypted data.
  • Disconnects from the device.

    Returns Promise<void>

    A Promise that resolves when the disconnection is complete.

  • 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>

    • The response 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>

    • 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.
  • 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.

        • (level, message): void
        • Parameters

          • level: string
          • message: string

          Returns void

    Returns Promise<null | lockProServiceData>

    • Parsed service data or null if invalid.