Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Yeelight LAN Control for mPython/micropython

Project description

概述

yeelight 是掌控板或micropython驱动库,用于控制局域网内的YeeLight智能灯泡/小米智能灯具设备。

库的安装方法

可通过以下任一方法进行安装。

  1. 将项目中的yeelight.py
  2. 在掌控板REPL界面中,使用upip安装,步骤如下:
    • 前置条件需要掌控板连接网络
    • 导入upip模块,执行import upip
    • 执行`upip.install('mPython-yeelight')
>>> import upip
>>> upip.install('mPython-yeelight')

使用

准备工作:

  • YeeLight智能灯泡在使用前,须要先配置好连接好wifi,并将 局域网控制 功能打开。
  • 掌控板确保已与智能灯泡在同个局域网内,并网络通畅。

yeelight Library Documentation:https://mpython-yeelight.readthedocs.io

YeeLight第三方控制协议:https://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf

简单示例

from mpython import *
from yeelight import *

my_wifi = wifi()                    # 连接到与YeeLight相同的局域网内
my_wifi.connectWiFi("","")          


discover_bulbs()        # 发现局域网内YeeLight的设备信息

bulb=Bulb("192.168.0.7")    # 构建Bulb类用于控制,传入IP参数

bulb.turn_on()              # 开灯
sleep(2)
bulb.turn_off()             # 关灯
sleep(2)
bulb.toggle()               # 翻转
sleep(2)
bulb.set_rgb(255,0,0)       # 设置RGB值
bulb.set_brightness(50)     # 调节亮度
sleep(2)
bulb.set_hsv(180,100)       # 设置HSV值
sleep(2)

执照

所有代码均在MIT许可下发布。

Project details


Release history Release notifications

Download files

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

Files for mPython-yeelight, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size mPython-yeelight-0.0.1.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page