yeelight API¶
这是自动生成的API文档。把它作为公众的参考项目的API
-
yeelight.
discover_bulbs
(timeout=2)[source]¶ 发现所有局域网内的Yeelight灯泡.
Parameters: timeout (int) – 等待回复需要多少秒。发现将总是要花这么长的时间, 因为它不知道当所有的灯泡都响应完毕时。 Returns: 字典列表,包含网络中每个灯泡的IP,端口和功能。
-
class
yeelight.
Bulb
(ip, port=55443, effect='smooth', duration=300, auto_on=False)[source]¶ YeeLight的控制类.
Parameters: - 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.
Return type: bool Returns: 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
()[source]¶ Retrieve and return the properties of the bulb.
This method also updates
last_properties
when it is called.Returns: A dictionary of param: value items. Return type: dict
-
bulb_type
¶ 灯泡类型
返回灯泡类型:White or Color.当尝试在属性已知之前访问时,灯泡类型是未知的。
Returns: 灯泡类型.
-
send_command
(method, params=None)[source]¶ 请求信息并返回响应
Parameters: - method (str) – control method id
- params (list) – list of params for the specified method
Returns: the command response
-
name
¶ 设置或返回设备名字 :return: 返回设备名字
-
is_on
¶ 返回灯泡是否打开 :return:打开则是’on’,关闭侧’off’。
-
set_rgb
(red, green, blue)[source]¶ 设置灯泡的RGB值 :param int red: 红色范围 (0-255) :param int green: 绿色范围 (0-255) :param int blue: 蓝色范围 (0-255)
-
set_hsv
(hue, saturation)[source]¶ Set the bulb’s HSV value.
Parameters: - hue (int) – The hue to set (0-359).
- saturation (int) – The saturation to set (0-100).