用于 LimitlessLED Wifi Bridge v6.0 协议的 Milight Wifi Bridge 3.0 控制器(灯开/关,更改颜色/模式/亮度/饱和度,链接/取消链接)
项目描述
Milight Wifi Bridge 3.0 Python 库
它是什么
这个 python 库旨在使用任何 Milight 3.0 灯泡和 wifi 桥接器(使用协议 LimitlessLED Wifi Bridge v6.0)集成到 python 或 shell 项目中。
它是多平台的,并且与 python 2.7+ 和 3+ 兼容。
功能
MilightWifiBridge 类功能的非详尽列表:
- 链接/取消链接灯
- 灯开/关
- Wifi 桥灯开/关
- 设置夜灯模式
- 设置白光模式(默认灯)(灯和桥灯)
- 设置颜色(灯和桥灯)
- 设置饱和度
- 设置亮度(灯和桥灯)
- 设置迪斯科模式(9种可用)(灯光和桥灯)
- 增加/减少迪斯科模式速度(灯光和桥灯)
- 获取 Milight wifi 网桥 MAC 地址
shell 命令的非详尽列表:
- 链接/取消链接灯
- 灯开/关
- Wifi 桥灯开/关
- 设置夜灯模式
- 设置白光模式(默认灯)(灯和桥灯)
- 设置颜色(灯和桥灯)
- 设置饱和度
- 设置亮度(灯和桥灯)
- 设置迪斯科模式(9种可用)(灯光和桥灯)
- 增加/减少迪斯科模式速度(灯光和桥灯)
- 获取 Milight wifi 网桥 MAC 地址
- 帮助
如何安装(python脚本和shell)
- 将您的 Milight 3.0 wifi 网桥连接到您的 wifi 网络(安装 android 应用程序并按照说明操作:https ://play.google.com/store/apps/details?id=com.irainxun.wifilight )
- 获取 wifi 网桥的 IP 地址和端口(可以从您的互联网盒子中找到 IP,默认端口为 5987)
- 加载你的 shell 或 python 脚本
笔记:
python setup.py install
您可以使用根文件夹中的命令将此库安装为包。python setup.py test
您可以使用根文件夹中的命令启动单元测试。
如何在shell中使用
# Note: You can combine multiple requests in one command if you want
# Get help
python3 MilightWifiBridge.py --help
# Link bulbs to a specific zone (light on the bulbs max 3sec before calling this command)
python3 MilightWifiBridge.py --ip 192.168.1.23 --zone 1 --link
# Unlink bulbs to a specific zone (light on the bulbs max 3sec before calling this command)
python3 MilightWifiBridge.py --ip 192.168.1.23 --zone 1 --unlink
# Turn lights ON
python3 MilightWifiBridge.py --ip 192.168.1.23 --zone 1 --turnOn
# Turn lights OFF
python3 MilightWifiBridge.py --ip 192.168.1.23 --zone 1 --turnOff
# Turn wifi bridge light ON
python3 MilightWifiBridge.py --ip 192.168.1.23 --turnOnWifiBridgeLamp
# Turn wifi bridge light OFF
python3 MilightWifiBridge.py --ip 192.168.1.23 --turnOffWifiBridgeLamp
# Set night mode
python3 MilightWifiBridge.py --ip 192.168.1.23 --zone 1 --setNightMode
# Set white mode
python3 MilightWifiBridge.py --ip 192.168.1.23 --zone 1 --setWhiteMode
# Set white mode of the bridge light
python3 MilightWifiBridge.py --ip 192.168.1.23 --setWhiteModeBridgeLamp
# Speed up disco mode
python3 MilightWifiBridge.py --ip 192.168.1.23 --zone 1 --speedUpDiscoMode
# Slow down disco mode
python3 MilightWifiBridge.py --ip 192.168.1.23 --zone 1 --slowDownDiscoMode
# Speed up disco mode of the bridge light
python3 MilightWifiBridge.py --ip 192.168.1.23 --speedUpDiscoModeBridgeLamp
# Slow down disco mode of the bridge light
python3 MilightWifiBridge.py --ip 192.168.1.23 --slowDownDiscoModeBridgeLamp
# Set specific color
python3 MilightWifiBridge.py --ip 192.168.1.23 --zone 1 --setColor 255
# Set specific color of the bridge light
python3 MilightWifiBridge.py --ip 192.168.1.23 --setColorBridgeLamp 255
# Set brightness
python3 MilightWifiBridge.py --ip 192.168.1.23 --zone 1 --setBrightness 50
# Set brightness of the bridge light
python3 MilightWifiBridge.py --ip 192.168.1.23 --setBrightnessBridgeLamp 50
# Set saturation
python3 MilightWifiBridge.py --ip 192.168.1.23 --zone 1 --setSaturation 50
# Set temperature
python3 MilightWifiBridge.py --ip 192.168.1.23 --zone 1 --setTemperature 50
# Set disco mode
python3 MilightWifiBridge.py --ip 192.168.1.23 --zone 1 --setDiscoMode 5
# Set disco mode of the bridge light
python3 MilightWifiBridge.py --ip 192.168.1.23 --setDiscoModeBridgeLamp 5
# Combined commands: Turn ON ALL lights (zone 0) with white mode, a brightness of 50% and a saturation of 50%
python3 MilightWifiBridge.py --ip 192.168.1.23 --zone 0 --turnOn --setWhiteMode --setBrightness 50 --setSaturation 50
如何在python脚本中使用
使用此库的 python 脚本示例:
import sys
from MilightWifiBridge import MilightWifiBridge
milight = MilightWifiBridge()
_ip = "192.168.1.23"
_port = 5987
_timeout = 5.0
_zoneId = 1 # 0 for all
_discoMode = 5
_color = 0xBA # Blue
_brightness = 50 # %
_saturation = 50 # %
_temperature = 50 # %
# Create a connection with the milight wifi bridge (mandatory step)
if not milight.setup(ip=_ip, port=_port, timeout_sec=_timeout):
print("Setup error")
sys.exit(2)
# Show MAC address
macAddress = milight.getMacAddress()
if macAddress != "":
print("MAC address of the milight wifi bridge: {}".format(str(macAddress)))
# Link bulbs to a zone
print("Link bulbs to zone {}: {}".format(str(_zoneId), str(milight.link(zoneId=_zoneId))))
# Unlink bulbs
print("Unlink bulbs of zone {}: {}".format(str(_zoneId), str(milight.unlink(zoneId=_zoneId))))
# Turn on bulbs in specific zone
print("Turn on bulbs in zone {}: {}".format(str(_zoneId), str(milight.turnOn(zoneId=_zoneId))))
# Turn off bulbs in specific zone
print("Turn off bulbs in zone {}: {}".format(str(_zoneId), str(milight.turnOff(zoneId=_zoneId))))
# Turn on wifi bridge lamp
print("Turn on wifi bridge lamp: {}".format(str(milight.turnOnWifiBridgeLamp())))
# Turn off wifi bridge lamp
print("Turn off wifi bridge lamp: {}".format(str(milight.turnOffWifiBridgeLamp())))
# Set night mode in specific zone
print("Set night mode in zone {}: {}".format(str(_zoneId), str(milight.setNightMode(zoneId=_zoneId))))
# Set white mode in specific zone
print("Set white mode in zone {}: {}".format(str(_zoneId), str(milight.setWhiteMode(zoneId=_zoneId))))
# Set white mode for the bridge light
print("Set white mode for the bridge light: {}".format(str(milight.setWhiteModeBridgeLamp())))
# Set specific disco mode in specific zone
print("Set disco mode {} in zone {}: {}".format(str(_discoMode), str(_zoneId), str(milight.setDiscoMode(discoMode=_discoMode, zoneId=_zoneId))))
# Speed up disco mode in specific zone
print("Speed up disco mode in zone {}: {}".format(str(_zoneId), str(milight.speedUpDiscoMode(zoneId=_zoneId))))
# Slow down disco mode in specific zone
print("Slow down disco mode in zone {}: {}".format(str(_zoneId), str(milight.slowDownDiscoMode(zoneId=_zoneId))))
# Set specific disco mode for the bridge light
print("Set disco mode {} for the bridge light: {}".format(str(_discoMode), str(milight.setDiscoModeBridgeLamp(discoMode=_discoMode))))
# Speed up disco mode for the bridge light
print("Speed up disco mode for the bridge light: {}".format(str(milight.speedUpDiscoModeBridgeLamp())))
# Slow down disco mod for the bridge light
print("Slow down disco mode for the bridge light: {}".format(str(milight.slowDownDiscoModeBridgeLamp())))
# Set specific color in specific zone
print("Set color {} in zone {}: {}".format(str(_color), str(_zoneId), str(milight.setColor(color=_color, zoneId=_zoneId))))
# Set specific color for the bridge light
print("Set color {} for the bridge light: {}".format(str(_color), str(milight.setColorBridgeLamp(color=_color))))
# Set specific brightness in specific zone
print("Set brightness {} in zone {}: {}".format(str(_brightness), str(_zoneId), str(milight.setBrightness(brightness=_brightness, zoneId=_zoneId))))
# Set specific brightness for the bridge light
print("Set brightness {} for the bridge light: {}".format(str(_brightness), str(milight.setBrightnessBridgeLamp(brightness=_brightness))))
# Set specific saturation in specific zone
print("Set saturation {} in zone {}: {}".format(str(_saturation), str(_zoneId), str(milight.setSaturation(saturation=_saturation, zoneId=_zoneId))))
# Set specific temperature in specific zone
print("Set temperature {} in zone {}: {}".format(str(_temperature), str(_zoneId), str(milight.setTemperature(temperature=_temperature, zoneId=_zoneId))))
# At the end, close connection with the milight wifi bridge
milight.close()
执照
这个项目是在麻省理工学院许可下。这意味着您可以随意使用它(只是不要删除库头)。
贡献
如果您想添加更多示例或改进库,只需创建一个带有正确提交消息和正确包装的拉取请求。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。
源分布
MilightWifiBridge-2.1.tar.gz
(12.7 kB
查看哈希)
内置分布
MilightWifiBridge-2.1-py3-none-any.whl
(13.4 kB
查看哈希)
关
MilightWifiBridge -2.1.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 747f967f64444cf3ab93bd0f9c208f9af0e127519cd7f52c7705dce8ac7ef999 |
|
MD5 | 80fe0aba6acb5a92469efa0a02ce4ee0 |
|
布莱克2-256 | 9bf92122cd22db7de70d2eb4544b49d7c20c8dc747ee50e06d62c0e6788327c4 |
关
MilightWifiBridge -2.1-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 0520b6969ec056de4034f11a75fa794e4adf10a77380f9ed037171f14a0e3965 |
|
MD5 | 2f77c2f922f07662cb4939b1a0e728b4 |
|
布莱克2-256 | e73b457c9b9dd320e619d9be05510790b08acd2cfc39c4bf05ec989d8918e8b4 |