Giter Club home page Giter Club logo

xiaomi-yeelight-api's Introduction


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

$ 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

Usage

Reading device information

from yeelight import SmartBulb

bulb = SmartBulb('192.168.xxx.xxx')

print('Name: %s' % bulb.name)
$ python3 info.py
Name: Bedroom Floor Lamp

Change state

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

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.

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)

License

MIT

xiaomi-yeelight-api's People

Contributors

vrachieru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.