Xiaomi Yeelight Smart Bulb API wrapper
- 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
- Query device information
- Change bulb state
- Set RGB color
- Set custom flow
$ pip3 install git+https://github.com/vrachieru/xiaomi-yeelight-api.git
or
$ git clone https://github.com/vrachieru/xiaomi-yeelight-api.git
$ pip3 install ./xiaomi-yeelight-api
from yeelight import SmartBulb
bulb = SmartBulb('192.168.xxx.xxx')
print('Name: %s' % bulb.name)
$ python3 info.py
Name: Bedroom Floor Lamp
from yeelight import SmartBulb
bulb = SmartBulb('192.168.xxx.xxx')
if bulb.is_on:
bulb.power_off()
print('Bulb powered off')
else:
bulb.power_on()
print('Bulb powered on')
$ python3 toggle.py
Bulb powered off
$ python3 toggle.py
Bulb powered on
The following will transition between the colors RED
, GREEN
, BLUE
at 100%
brightness with a transition duration of 1s
and 1s
delay between transitions.
from yeelight import SmartBulb, Flow, RGBTransition, SleepTransition
RED = [255, 0, 0]
GREEN = [0, 255, 0]
BLUE = [0, 0, 255]
flow = Flow(
10,
Flow.actions.recover,
[
RGBTransition(*RED, 1000, 100),
SleepTransition(1000),
RGBTransition(*GREEN, 1000, 100),
SleepTransition(1000),
RGBTransition(*BLUE, 1000, 100),
SleepTransition(1000)
]
)
bulb = SmartBulb('192.168.xxx.xxxx')
bulb.start_flow(flow)
MIT