Yeelight

Yeelight

new Yeelight(address, port) → {Yeelight}

Source:
Yeelight
Parameters:
Name Type Description
address String address of yeelight device
port Number port of yeelight device
Returns:
Instance of Yeelight
Type
Yeelight

Members

props :Array

Source:
props
Type:
  • Array

Methods

(static) discover(port, callback) → {SSDP}

Source:
Search Yeelight blub
Example
Yeelight.discover(function(light){
 console.log(light.name);
});
Parameters:
Name Type Description
port Number ssdp port
callback function handle your device
Returns:
ssdp instance
Type
SSDP

adjust_bright(percentage, duration) → {Promise}

Source:
This method is used to adjust the brightness by specified percentage within specified duration.
Parameters:
Name Type Description
percentage Number the percentage to be adjusted. The range is: -100 ~ 100
duration Number Refer to "set_ct_abx" method.
Returns:
Type
Promise

adjust_color(percentage, duration) → {Promise}

Source:
This method is used to adjust the color within specified duration.
Parameters:
Name Type Description
percentage Number the percentage to be adjusted. The range is: -100 ~ 100
duration Number Refer to "set_ct_abx" method.
Returns:
Type
Promise

adjust_ct(percentage, duration) → {Promise}

Source:
This method is used to adjust the color temperature by specified percentage within specified duration.
Parameters:
Name Type Description
percentage Number the percentage to be adjusted. The range is: -100 ~ 100
duration Number Refer to "set_ct_abx" method.
Returns:
Type
Promise

bg_set() → {Promise}

Source:
These methods are used to control background light, for each command detail, refer to set_xxx command.
Returns:
Type
Promise

command(method, params) → {Promise}

Source:
execute command
Parameters:
Name Type Description
method String The value of "method" is a string that specifies which control method the sender wants to invoke. The value must be chosen by sender from one of the methods that listed in "SUPPORT" header in advertisement request or search response message. Otherwise, the message will be rejected by smart LED.
params String The value of "params" is an array. The values in the array are method specific.
Returns:
promise
Type
Promise

cron_add(type, value) → {Promise}

Source:
[cron_add description]
Parameters:
Name Type Description
type Number [description]
value Number [description]
Returns:
Type
Promise

cron_del(type) → {Promise}

Source:
[cron_del description]
Parameters:
Name Type Description
type Number [description]
Returns:
Type
Promise

cron_get(type) → {Promise}

Source:
[cron_get description]
Parameters:
Name Type Description
type Number [description]
Returns:
Type
Promise

dev_toggle() → {Promise}

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

When there is main light and background light, “toggle” is used to toggle main light, “bg_toggle” is used to toggle background light while “dev_toggle” is used to toggle both light at the same time

Returns:
Type
Promise

exit() → {Yeelight}

Source:
Close Yeelight device
Returns:
Yeelight Instance
Type
Yeelight

get_prop(…props) → {Promise}

Source:
get_prop This method is used to retrieve current property of smart LED. All the supported properties are defined in table 4-2, section 4.3
Example
Request:
{"id":1,"method":"get_prop","params":["power", "not_exist", "bright"]}

Response:
{"id":1, "result":["on", "", "100"]}
Parameters:
Name Type Attributes Description
props * <repeatable>
The parameter is a list of property names and the response contains a list of corresponding property values. If the requested property name is not recognized by smart LED, then a empty string value ("") will be returned.
Returns:
Type
Promise

is_support(func) → {Boolean}

Source:
is_support("set_rgb")
Parameters:
Name Type Description
func String
Returns:
isSupport
Type
Boolean

parse(data) → {Yeelight}

Source:
Parse Yeelight Response
Parameters:
Name Type Description
data String
Returns:
Yeelight Instance
Type
Yeelight

set_adjust(action, prop) → {Promise}

Source:
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:
Name Type Description
action String 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 String 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.)
Returns:
Type
Promise

set_bright(brightness, effect, duration) → {Promise}

Source:
set_bright This method is used to change the brightness of a smart LED.
Parameters:
Name Type Description
brightness is the 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 String [Refer to Yeelight#set_ct_abx method.]
duration Number [Refer to Yeelight#set_ct_abx method.]
Returns:
Type
Promise

set_ct_abx(ct_value, effect, duration) → {Promise}

Source:
set_ct_abx This method is used to change the color temperature of a smart LED
Parameters:
Name Type Description
ct_value Number is the target color temperature. The type is integer and range is 1700 ~ 6500 (k).
effect String 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 Number specifies the total time of the gradual changing. The unit is milliseconds. The minimum support duration is 30 milliseconds.
Returns:
Type
Promise

set_default() → {Promise}

Source:
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.
Returns:
Type
Promise

set_hsv(hue, sat, effect, duration) → {Promise}

Source:
[set_hsv This method is used to change the color of a smart LED]
Parameters:
Name Type Description
hue Number is the target hue value, whose type is integer. It should be expressed in decimal integer ranges from 0 to 359.
sat Number is the target saturation value whose type is integer. It's range is 0 to 100
effect Striung [Refer to Yeelight#set_ct_abx method.]
duration Number [Refer to Yeelight#set_ct_abx method.]
Returns:
Type
Promise

set_music(action, host, port) → {Promise}

Source:
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.

When control device wants to start music mode, it needs start a TCP server firstly and then call “set_music” command to let the device know the IP and Port of the TCP listen socket. After received the command, LED device will try to connect the specified peer address. If the TCP connection can be established successfully, then control device could send all supported commands through this channel without limit to simulate any music effect. The control device can stop music mode by explicitly send a stop command or just by closing the socket.

Parameters:
Name Type Description
action Number the action of set_music command. The valid value can be: 0: turn off music mode. 1: turn on music mode.
host String the IP address of the music server
port Number the TCP port music application is listening on.
Returns:
Type
Promise

set_name(name) → {Promise}

Source:
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 Yeelight#get_prop method.

When using Yeelight official App, the device name is stored on cloud. This method instead store the name on persistent memory of the device, so the two names could be different.

Parameters:
Name Type Description
name String the name of the device.
Returns:
Type
Promise

set_power(power, effect, duration) → {Promise}

Source:
set_power This method is used to switch on or off the smart LED (software managed on/off).
Parameters:
Name Type Description
power can only be "on" or "off".
  • "on" means turn on the smart LED,
  • "off" means turn off the smart LED.
  • effect String [description]
    duration Number [description]
    Returns:
    Type
    Promise

    set_rgb(rgb_value, effect, duration) → {Promise}

    Source:
    set_rgb This method is used to change the color of a smart LED.
    Parameters:
    Name Type Description
    rgb_value is the target color, whose type is integer. It should be expressed in decimal integer ranges from 0 to 16777215 (hex: 0xFFFFFF).
    effect String [Refer to Yeelight#set_ct_abx method.]
    duration Number [Refer to Yeelight#set_ct_abx method.]
    Returns:
    Type
    Promise

    set_scene(type, …value) → {Promise}

    Source:
    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:
    Name Type Attributes Description
    type String can be "color", "hsv", "ct", "cf", "auto_dealy_off".
  • "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" are class specific.
  • value Number <repeatable>
    Returns:
    Type
    Promise

    start_cf(count, action, flow_expression) → {Promise}

    Source:
    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. All our recommended scenes, e.g. Sunrise/Sunset effect is implemented using this method. With the flow expression, user can actually “program” the light effect.
    Parameters:
    Name Type Description
    count Number is the total number of visible state changing before color flowstopped. 0 means infinite loop on the state changing.
    action Number is 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 String is the expression of the state changing series.
    Returns:
    Type
    Promise

    stop_cf() → {Promise}

    Source:
    stop_cf This method is used to stop a running color flow.
    Returns:
    Type
    Promise

    sync() → {Promise}

    Source:
    [sync description]
    Returns:
    Yeelight Instance
    Type
    Promise

    toggle() → {Promise}

    Source:
    toggle This method is used to toggle the smart LED.
    Returns:
    Type
    Promise