Table of Contents

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

IReadOnlyList<LightEffectDefinition>

Effect

Gets the latest normalized light effect state.

public LightEffectState? Effect { get; }

Property Value

LightEffectState

Hsv

Gets the latest normalized HSV color.

public HsvColor? Hsv { get; }

Property Value

HsvColor

IsAvailable

Gets a value indicating whether light control is available.

public bool IsAvailable { get; }

Property Value

bool

State

Gets the latest normalized light state.

public LightState? State { get; }

Property Value

LightState

SupportsEffects

Gets a value indicating whether the light reports effect capability.

public bool SupportsEffects { get; }

Property Value

bool

Methods

ClearEffectAsync(CancellationToken)

Disables the current lighting effect and refreshes state.

public Task ClearEffectAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The 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

brightness int

The brightness percentage from 0 through 100.

cancellationToken CancellationToken

The cancellation token for the operation.

Returns

Task

A task that completes when the light state has been refreshed.

Exceptions

ArgumentOutOfRangeException

Thrown when brightness is 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

colorTemperature int

The color temperature, in kelvin, to apply to the light.

cancellationToken CancellationToken

The cancellation token for the operation.

Returns

Task

A task that completes when the light state has been refreshed.

Exceptions

ArgumentOutOfRangeException

Thrown when colorTemperature is 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

effect string

The device-specific light effect name or identifier.

cancellationToken CancellationToken

The cancellation token for the operation.

Returns

Task

A task that completes when the light effect state has been refreshed.

Exceptions

ArgumentException

Thrown when effect is 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

hue int

The hue component from 0 through 360.

saturation int

The saturation component from 0 through 100.

value int

The value or brightness component from 0 through 100.

cancellationToken CancellationToken

The cancellation token for the operation.

Returns

Task

A task that completes when the light state has been refreshed.

Exceptions

ArgumentOutOfRangeException

Thrown when hue, saturation, or value falls outside its supported range.

TurnOffAsync(CancellationToken)

Turns the light off and refreshes state.

public Task TurnOffAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The 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

cancellationToken CancellationToken

The 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

cancellationToken CancellationToken

The cancellation token for the operation.

Returns

Task

A task that completes when the device state has been refreshed.