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 Hue
hue = Hue()
Manual:
from PyHue import Hue
hue = Hue(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 Hue
hue = Hue()
print(hue.get_all_lights())
But for example, to toggle the light with the id '1', you can use the following code:
from PyHue import Hue
hue = Hue()
hue.toggle_light(1)
To set the lights on/off state, use this:
from PyHue import Hue
hue = Hue()
hue.set_light(1, bool("<onOff>"))
Finally, if you want to make custom API-Requests, you should use this:
from PyHue import Hue
hue = Hue()
print(hue.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 Distribution
Built Distribution
Hashes for py3_PyHue-0.1a4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | daa18c1c2699b80938f6659ba519a772144dee030e296b6fb1de75782fde32e8 |
|
MD5 | 2434f211c8af2a4c9db03533bc9ac5df |
|
BLAKE2b-256 | 67c34440a94e7c8af2b7ce084e7cdf1064ca673e77de92307fa362ad943b3b92 |