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
-
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'。
-
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).