Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Discover

The class to discover yeelight device on wifi network using UDP package

param

Yeelight Discover

param

samuraitruong@hotmail.com

Hierarchy

  • EventEmitter
    • Discover

Index

Constructors

constructor

  • Parameters

    • options: IDiscoverConfig

      discover object include the port and multicast host. see IDiscoverConfig for more detail

    • Optional logger: ILogger

      the application logger which implement of log, info, debug and error function

    Returns Discover

Properties

Private client

client: Socket

Private clientBound

clientBound: boolean = false

Private devices

devices: IDevice[]

Private isDestroyed

isDestroyed: boolean = false

Private options

options: IDiscoverConfig = ...

Private timer

timer: any

Static Readonly captureRejectionSymbol

captureRejectionSymbol: typeof captureRejectionSymbol

Static captureRejections

captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

Static defaultMaxListeners

defaultMaxListeners: number

Static Readonly errorMonitor

errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Methods

Private addDevice

  • Add the new discovered device into the internal list

    Parameters

    • device: IDevice

      the new device found from network

    Returns void

    return 0 if device already existing, 1 if new device added to the list

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): Discover
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Discover

destroy

  • destroy(): Promise<void>
  • Clean up resource and close all open connection, call this function after you finish your action to avoid memory leak

    Returns Promise<void>

    return a promise, fullfil will call after internal socket connection dropped

detectLightIP

  • detectLightIP(ipAddress: string): Promise<IDevice>
  • Try to verify if the light on and listening on the know ip address

    Parameters

    • ipAddress: string

      : know IP Address of the light.

    Returns Promise<IDevice>

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): (string | symbol)[]
  • Returns (string | symbol)[]

getMaxListeners

  • getMaxListeners(): number
  • Returns number

Private getMessage

  • getMessage(): Buffer
  • Generate the UDP message to discover device on local network.

    Returns Buffer

listenerCount

  • listenerCount(event: string | symbol): number
  • Parameters

    • event: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: (...args: any[]) => void): Discover
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Discover

on

  • on(event: string | symbol, listener: (...args: any[]) => void): Discover
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Discover

Private onError

  • onError(error: Error): void
  • Internal function to handle socket error

    Parameters

    • error: Error

      Error details

    Returns void

Private onSocketMessage

  • onSocketMessage(buffer: Buffer, addressInfo: AddressInfo): void
  • The event run when recieved the message devices

    Parameters

    • buffer: Buffer

      the buffer revieved from the socket

    • addressInfo: AddressInfo

    Returns void

once

  • once(event: string | symbol, listener: (...args: any[]) => void): Discover
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Discover

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): Discover
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Discover

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): Discover
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Discover

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • removeAllListeners(event?: string | symbol): Discover
  • Parameters

    • Optional event: string | symbol

    Returns Discover

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): Discover
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns Discover

scanByIp

  • Perfrom IP port scan to find an IP with port 55443 open rather than using SSDP discovery method

    requires

    {Promise<IDevice[]>} promise of list of device found

    Returns Promise<IDevice[]>

setMaxListeners

  • Parameters

    • n: number

    Returns Discover

start

  • The class to discover yeelight device on wifi network using UDP package You need to turn on "LAN Control" on phone app to get SSDP discover function work

    Returns Promise<IDevice[]>

    a promise that could resolve to 1 or many devices on the network

Static getEventListener

  • getEventListener(emitter: DOMEventTarget | EventEmitter, name: string | symbol): Function[]
  • Returns a list listener for a specific emitter event name.

    Parameters

    • emitter: DOMEventTarget | EventEmitter
    • name: string | symbol

    Returns Function[]

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Static on

  • on(emitter: EventEmitter, event: string, options?: StaticEventEmitterOptions): AsyncIterableIterator<any>
  • Parameters

    • emitter: EventEmitter
    • event: string
    • Optional options: StaticEventEmitterOptions

    Returns AsyncIterableIterator<any>

Static once

  • once(emitter: NodeEventTarget, event: string | symbol, options?: StaticEventEmitterOptions): Promise<any[]>
  • once(emitter: DOMEventTarget, event: string, options?: StaticEventEmitterOptions): Promise<any[]>
  • Parameters

    • emitter: NodeEventTarget
    • event: string | symbol
    • Optional options: StaticEventEmitterOptions

    Returns Promise<any[]>

  • Parameters

    • emitter: DOMEventTarget
    • event: string
    • Optional options: StaticEventEmitterOptions

    Returns Promise<any[]>

Generated using TypeDoc