Python module to talk to Philips Hue.
Project description
# 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():
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 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():
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiohue-1.0.0.tar.gz
(4.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiohue-1.0.0.tar.gz.
File metadata
- Download URL: aiohue-1.0.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9724e21db3e1cd94beaa82a17aaa7142f505955cd48c89bdd423c2b933b98138
|
|
| MD5 |
88346098199b61146175962c906d1231
|
|
| BLAKE2b-256 |
beda03b3b5b2212406ac75efe51e75defdaebef565007ff3e357958ff6e66df3
|
File details
Details for the file aiohue-1.0.0-py3-none-any.whl.
File metadata
- Download URL: aiohue-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ea4cdb596d13fd4855f37d97f926dc2c3fda21396a57013d0ee62207f3d1f57
|
|
| MD5 |
46163308119b6a8df820c32d3d837f87
|
|
| BLAKE2b-256 |
7cfb2e182869bf0b4403533759cbe150037004c47ef510a478fc72479e8ebf0c
|