未知

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第三方库


热门话题
NetBeans中的Java Swing滚动窗格   java如何与具有复合键的表建立关系?   Android中读取文件时java数据丢失   java黄瓜场景。embed在ubuntu机器上不工作?   java从spring mvc控制器操作中,我如何获得请求/响应的访问权限?   java减去两个长值   java选择下一个值firebase 安卓   用于起始和结尾连字符的java正则表达式   Java正则表达式解释   java Lifefay freemarker ADT:方法不可用?   java我怎样才能让我的开关盒作用于JFrame?   java在我的场景中使用连接池的理想方式是什么   java我如何接受jsoup的cookies?   java如何将整数数组更改为字符串数组?   java Android操作\u指针\u向上直到剩余触摸移动时才调用   java为什么gradle会出错?   io如何在java中复制/拆分输入流?   java使JButton不可见,但尊重其原始空间   java Spring提交表单获取复选框值不起作用