Skip to main content

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


Download files

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

Source Distribution

mPython-yeelight-0.0.1.tar.gz (5.6 kB view details)

Uploaded Source

File details

Details for the file mPython-yeelight-0.0.1.tar.gz.

File metadata

  • Download URL: mPython-yeelight-0.0.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for mPython-yeelight-0.0.1.tar.gz
Algorithm Hash digest
SHA256 d67ae057038378716493883c40e5f85b27ef761354b810abca7f32612b507a74
MD5 42397ba5ab3e72d723941b61111f30e6
BLAKE2b-256 32f19a3edd615b2b743bbec0e775c608ea1163c5afc5e699bdf0904beb421f4d

See more details on using hashes here.

Supported by

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