Skip to main content

Aiohue

Asynchronous library to control Philips Hue

Requires Python 3.8+ and uses asyncio and aiohttp.

import asyncio
from pprint import pprint

import aiohttp
from aiohue.discovery import discover_nupnp


async def main():
    async with aiohttp.ClientSession() as session:
        await run(session)


async def run(websession):
    bridges = await discover_nupnp(websession)

    bridge = bridges[0]
    await bridge.create_user('aiophue-example')
    print('Your username is', bridge.username)

    await bridge.initialize()

    print('Name', bridge.config.name)
    print('Mac', bridge.config.mac)

    print()
    print('Lights:')
    for id in bridge.lights:
        light = bridge.lights[id]
        print('{}: {}'.format(light.name, 'on' if light.state['on'] else 'off'))

    # Change state of a light.
    await light.set_state(on=not light.state['on'])

    print()
    print('Groups:')
    for id in bridge.groups:
        group = bridge.groups[id]
        print('{}: {}'.format(group.name, 'on' if group.action['on'] else 'off'))

    # Change state of a group.
    await group.set_action(on=not group.state['on'])


asyncio.run(main())

Timeouts

Aiohue does not specify any timeouts for any requests. You will need to specify them in your own code. We recommend the async_timeout package:

import async_timeout

with async_timeout.timeout(10):
    await bridge.initialize()

Contribution guidelines

Object hierarchy and property/method names should match the Philips Hue API.

Metadata

Release files for aiohue 2.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiohue 2.6.0
File Size Uploaded Provenance Actions
aiohue-2.6.0.tar.gz 15.1 kB Without provenance Details for aiohue-2.6.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aiohue 2.6.0
File Interpreter ABI Platform Actions
aiohue-2.6.0-py3-none-any.whl Python 3 none any Details for aiohue-2.6.0-py3-none-any.whl

Total release size: 33.0 kB

Release files / aiohue-2.6.0.tar.gz

Download URL aiohue-2.6.0.tar.gz
Size 15.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e4b781403e7dd891733334b7b5d41053196eaf80809b15421d5b82695580561d
BLAKE2b-256 checksum
How to use checksums
d4bb0ba4acb7ffd2cf0d32ba0c594b85a4558bc6dbb00ba1d54f93cd0f2fcc19
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

Release files / aiohue-2.6.0-py3-none-any.whl

Download URL aiohue-2.6.0-py3-none-any.whl
Size 17.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e916d0de6d28248853713e4775bf72fe77fab4339c3b22d3dad9083846ed1d4
BLAKE2b-256 checksum
How to use checksums
b81b581ea616bc99d932bb335907be04c255de0cc4c31f9870f81732c14e5e26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

Security for aiohue 2.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.6.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page