Table of Contents

Class YeelightMusicSession

Namespace
Yeelight
Assembly
YeelightClient.dll

A device in music mode: a connection over which the device takes commands without a limit on their number, and without answering them.

public sealed class YeelightMusicSession : IAsyncDisposable
Inheritance
YeelightMusicSession
Implements
Inherited Members

Remarks

Get one from StartMusicModeAsync(IPAddress?, int, CancellationToken). In music mode the device connects to this computer, and a command that is sent over that connection is carried out at once, as fast as they come: a light can follow music, or the colours of a screen. The price is that the commands are not answered, so a command that the light refuses goes unnoticed, and the device reports no changes to its properties while it is in music mode.

A command here only fails when the connection does: a YeelightException of the kind ConnectionLost. The session ends when it is disposed (the device leaves music mode when the connection closes), when the device closes the connection, or when the client is disposed. Completion tells when.

Properties

Completion

Gets a task that ends when the session has ended: it was disposed, or the device closed the connection, or the connection failed.

IsConnected

Gets whether the session is open.

Methods

DisposeAsync()

Ends the session: the connection is closed, and the device leaves music mode.

SendCommandAsync(string, IReadOnlyList<object?>?, CancellationToken)

Sends any command, for what this class has no method for (the commands of the background light, for one: bg_set_rgb). The method is sent as it is.

SetBrightnessAsync(int, TimeSpan?, CancellationToken)

Sets the brightness.

SetColorTemperatureAsync(int, TimeSpan?, CancellationToken)

Sets the colour temperature.

SetHsvAsync(int, int, TimeSpan?, CancellationToken)

Sets the colour as a hue and a saturation.

SetPowerAsync(bool, TimeSpan?, CancellationToken)

Switches the light on or off.

SetRgbAsync(Color, TimeSpan?, CancellationToken)

Sets the colour.

SetRgbAsync(int, int, int, TimeSpan?, CancellationToken)

Sets the colour.

ToggleAsync(CancellationToken)

Switches the light off when it is on, and on when it is off.