Python3 Module for controlling Philips Hue lights
Project description
Python3 Module for controlling Philips Hue lights.
Quick Start Guide:
Installation:
without VirtualENV:
python3 -m pip install py3-PyHue
with VirtualENV:
Windows:
.\<envname>\Scripts\python.exe -m pip install py3-PyHue
Linux:
./<envname>/bin/python3 -m pip install py3-PyHue
Setup:
Here you have 2 options: Either the Auto-Discovery or the manual setting!
Auto-Discovery:
from PyHue import *
bridge = Bridge()
Manual:
from PyHue import *
bridge = Bridge(ip='<your ip address>')
Now a new instance of the Hue class is created. If you already used this package, you will notice, that the package will automagicaly connect to the Hue bridge. To restart the discovery process, stop the Python3 script and delete the file '.cached_ip_important' from the root directory (i.e. There, where the main script is located).
After a bridge was discovered, the authentication process will start. You will have to press the button on the front of the Bridge. After that, press the enter key to proceed. After this process you will have a new file '.cached_username_important' in the root directory.
Now you can start coding!
Usage:
All of the available methods are described in the documentation! (It's linked above! You should really check it out!)
To list all lights, you can use this!:
from PyHue import *
bridge = Bridge()
print(bridge.get_all_lights())
But for example, to toggle the light with the id '1', you can use the following code:
from PyHue import *
bridge = Bridge()
light = Lights(bridge, 1)
light.toggle_power()
To turn the light on, use this: (In this case using light-id '1' again)
from PyHue import *
bridge = Bridge()
light = Lights(bridge, 1)
light.power = True
# or to turn it off:
light.power = False
Finally, if you want to make custom API-Requests, you should use this:
from PyHue import *
bridge = Bridge()
print(bridge.api_request('<METHOD>', '<ENDPOINT>', <body (dict)>))
Happy Coding!
More information is in the Docs linked above!
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 Distributions
Built Distribution
File details
Details for the file py3_PyHue-0.2a0-py3-none-any.whl
.
File metadata
- Download URL: py3_PyHue-0.2a0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 218087adb182200fbdac05e88da361001eeb666093b0abdafbff46214778abde |
|
MD5 | 47fdd18d89332626dff838b53c3c9512 |
|
BLAKE2b-256 | d2e08e1371456fa994eb53932ebc59617629ecd3a315686a73a1acc743af96e7 |