项目作者: vrachieru

项目描述 :
Xiaomi Yeelight Smart Bulb API wrapper.
高级语言: Python
项目地址: git://github.com/vrachieru/xiaomi-yeelight-api.git
创建时间: 2018-10-17T08:33:04Z
项目社区:https://github.com/vrachieru/xiaomi-yeelight-api

开源协议:MIT License

下载







Version


Version



Xiaomi Yeelight Smart Bulb API wrapper

About Xiaomi Yeelight Smart Bulb

  • Xiaomi Yeelight Smart Bulb are light bulbs that can be turned on/off and their color/brightness changed remotely via an app
  • Can be operated either via cloud or lan

Features

  • Query device information
  • Change bulb state
  • Set RGB color
  • Set custom flow

Install

  1. $ pip3 install git+https://github.com/vrachieru/xiaomi-yeelight-api.git

or

  1. $ git clone https://github.com/vrachieru/xiaomi-yeelight-api.git
  2. $ pip3 install ./xiaomi-yeelight-api

Usage

Reading device information

  1. from yeelight import SmartBulb
  2. bulb = SmartBulb('192.168.xxx.xxx')
  3. print('Name: %s' % bulb.name)
  1. $ python3 info.py
  2. Name: Bedroom Floor Lamp

Change state

  1. from yeelight import SmartBulb
  2. bulb = SmartBulb('192.168.xxx.xxx')
  3. if bulb.is_on:
  4. bulb.power_off()
  5. print('Bulb powered off')
  6. else:
  7. bulb.power_on()
  8. print('Bulb powered on')
  1. $ python3 toggle.py
  2. Bulb powered off
  3. $ python3 toggle.py
  4. Bulb powered on

Set custom flow

The following will transition between the colors RED, GREEN, BLUE at 100% brightness with a transition duration of 1s and 1s delay between transitions.

  1. from yeelight import SmartBulb, Flow, RGBTransition, SleepTransition
  2. RED = [255, 0, 0]
  3. GREEN = [0, 255, 0]
  4. BLUE = [0, 0, 255]
  5. flow = Flow(
  6. 10,
  7. Flow.actions.recover,
  8. [
  9. RGBTransition(*RED, 1000, 100),
  10. SleepTransition(1000),
  11. RGBTransition(*GREEN, 1000, 100),
  12. SleepTransition(1000),
  13. RGBTransition(*BLUE, 1000, 100),
  14. SleepTransition(1000)
  15. ]
  16. )
  17. bulb = SmartBulb('192.168.xxx.xxxx')
  18. bulb.start_flow(flow)

License

MIT