Class WoCeilingLight

Class representing a WoCeilingLight device.

Hierarchy (View Summary)

Constructors

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

      The command buffer.

    Returns Promise<Buffer<ArrayBufferLike>>

    A Promise that resolves with the response buffer.

  • Connects to the device.

    Returns Promise<void>

    A Promise that resolves when the connection is complete.

  • Disconnects from the device.

    Returns Promise<void>

    A Promise that resolves when the disconnection is complete.

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

  • Sends a command to the ceiling light.

    Parameters

    • bytes: number[]

      The command bytes.

    Returns Promise<boolean>

    • Resolves with a boolean indicating whether the operation was successful.
  • Reads the state of the ceiling light.

    Returns Promise<boolean>

    • Resolves with a boolean indicating whether the light is ON (true) or OFF (false).
  • Sets the brightness of the ceiling light.

    Parameters

    • brightness: number

      The brightness percentage (0-100).

    Returns Promise<boolean>

    • Resolves with a boolean indicating whether the operation was successful.
  • Sets the color temperature of the ceiling light.

    Parameters

    • color_temperature: number

      The color temperature percentage (0-100).

    Returns Promise<boolean>

    • Resolves with a boolean indicating whether the operation was successful.
  • Sets the device name.

    Parameters

    • name: string

      The new device name.

    Returns Promise<void>

    A Promise that resolves when the name is set.

  • Sets the RGB color of the ceiling light.

    Parameters

    • brightness: number

      The brightness percentage (0-100).

    • red: number

      The red color value (0-255).

    • green: number

      The green color value (0-255).

    • blue: number

      The blue color value (0-255).

    Returns Promise<boolean>

    • Resolves with a boolean indicating whether the operation was successful.
  • Sets the state of the ceiling light.

    Parameters

    • reqByteArray: number[]

      The request byte array.

    Returns Promise<boolean>

    • Resolves with a boolean indicating whether the operation was successful.
  • Turns off the ceiling light.

    Returns Promise<boolean>

    • Resolves with a boolean indicating whether the light is OFF (false).
  • Turns on the ceiling light.

    Returns Promise<boolean>

    • Resolves with a boolean indicating whether the light is ON (true).
  • Parses the service data for WoCeilingLight.

    Parameters

    • manufacturerData: Buffer<ArrayBufferLike>

      The manufacturer data buffer.

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

      The function to emit log messages.

    Returns Promise<null | ceilingLightServiceData>

    • Parsed service data or null if invalid.
  • Parses the service data for WoCeilingLight Pro.

    Parameters

    • manufacturerData: Buffer<ArrayBufferLike>

      The manufacturer data buffer.

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

      The function to emit log messages.

    Returns Promise<null | ceilingLightProServiceData>

    • Parsed service data or null if invalid.