Python Hue V2
Python library to control the Philips Hue lighting system for Hue-V2 API.
Features
- Design for Hue API 2.0
High Level Control
Simple Example
import time
from python_hue_v2 import Hue, BridgeFinder
finder = BridgeFinder()
time.sleep(1) # wait for search
# Get server by mdns
host_name = finder.get_bridge_server_lists()[0] # Here we use first Hue Bridge
# or hue = Hue('ip address','app-key')
hue = Hue(host_name, 'hue app key') # create Hue instance
lights = hue.lights
for light in lights:
print(light.on)
light.on = True
light.brightness = 80.0
Scenes
You can get scenes from hue bridge.
from python_hue_v2 import Hue
hue = Hue('bridge-ip', 'app-key')
scenes = hue.scenes
for scene in scenes:
print(scene.id)
print(scene.data_dict)
Recall scene using active, dynamic_palette, static.
scene = scenes[0]
scene.recall(action='active')
If you want create one scene with light actions in a room:
from python_hue_v2.scene import ActionPost, ScenePost
light_id = []
lights = hue.lights
for light in lights:
light_id.append(light.light_id)
actions = []
for rid in light_id:
actions.append(
ActionPost.create_by_parameters(
target_rid=rid,
target_rtype='light',
on=True,
brightness=50,
color_xy=(0.1, 0.3) # xy color tuple
# mirek=200 % or use mirek
)
)
# Get all rooms, may be empty
rooms = hue.rooms
# ScenePost should have a group property, Here we bind with a room
# refer to https://developers.meethue.com/develop/hue-api-v2/api-reference/#resource_scene_post
# Group associated with this Scene. All services in the group are part of this scene.
# If the group is changed the scene is update (e.g. light added/removed)
scene_post: ScenePost = ScenePost.create_by_parameters(
actions=actions, name='test', group_rid=rooms[0].id, group_rtype="room"
)
hue.create_scene(scene_post)
Also, you can delete scene by id.
hue.delete_scene('scene-id-example')
Grouped Light
Get group Lights from hue.
from python_hue_v2 import Hue
hue = Hue('bridge-ip', 'app-key')
grouped_lights = hue.grouped_lights
for group in grouped_lights:
print(group.type)
group.on = True
Low Level Control
Also, you can use basic function in bridge class.
import time
from python_hue_v2 import Hue
# or hue = Hue('ip address','app-key')
hue = Hue('host_name', 'hue app key') # create Hue instance
bridge = hue.bridge
bridge.get_lights()
bridge.set_light('id', light_property_name='on', property_value={'on': True})
bridge.get_zones()
Attention
Some API may be de deprecated When major version updates.
TODO
- Zones Control Class
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_hue_v2-1.0.1.tar.gz.
File metadata
- Download URL: python_hue_v2-1.0.1.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53b96d86d99f9b1dc8977927b33b55327fa4a068b960aa20d5df6d2cc4fc23ac
|
|
| MD5 |
e8758dbd1418e6085bc0e1a0270c7343
|
|
| BLAKE2b-256 |
9455935f019667350e8cb9fea4cb0b032491d142782805b5df84e09c18f46097
|
File details
Details for the file python_hue_v2-1.0.1-py3-none-any.whl.
File metadata
- Download URL: python_hue_v2-1.0.1-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
838f7b0e68cc04bace4955e08d6906b5d8c11050300cb4d250402de4791a59c5
|
|
| MD5 |
b1e8e47fc71ca3062a63ab731327169e
|
|
| BLAKE2b-256 |
68b28bfc2e1fed7b84f7583d30b06909cde46cdac74067e7aaa5ca78e6005470
|