Skip to main content

Async API for controlling Hue Lights

Project description

Hue API

Async API for controlling Hue Lights

PyPI

Installation

This is an async client for interacting with the Hue Bridge API, to control Hue Lights.

The minimum Python version required to run this is 3.9

Install the package using pip:

pip install hue-api

Create a .env file in your project root, with variables:

HUE_BRIDGE_IP=192.168.x.x
HUE_BRIDGE_USER=xxxxxxxxxx

Usage

from hue import api

# Set the light id to control
light = 1

# from an async function
async def main():
  await api.switch_on(light)

# or from a sync context
import asyncio
asyncio.run(api.switch_on(light))

Available methods

  • switch_on(light: int) -> bool

    Turn light on

  • switch_off(light: int) -> bool

    Turn light off

  • get_light(light: int) -> dict[Any]

    Get all the information about light

  • get_state(light: int) -> dict[Any]

    Get the current state of light

  • set_state(light: int, state: dict[Any]) -> tuple[bool, dict[Any]]

    Set the state of light

    Input values of "bri", "hue", "sat", "xy", "ct" in state

    Returns the success value and the current state

  • save_state(light: int) -> dict[Any]

    Save the current state of light

  • restore_state(light: int) -> dict[Any]

    Restore the last saved state of light

Changelog

All notable changes to this project will be documented in this file. The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Unreleased

0.1.1 (2021-04-15)

Added

  • Add documentation

Fixed

  • Fix minimum python version required 3.9
  • Fix tox tests

0.1.0 (2021-04-15)

  • First release

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

hue-api-0.1.1.tar.gz (8.1 kB view hashes)

Uploaded Source

Built Distribution

hue_api-0.1.1-py2.py3-none-any.whl (7.6 kB view hashes)

Uploaded Python 2 Python 3

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