Table of Contents

Method WaitForDeviceAsync

Namespace
Yeelight
Assembly
YeelightClient.dll

WaitForDeviceAsync(string, TimeSpan, CancellationToken)

Waits until a light is found, when it is not yet: look for lights first (StartDiscovery(TimeSpan?), StartListening() or ProbeAsync(IPAddress, CancellationToken)).

public Task<YeelightDevice> WaitForDeviceAsync(string id, TimeSpan timeout, CancellationToken cancellationToken = default)

Parameters

id string

The id of the light, for example 0x000000000015243f (the case does not matter).

timeout TimeSpan

How long to wait, or InfiniteTimeSpan to wait until the light is found (or the token is cancelled, or the client disposed).

cancellationToken CancellationToken

To stop waiting.

Returns

Task<YeelightDevice>

The light.

Exceptions

ArgumentNullException

id is null.

ArgumentOutOfRangeException

The timeout is negative (and not infinite), or more than about 49 days.

TimeoutException

The light was not found within the time.

ObjectDisposedException

The client is disposed.

OperationCanceledException

The wait was cancelled, or the client was disposed while it waited.