yeelight API

这是自动生成的API文档。把它作为公众的参考项目的API

yeelight.discover_bulbs(timeout=2)[源代码]

发现所有局域网内的Yeelight灯泡.

参数:timeout (int) -- 等待回复需要多少秒。发现将总是要花这么长的时间, 因为它不知道当所有的灯泡都响应完毕时。
返回:字典列表,包含网络中每个灯泡的IP,端口和功能。
class yeelight.Bulb(ip, port=55443, effect='smooth', duration=300, auto_on=False)[源代码]

YeeLight的控制类.

参数:
  • ip (str) -- 灯泡的IP.
  • port (int) -- 连接灯泡的端口号,默认55443.
  • effect (str) -- 效果类型."smooth" or "sudden".
  • duration (int) -- 效果的持续时间,以毫秒为单位.最小值为30.突然效果会忽略此值.
  • auto_on (bool) -- 是否 ensure_on() 在每次操作之前调用以自动打开灯泡,如果它已关闭。这会在每条消息之前更新灯泡的属性, 每个命令会花费一个额外的消息。 如果您担心速率限制,请将其关闭并自行检查。get_properties() 或运行 ensure_on()
music_mode

Return whether the music mode is active.

返回类型:bool
返回:True if music mode is on, False otherwise.
last_properties

The last properties we've seen the bulb have.

This might potentially be out of date, as there's no background listener for the bulb's notifications. To update it, call get_properties.

get_properties()[源代码]

Retrieve and return the properties of the bulb.

This method also updates last_properties when it is called.

返回:A dictionary of param: value items.
返回类型:dict
ensure_on()[源代码]

Turn the bulb on if it is off.

bulb_type

灯泡类型

返回灯泡类型:White or Color.当尝试在属性已知之前访问时,灯泡类型是未知的。

返回:灯泡类型.
send_command(method, params=None)[源代码]

请求信息并返回响应

参数:
  • method (str) -- control method id
  • params (list) -- list of params for the specified method
返回:

the command response

name

设置或返回设备名字 :return: 返回设备名字

is_on

返回灯泡是否打开 :return:打开则是'on',关闭侧'off'。

turn_on()[源代码]

打开灯泡

turn_off()[源代码]

关闭灯泡

toggle()[源代码]

反转灯泡状态.

set_rgb(red, green, blue)[源代码]

设置灯泡的RGB值 :param int red: 红色范围 (0-255) :param int green: 绿色范围 (0-255) :param int blue: 蓝色范围 (0-255)

set_hsv(hue, saturation)[源代码]

Set the bulb's HSV value.

参数:
  • hue (int) -- The hue to set (0-359).
  • saturation (int) -- The saturation to set (0-100).
set_color_temp(degrees)[源代码]

设置灯泡色温

参数:degrees (int) -- 色温范围(1700-6500).
set_adjust(action, prop)[源代码]

该方法用于改变智能LED的亮度、CT或颜色,在不知道当前值的情况下.

参数:
  • action (str) -- 调整方向,可以的值是,'increase' : 增加指定属性;100'decrease': 减小指定属性;'circle': 增加指定的属性,当它达到最大值后,回到最小值.
  • prop (str) -- 属性调制. 可以是 "bright" 亮度调整, "ct" 色温调整, "color" 颜色调整.
set_brightness(brightness)[源代码]

设置灯泡亮度

参数:brightness (int) -- 亮度范围 (1-100).
start_flow(flow)[源代码]

Start a flow

参数:flow (yeelight.Flow) -- the Flow instance to start
cron_add(event_type, value)[源代码]

Add an event to cron.

cron_get(event_type)[源代码]

Retrieve an event from cron.

cron_del(event_type)[源代码]

Remove an event from cron.

exception yeelight.BulbException[源代码]

一般的 yeelight 异常类

当灯泡通知错误时会引发此异常,例如,当尝试向灯泡发出不支持的命令时。