Skip to main content

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():
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.

Project details


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.3.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

aiohue-1.3.1-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file aiohue-1.3.1.tar.gz.

File metadata

  • Download URL: aiohue-1.3.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiohue-1.3.1.tar.gz
Algorithm Hash digest
SHA256 d00b849a29778f82a80143fbeb183f2b40d0dd64e59a4e1f4432ae7f91746215
MD5 7aa84f0bf9fed9caa23ccc598f6d8065
BLAKE2b-256 c0d900ffdce0b85ce9694f6e5f426104a1210a8b89f7ec4db6c5f0def6ea845c

See more details on using hashes here.

File details

Details for the file aiohue-1.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aiohue-1.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31effc90de23dccd7054502ef2a5f92d7a4aed04ae8e3464f2c70685185c03b0
MD5 bf9261b979f723496415119cfa1a96ce
BLAKE2b-256 a1f2da2129ea6005256accdc4af0a5bda487ec1c598374adebe5572dfa0928aa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page