Skip to main content

Python module to talk to Philips Hue.

Project description


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('Mac', bridge.config.mac)

    for id in bridge.lights:
        light = bridge.lights[id]
        print('{}: {}'.format(, 'on' if light.state['on'] else 'off'))

    # Change state of a light.
    await light.set_state(on=not light.state['on'])

    for id in bridge.groups:
        group = bridge.groups[id]
        print('{}: {}'.format(, 'on' if group.action['on'] else 'off'))

    # Change state of a group.
    await group.set_action(on=not group.state['on'])


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.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for aiohue, version 2.2.0
Filename, size File type Python version Upload date Hashes
Filename, size aiohue-2.2.0-py3-none-any.whl (14.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size aiohue-2.2.0.tar.gz (8.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page