# Aiohue
## Asynchronous library to control Phlipis 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():
bridges = await discover_nupnp()
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 Phlipis 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():
bridges = await discover_nupnp()
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.
Release files for aiohue 0.3.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-0.3.0.tar.gz | 4.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiohue-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.4 kB
Release files / aiohue-0.3.0.tar.gz
| Download URL | aiohue-0.3.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a8570b5bec1de00a112c858a659a035971dee81973e24f481946503fbbfee0e7
|
|
BLAKE2b-256 checksum How to use checksums |
cd0cacb39187beb7eab92292df632c5784ae39ceacc7fae474f3d9022c321258
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / aiohue-0.3.0-py3-none-any.whl
| Download URL | aiohue-0.3.0-py3-none-any.whl |
|---|---|
| Size | 8.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4188cf42a29c3d2aa84ab2667dc9f8c53002ab47422ec1006bd835b18c422405
|
|
BLAKE2b-256 checksum How to use checksums |
f0a606750d1d4111915b3d27c5dd7fddaec620c66005ae1cd9510a3ff8dec5d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |