Device class

Represents Yeelight device (bulb, light, strip,...) and allows to control device with given address and port.

Constructors

Device({required InternetAddress address, required int port, CommandSender? commandSender})

Properties

address InternetAddress
IP address of the device.
final
commandSender ↔ CommandSender?
Command sender, default is TCPCommandSender.
getter/setter pair
hashCode int
The hash code for this object.
no setteroverride
isConnected bool
Returns true if device is connected (connection exists).
no setter
notificationMessageStream Stream<NotificationMessage>
When there is a device state change, the device will send a notification message to all connected clients. This is to make sure all clients will get the latest device state in time without having to poll the status from time to time.
no setter
port int
Port of the device.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

adjustBrightness({int? id, LightType lightType = LightType.main, required int percentage, required Duration duration}) Future<CommandResponse?>
This method is used to adjust the brightness by specified percentage within specified duration.
adjustColor({int? id, LightType lightType = LightType.main, required int percentage, required Duration duration}) Future<CommandResponse?>
This method is used to adjust the color within specified duration.
adjustColorTemperature({int? id, LightType lightType = LightType.main, required int percentage, required Duration duration}) Future<CommandResponse?>
This method is used to adjust the color temperature by specified percentage within specified duration.
connect() Future<void>
Creates connection to the device.
cronAdd({int? id, required Duration timer}) Future<CommandResponse?>
This method is used to start a timer.
cronDelete({int? id}) Future<CommandResponse?>
This method is used to stop the specified cron job.
cronGet({int? id}) Future<CommandResponse?>
This method is used to get the setting of current cron job of the specific type.
disconnect() → void
Disconnects from device.
getProps({int? id, required List<String> parameters}) Future<CommandResponse?>
This method is used to retrieve current property of the device.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sendCommand(Command command) Future<CommandResponse?>
Allows to send any Command.
setAdjust({int? id, LightType lightType = LightType.main, required AdjustAction action, required AdjustProperty property}) Future<CommandResponse?>
This method is used to change brightness, color temperature or color of device main light without knowing the current value.
setBrightness({int? id, LightType lightType = LightType.main, required int brightness, Effect effect = const Effect.smooth(), Duration duration = const Duration(milliseconds: 30)}) Future<CommandResponse?>
This method is used to change the brightness of light.
setColorTemperature({int? id, LightType lightType = LightType.main, required int colorTemperature, Effect effect = const Effect.smooth(), Duration duration = const Duration(milliseconds: 30)}) Future<CommandResponse?>
This method is used to set the color temperature of the light.
setDefault({int? id, LightType? lightType}) Future<CommandResponse?>
This method is used to save current state of the light to persistent memory.
setHSV({int? id, LightType lightType = LightType.main, required int hue, required int saturation, Effect effect = const Effect.smooth(), Duration duration = const Duration(milliseconds: 30)}) Future<CommandResponse?>
This method is used to set the color of light.
setMusic({int? id, required int action, required String host, required int port}) Future<CommandResponse?>
This method is used to start or stop music mode on device. Under music mode, no property will be reported and no message quota is checked.
setName({int? id, required String name}) Future<CommandResponse?>
This method is used to set name for device. The name will be stored on the device and reported in discovering response.
setRGB({int? id, LightType lightType = LightType.main, required int color, Effect effect = const Effect.smooth(), Duration duration = const Duration(milliseconds: 30)}) Future<CommandResponse?>
This method is used to set the color of light.
setScene({int? id, LightType lightType = LightType.main, required Scene scene}) Future<CommandResponse?>
This method is used to set the device (main light) directly to specified state. If the device is off, it will turn the device on and then apply this command.
startFlow({int? id, LightType lightType = LightType.main, required Flow flow}) Future<CommandResponse?>
This method is used to start a color flow.
stopFlow({int? id, LightType lightType = LightType.main}) Future<CommandResponse?>
This method is used to stop a running color flow.
toggle({int? id, LightType? lightType}) Future<CommandResponse?>
This method is used to toggle the the light.
toString() String
A string representation of this object.
override
turnOff({int? id, Effect effect = const Effect.sudden(), Duration duration = const Duration(milliseconds: 30)}) Future<CommandResponse?>
This method is used to turn the device OFF.
turnOn({int? id, Effect effect = const Effect.smooth(), Duration duration = const Duration(milliseconds: 30)}) Future<CommandResponse?>
This method is used to turn the device ON.

Operators

operator ==(Object other) bool
The equality operator.
override