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
idstringThe id of the light, for example
0x000000000015243f(the case does not matter).timeoutTimeSpanHow long to wait, or InfiniteTimeSpan to wait until the light is found (or the token is cancelled, or the client disposed).
cancellationTokenCancellationTokenTo stop waiting.
Returns
- Task<YeelightDevice>
The light.
Exceptions
- ArgumentNullException
idisnull.- 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.