Method SetPowerAsync
- Namespace
- Yeelight
- Assembly
- YeelightClient.dll
SetPowerAsync(bool, TimeSpan?, PowerOnMode, CancellationToken)
Switches the light on or off.
public Task SetPowerAsync(bool on, TimeSpan? transition = null, PowerOnMode mode = PowerOnMode.Normal, CancellationToken cancellationToken = default)
Parameters
onbooltrueto switch on,falseto switch off.transitionTimeSpan?How long the change takes, or
nullfor a sudden one.modePowerOnModeThe mode to switch on in (only when switching on).
cancellationTokenCancellationTokenTo stop waiting for the answer.
Returns
- Task
A task that ends when the light has answered.
Exceptions
- ArgumentOutOfRangeException
The transition is shorter than the light accepts.
- ArgumentException
A mode other than Normal is given when switching off.