Skip to main content

Python library for Xiaomi Mi Yeelight.

Project description

version ci coverage license

yeelib

Python library for Xiaomi Mi Yeelight.

yeelib is an asyncio based Python library to control Yeelights. It has no external dependencies and is blazing fast!

Getting Started

Install

pip install yeelib

Example:

import asyncio

from yeelib import search_bulbs


@asyncio.coroutine
def turn_all_lights_on(bulbs):
    while True:
        for b in bulbs.values():
            asyncio.Task(b.send_command("set_power",
                                        ["off", "sudden", 40]))
        yield from asyncio.sleep(10)


def main():
    loop = asyncio.get_event_loop()
    bulbs = loop.run_until_complete(search_bulbs())
    loop.create_task(turn_all_lights_on(bulbs))
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        loop.stop()


if __name__ == '__main__':
    main()

The script above will turn all off every 10 seconds. The following script does the same thing, but note how you can define the bulbs prior calling the search_bulbs context manager. This works due to the fact that dictionaries are mutable in Python.

Specifications

For more information check out the Yeelight developer documentation. http://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yeelib-2.0.0.tar.gz (12.8 kB view details)

Uploaded Source

File details

Details for the file yeelib-2.0.0.tar.gz.

File metadata

  • Download URL: yeelib-2.0.0.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for yeelib-2.0.0.tar.gz
Algorithm Hash digest
SHA256 2308585649737396f09b218f55527915165a94828795ae789ad59313587ed018
MD5 f4df1bc6cf94b664d9890deac1b952eb
BLAKE2b-256 a8263da74bd3384f6a7cae058f0bd482794c877e4b6fdab1d7b657c06e150efa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page