跳转到主要内容

未知

项目描述

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

Philips Hue照明系统的功能齐全的Python客户端。

安装

使用pip安装(推荐)

pip install python-hue-client

使用easy_install安装

easy_install python-hue-client

文档

文档可在http://python-hue-client.readthedocs.org找到

快速入门

此库大致基于从Django的ORM借用的一些概念。GitHub上有一些示例,但让我们从一个列出所有可用灯泡的示例开始。

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)

有关更多信息,请参阅完整文档

致谢

Adam Charnock开发,非常欢迎贡献力量!

python-hue-client使用seed打包。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

python-hue-client-0.1.0.tar.gz (917.0 kB 查看哈希值)

上传时间:

构建分布

python_hue_client-0.1.0-cp27-none-macosx_10_10_x86_64.whl (4.6 kB 查看哈希值)

上传于 CPython 2.7 macOS 10.10+ x86-64

由以下支持