Method SetPowerAsync
- Namespace
- Yeelight
- Assembly
- YeelightClient.dll
SetPowerAsync(bool, TimeSpan?, CancellationToken)
Switches the light on or off.
public Task SetPowerAsync(bool on, TimeSpan? transition = null, CancellationToken cancellationToken = default)
Parameters
onbooltrueto switch on,falseto switch off.transitionTimeSpan?How long the change takes, or
nullfor a sudden one.cancellationTokenCancellationTokenTo stop waiting for the connection.
Returns
- Task
A task that ends when the command has been sent.
Exceptions
- ArgumentOutOfRangeException
The transition is shorter than the light accepts.
- YeelightException
The connection is lost.