Class LightModule
- Namespace
- KasaTapoClient
- Assembly
- KasaTapoClient.dll
Provides module-style access to light features for bulbs and light strips.
public sealed class LightModule
- Inheritance
-
LightModule
- Inherited Members
Properties
AvailableEffects
Gets the available light effects reported by the device.
public IReadOnlyList<LightEffectDefinition> AvailableEffects { get; }
Property Value
Effect
Gets the latest normalized light effect state.
public LightEffectState? Effect { get; }
Property Value
Hsv
Gets the latest normalized HSV color.
public HsvColor? Hsv { get; }
Property Value
IsAvailable
Gets a value indicating whether light control is available.
public bool IsAvailable { get; }
Property Value
State
Gets the latest normalized light state.
public LightState? State { get; }
Property Value
SupportsEffects
Gets a value indicating whether the light reports effect capability.
public bool SupportsEffects { get; }
Property Value
Methods
ClearEffectAsync(CancellationToken)
Disables the current lighting effect and refreshes state.
public Task ClearEffectAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token for the operation.
Returns
- Task
A task that completes when the light effect state has been refreshed.
SetBrightnessAsync(int, CancellationToken)
Sets the brightness percentage and refreshes state.
public Task SetBrightnessAsync(int brightness, CancellationToken cancellationToken = default)
Parameters
brightnessintThe brightness percentage from 0 through 100.
cancellationTokenCancellationTokenThe cancellation token for the operation.
Returns
- Task
A task that completes when the light state has been refreshed.
Exceptions
- ArgumentOutOfRangeException
Thrown when
brightnessis outside the inclusive range of 0 through 100.
SetColorTemperatureAsync(int, CancellationToken)
Sets the color temperature in kelvin and refreshes state.
public Task SetColorTemperatureAsync(int colorTemperature, CancellationToken cancellationToken = default)
Parameters
colorTemperatureintThe color temperature, in kelvin, to apply to the light.
cancellationTokenCancellationTokenThe cancellation token for the operation.
Returns
- Task
A task that completes when the light state has been refreshed.
Exceptions
- ArgumentOutOfRangeException
Thrown when
colorTemperatureis zero or negative.
SetEffectAsync(string, CancellationToken)
Enables a lighting effect by device-specific name or identifier and refreshes state.
public Task SetEffectAsync(string effect, CancellationToken cancellationToken = default)
Parameters
effectstringThe device-specific light effect name or identifier.
cancellationTokenCancellationTokenThe cancellation token for the operation.
Returns
- Task
A task that completes when the light effect state has been refreshed.
Exceptions
- ArgumentException
Thrown when
effectis empty or whitespace.
SetHsvAsync(int, int, int, CancellationToken)
Sets the HSV color and refreshes state.
public Task SetHsvAsync(int hue, int saturation, int value, CancellationToken cancellationToken = default)
Parameters
hueintThe hue component from 0 through 360.
saturationintThe saturation component from 0 through 100.
valueintThe value or brightness component from 0 through 100.
cancellationTokenCancellationTokenThe cancellation token for the operation.
Returns
- Task
A task that completes when the light state has been refreshed.
Exceptions
- ArgumentOutOfRangeException
Thrown when
hue,saturation, orvaluefalls outside its supported range.
TurnOffAsync(CancellationToken)
Turns the light off and refreshes state.
public Task TurnOffAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token for the operation.
Returns
- Task
A task that completes when the light state has been refreshed.
TurnOnAsync(CancellationToken)
Turns the light on and refreshes state.
public Task TurnOnAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token for the operation.
Returns
- Task
A task that completes when the light state has been refreshed.
UpdateAsync(CancellationToken)
Refreshes light-related device state.
public Task UpdateAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token for the operation.
Returns
- Task
A task that completes when the device state has been refreshed.