Git Product home page Git Product logo

hue-api's Introduction

Hue API

Async API and CLI tools for interacting with Hue Lights

Python Tests Publish Package Python Versions Package Version

Documentation: hue-api.nirantak.com

Source: github.com/nirantak/hue-api

Installation

This is an async client to interact with the Hue Bridge API.

The minimum Python version required to run this is 3.8

Install the package using pip:

pip install hue-api

Usage

Follow this link to create a Hue API user if not already known (API reference)

Using the CLI

hue --help

# Get the version of hue-api installed
hue version

# To find your Hue Bridge IP address go to discovery.meethue.com, or run:
hue bridge discover

Using the API

from hue import Bridge, Light

# Create a light object with the light id (number), Bridge IP and user
light = Light(1, ip="your-hue-bridge-ip", user="hue-api-user")

# from an async function
async def main():
  await Bridge.discover()
  await light.power_on()

# or from a sync context
import asyncio
asyncio.run(Bridge.discover())
asyncio.run(light.power_on())

Changelog

See the file CHANGELOG.md

License

This project is licensed under the terms of the MIT license

hue-api's People

Contributors

dependabot[bot] avatar nirantak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hue-api's Issues

Add More Items to set_state()

Hi Nirantak,
Thanks so much for such a well written library and for keeping it up to date.

I was wondering if you had any plans to add the rest of the available states to the set_state() Light method?
Your library is amazing, but only supports a small number of state changes. I'd love to allow for effects, alert and colormode.

Is this something you'd be interested in adding? If not, can you tell me what the best way to go about it is? Is it as simple as adding the required keys in the method on line 101?

Many thanks again for all the time you put into this (and for the type hints).

set_state strange behaviour

Description

  • Hue API version: version = "0.4.8"
  • Python version: Python 3.11.6
  • Operating System: Arch linux

Thanks for this library !
I'm hooking my lights up to my StreamDeck +, and ran into this issue.

On initital get_state I end up with something like this ::

state = {"on": True, "bri": 228, "hue": 8378, "sat": 212, "effect": "none", "xy": [0.4976, 0.4266], "ct": 350, "alert": "select", "colormode": "hs", "mode": "homeautomation", "reachable": True}

I updated the "bri" value and set_state(state).
It set the full state as expected, but the light was kind of flashing and struggling with the info,
so I read a bit further and it looks like you can just update what you want as in , via asyncio: light.set_state({ "bri": 123 })

So I tried that, adn now the get_state call looks very different, even after a light.restore_state().

{"on": true, "bri": 213, "alert": "select", "mode": "homeautomation", "reachable": false

Everything else is gone.
Is that as expected?

Do I need to set a certain combination of parameters per mode?
I went through the developer docs and couldn't see anything on this.

Happy to send more data / run tests if it helps :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.