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

VERSION

Version 0.10

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

ct_value

Target color temperature. The type is integer and range is 1700 ~ 6500 (k).

effect

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.

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

rgb_value

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

effect

Refer to set_ct_abx method.

duration

Refer to set_ct_abx method.

set_hsv

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

Parameters

hue

Target hue value, whose type is integer. It should be expressed in decimal integer ranges from 0 to 359.

sat

Target saturation value whose type is integer. It's range is 0 to 100.

effect

Refer to set_ct_abx method.

duration

Refer to set_ct_abx method.

set_bright

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

Parameters

brightness

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.

effect

Refer to set_ct_abx method.

duration

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

power

Can only be on or off. on means turn on the smart LED, off means turn off the smart LED.

effect

Refer to set_ct_abx method.

duration

Refer to set_ct_abx method.

mode (optional parameter)
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

count

Total number of visible state changing before color flow stopped. 0 means infinite loop on the state changing.

action

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.
flow_expression

The expression of the state changing series.

Duration

Gradual change time or sleep time, in milliseconds, minimum value 50.

Mode
1 color
2 color temperature
7 sleep
Value
RGB value when mode is 1,
CT value when mode is 2,
Ignored when mode is 7
Brightness

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

class
color means change the smart LED to specified color and brightness
hsv means change the smart LED to specified color and brightness
ct means change the smart LED to specified ct and brightness
cf means start a color flow in specified fashion
auto_delay_off means turn on the smart LED to specified brightness and start a sleep timer to turn off the light after the specified minutes
val1
val2
val3

cron_add

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

Parameters

type

Currently can only be 0 (means power off).

value

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

type

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

cron_del

This method is used to stop the specified cron job.

Parameters

type

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

action

The direction of the adjustment, the valid value can be:

increase increase the specified property
decrease decrease the specified property
circle increase the specified property, after it reaches the max value, go back to minimum value
prop

The property to adjust. The valid value can be:

bright adjust brightness
ct adjust color temperature
color adjust color.

(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

action

The action of set_music command. The valid value can be:

0 turn off music mode
1 turn on music mode
host

The IP address of the music server.

port

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

name

The name of the device.

adjust_bright

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

Parameters

percentage

The percentage to be adjusted. The range is: -100 ~ 100

duration

Refer to "set_ct_abx" method.

adjust_ct

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

Parameters

percentage

The percentage to be adjusted. The range is: -100 ~ 100

duration

Refer to "set_ct_abx" method.

adjust_color

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

Parameters

percentage

The percentage to be adjusted. The range is: -100 ~ 100

duration

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.