# Aiohue
## Asynchronous library to control Philips Hue
Requires Python 3.5 and uses asyncio and aiohttp.
```python
import asyncio
from pprint import pprint
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.get_event_loop().run_until_complete(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:
```python
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.
## Asynchronous library to control Philips Hue
Requires Python 3.5 and uses asyncio and aiohttp.
```python
import asyncio
from pprint import pprint
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.get_event_loop().run_until_complete(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:
```python
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 1.1.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-1.1.0.tar.gz | 4.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiohue-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.9 kB
Release files / aiohue-1.1.0.tar.gz
| Download URL | aiohue-1.1.0.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7b0c576c74d4b36d6089198f2aec4b2be1d156af319e1ebcc609520d95fdd384
|
|
BLAKE2b-256 checksum How to use checksums |
c0c619375bf63563130fd1f7d51a7644695297ed646a163e4052f2a217e1f7ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / aiohue-1.1.0-py3-none-any.whl
| Download URL | aiohue-1.1.0-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
72f00fda88e886e2cb9c75a51f60201aa43fea6195a1c7f5aee59be473da730e
|
|
BLAKE2b-256 checksum How to use checksums |
a81f8adb56d7a4d072e3e7c52d2e7840fbbd64debe1224ab5dd25753430d4ade
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |