Scroll to navigation

Device::Yeelight::Light(3) User Contributed Perl Documentation Device::Yeelight::Light(3)

Device::Yeelight::Light - WiFi Smart LED Light

SYNOPSIS

This module provides base class for Yeelight smart device

SUBROUTINES/METHODS

new

Creates new Yeelight light device.

is_supported

Checks if method is supported by the device.

connection

Create and return socket connected to the device.

call

Sends command to device.

Yeelight API CALLS

get_prop

This method is used to retrieve current property of smart LED.

set_ct_abx

This method is used to change the color temperature of a smart LED.

Parameters

Target color temperature. The type is integer and range is 1700 ~ 6500 (k).
Support two values: sudden and smooth. If effect is sudden, then the color temperature will be changed directly to target value, under this case, the third parameter duration is ignored. If effect is smooth, then the color temperature will be changed to target value in a gradual fashion, under this case, the total time of gradual change is specified in third parameter duration.
Specifies the total time of the gradual changing. The unit is milliseconds. The minimum support duration is 30 milliseconds.

set_rgb

This method is used to change the color of a smart LED.

Parameters

Target color, whose type is integer. It should be expressed in decimal integer ranges from 0 to 16777215 (hex: 0xFFFFFF).
Refer to "set_ct_abx" method.
Refer to "set_ct_abx" method.

set_hsv

This method is used to change the color of a smart LED.

Parameters

Target hue value, whose type is integer. It should be expressed in decimal integer ranges from 0 to 359.
Target saturation value whose type is integer. It's range is 0 to 100.
Refer to "set_ct_abx" method.
Refer to "set_ct_abx" method.

set_bright

This method is used to change the brightness of a smart LED.

Parameters

Target brightness. The type is integer and ranges from 1 to 100. The brightness is a percentage instead of a absolute value. 100 means maximum brightness while 1 means the minimum brightness.
Refer to "set_ct_abx" method.
Refer to "set_ct_abx" method.

set_power

This method is used to switch on or off the smart LED (software managed on/off).

Parameters

Can only be on or off. on means turn on the smart LED, off means turn off the smart LED.
Refer to "set_ct_abx" method.
Refer to "set_ct_abx" method.
0 Normal turn on operation (default value)
1 Turn on and switch to CT mode.
2 Turn on and switch to RGB mode.
3 Turn on and switch to HSV mode.
4 Turn on and switch to color flow mode.
5 Turn on and switch to Night light mode. (Ceiling light only).

toggle

This method is used to toggle the smart LED.

set_default

This method is used to save current state of smart LED in persistent memory. So if user powers off and then powers on the smart LED again (hard power reset), the smart LED will show last saved state.

start_cf

This method is used to start a color flow. Color flow is a series of smart LED visible state changing. It can be brightness changing, color changing or color temperature changing. This is the most powerful command.

Parameters

Total number of visible state changing before color flow stopped. 0 means infinite loop on the state changing.
The action taken after the flow is stopped.
0 means smart LED recover to the state before the color flow started.
1 means smart LED stay at the state when the flow is stopped.
2 means turn off the smart LED after the flow is stopped.
The expression of the state changing series.
Gradual change time or sleep time, in milliseconds, minimum value 50.
1 color
2 color temperature
7 sleep
Brightness value, -1 or 1 ~ 100. Ignored when mode is 7. When this value is -1, brightness in this tuple is ignored (only color or CT change takes effec

stop_cf

This method is used to stop a running color flow.

set_scene

This method is used to set the smart LED directly to specified state. If the smart LED is off, then it will turn on the smart LED firstly and then apply the specified command.

Parameters

cron_add

This method is used to start a timer job on the smart LED.

Parameters

Currently can only be 0 (means power off).
Length of the timer (in minutes).

cron_get

This method is used to retrieve the setting of the current cron job of the specified type.

Parameters

The type of the cron job (currently only support 0).

cron_del

This method is used to stop the specified cron job.

Parameters

The type of the cron job (currently only support 0).

set_adjust

This method is used to change brightness, CT or color of a smart LED without knowing the current value, it's main used by controllers.

Parameters

The direction of the adjustment, the valid value can be:
The property to adjust. The valid value can be:
(When "prop" is color, the "action" can only be circle, otherwise, it will be deemed as invalid request.)

set_music

This method is used to start or stop music mode on a device. Under music mode, no property will be reported and no message quota is checked.

Parameters

The action of "set_music" command. The valid value can be:
0 turn off music mode
1 turn on music mode
The IP address of the music server.
The TCP port music application is listening on.

set_name

This method is used to name the device. The name will be stored on the device and reported in discovering response. User can also read the name through "get_prop" method.

Parameters

The name of the device.

adjust_bright

This method is used to adjust the brightness by specified percentage within specified duration.

Parameters

The percentage to be adjusted. The range is: -100 ~ 100
Refer to "set_ct_abx" method.

adjust_ct

This method is used to adjust the color temperature by specified percentage within specified duration.

Parameters

The percentage to be adjusted. The range is: -100 ~ 100
Refer to "set_ct_abx" method.

adjust_color

This method is used to adjust the color within specified duration.

Parameters

The percentage to be adjusted. The range is: -100 ~ 100
Refer to "set_ct_abx" method.

bg_set_xxx / bg_toggle

These methods are used to control background light, for each command detail, refer to set_xxx command.

Refer to "set_xxx" command.

bg_adjust_xxx

This method is used to adjust background light by specified percentage within specified duration.

Refer to "adjust_bright", "adjust_ct", "adjust_color".

dev_toggle

This method is used to toggle the main light and background light at the same time.

AUTHOR

Jan Baier, "<jan.baier at amagical.net>"

SEE ALSO

This API is described in the Yeeling WiFi Light Inter-Operation Specification.

LICENSE AND COPYRIGHT

Copyright 2019 Jan Baier.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See <http://dev.perl.org/licenses/> for more information.

2021-08-06 perl v5.40.0