Class representing a WoBulb device.

Hierarchy (view full)

Constructors

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.

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

  • Reads the state of the bulb.

    Returns Promise<boolean>

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

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

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

    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.
  • Turns off the bulb.

    Returns Promise<boolean>

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

    Returns Promise<boolean>

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

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

    • Parsed service data or null if invalid.