未知

python-hue-client的Python项目详细描述


https://img.shields.io/pypi/v/python-hue-client.svghttps://img.shields.io/pypi/dm/python-hue-client.svghttps://img.shields.io/github/license/adamcharnock/python-hue-client.svg

飞利浦色调照明系统的全功能python客户端。

安装

使用PIP安装(推荐):

pip install python-hue-client

使用简易安装进行安装:

easy_install python-hue-client

快速启动

这个库大致是根据从django的orm中借用的概念建模的。 github中有一些examples可用,但让我们深入了解一下 以列出所有可用灯光的示例:

from pprint import pprint
from hueclient.api import hue_api
from hueclient.models.light import Light

if __name__ == '__main__':
    hue_api.authenticate_interactive(app_name='List Lights Example')

    for light in Light.objects.all():
        print(
            "Light {id} is named '{name}' and is {onoff} (brightness: {brightness})".format(
                id=light.id,
                name=light.name,
                onoff='on' if light.state.on else 'off',
                brightness=light.state.brightness,
            )
        )

下面是一个闪烁特定灯光的示例:

from time import sleep
from hueclient.api import hue_api
from hueclient.models.light import Light

# examples/blink_light.py
if __name__ == '__main__':
    # Make sure we are authenticated with the hue bridge.
    # You will be prompted if no username is found in ~/.python_hue
    hue_api.authenticate_interactive(app_name='Blink Light Example')

    # Get light ID 1
    light = Light.objects.get(id=1)

    # Loop forever
    while True:
        # Flip the on state from on -> off / off -> on
        light.state.on = not light.state.on

        # Save the state back to the bridge
        # (Note: required in order for your changes to take effect)

        light.state.save()

        # Pause here for a couple of seconds to create a slow blink
        # (Note: It is important to sleep here at least a little to
        # avoid overloading the bridge with API requests)
        sleep(2)

有关更多信息,请参见full documentation

学分

Adam Charnock开发,非常欢迎您的贡献!

python hue客户端使用seed打包。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java将Eclipse中的“查找引用”限制为仅引用我的代码   向Mac Store提交应用程序时出现macos Java错误(不推荐使用API)   与jnpout32pkg/jnpout32reg的java并行端口通信   java是否将应用程序添加到电子邮件附件的内容提供商列表?   java如何关闭外部iframe src   java无法播放整个音频片段   java Android:更改活动的背景颜色(主视图)   Android上的java常量运行控制服务   java绝地武士团结果不等于redis llen   从go或java程序调用c有什么危险?   java如何摆脱OSGi捆绑包的属性,这些属性在相应的配置(“service.pid”等)中不存在?   intellij知道Gradle为什么要编译。java文件,但不创建我的。罐子   节点。js从客户端应用程序(ReactJs+NodeJs)向JavaWeb服务发出请求   限制大小字节[]Java 安卓   java检测传入请求的数据类型   eclipse如何转换一个。txt文件到。csv与Java?   将日期时间从SQLite解析为java时出错。SQL。时间戳   java有没有办法控制类在wildfly中部署的顺序