Aiohue
Asynchronous library to control Philips Hue
Requires Python 3.5 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.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aiohue-2.4.0.tar.gz | 14.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiohue-2.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.6 kB
Release files / aiohue-2.4.0.tar.gz
| Download URL | aiohue-2.4.0.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
59ac159301064d222192f7b58891d39a2f25aab620061ed12e7cfaf1b5d1a6cc
|
|
BLAKE2b-256 checksum How to use checksums |
77471ac2679dc425ffb2b5fdeb07ff9ace8942ae441f52eb7e75bea47a53827d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
|
Release files / aiohue-2.4.0-py3-none-any.whl
| Download URL | aiohue-2.4.0-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e1ab5ece16af58aaac8833c0a3d3534362cd629110ff3e47c067c4c0bb13944
|
|
BLAKE2b-256 checksum How to use checksums |
09c6bbccf421577dce55cc82bb190cc48ee41bed04eb341c3444f4cdf3a25038
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5
|