hue-entertainment-pykit 0.9.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hue_entertainment_pykit-0.9.4/LICENSE.md +21 -0
- hue_entertainment_pykit-0.9.4/PKG-INFO +186 -0
- hue_entertainment_pykit-0.9.4/README.md +161 -0
- hue_entertainment_pykit-0.9.4/pyproject.toml +44 -0
- hue_entertainment_pykit-0.9.4/setup.cfg +4 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/__init__.py +36 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/api.py +271 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/bridge/__init__.py +0 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/bridge/bridge_repository.py +313 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/bridge/entertainment_configuration_repository.py +129 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/exceptions/__init__.py +0 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/exceptions/api_exception.py +13 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/exceptions/bridge_exception.py +13 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/exceptions/dtls_handshake_exception.py +13 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/models/__init__.py +0 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/models/bridge.py +181 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/models/entertainment_configuration.py +371 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/models/payload.py +84 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/network/__init__.py +0 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/network/dtls.py +252 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/network/mdns.py +112 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/services/__init__.py +0 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/services/discovery_service.py +271 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/services/streaming_service.py +387 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/utils/__init__.py +0 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/utils/converter.py +71 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/utils/file_handler.py +74 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/utils/logger.py +75 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit/utils/status_code.py +18 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit.egg-info/PKG-INFO +186 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit.egg-info/SOURCES.txt +33 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit.egg-info/dependency_links.txt +1 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit.egg-info/requires.txt +10 -0
- hue_entertainment_pykit-0.9.4/src/hue_entertainment_pykit.egg-info/top_level.txt +1 -0
- hue_entertainment_pykit-0.9.4/tests/test_hue_entertainment_pykit.py +203 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Dominik Hrdas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hue-entertainment-pykit
|
|
3
|
+
Version: 0.9.4
|
|
4
|
+
Summary: A comprehensive Python toolkit for Philips Hue Entertainment API
|
|
5
|
+
Author: Dominik Hrdas
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/hrdasdominik/hue-entertainment-pykit
|
|
8
|
+
Keywords: philips,hue,lights,entertainment,api
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Utilities
|
|
14
|
+
Requires-Python: <3.13,>=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE.md
|
|
17
|
+
Requires-Dist: python-mbedtls<3,>=2.10.1
|
|
18
|
+
Requires-Dist: requests<3,>=2.32.5
|
|
19
|
+
Requires-Dist: typing_extensions<5,>=4.8.0; python_version < "3.11"
|
|
20
|
+
Requires-Dist: zeroconf<1,>=0.148.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: flake8<8,>=7; extra == "dev"
|
|
23
|
+
Requires-Dist: pylint<5,>=4; extra == "dev"
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# Hue Entertainment PyKit
|
|
27
|
+

|
|
28
|
+

|
|
29
|
+

|
|
30
|
+

|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
<img align="right" alt="HEPK logo" src="docs/logo/horizontal.png" width="400">
|
|
36
|
+
|
|
37
|
+
## Introduction
|
|
38
|
+
|
|
39
|
+
Unlock the full spectrum of Philips Hue lighting with the Hue Entertainment PyKit. This Python library simplifies connecting to the Hue Bridge and controlling lights with minimal latency, empowering developers to create dynamic and responsive lighting environments.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Motivation
|
|
44
|
+
|
|
45
|
+
Confronted with the complexity of the official Hue EDK and challenges in DTLS handshake implementation which many in the community had, Hue Entertainment PyKit was crafted to provide a straightforward, Python-centric approach to light control using the Philips Hue Entertainment API.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Quick Start
|
|
50
|
+
|
|
51
|
+
### Installing
|
|
52
|
+
|
|
53
|
+
To install Hue Entertainment PyKit, ensure you have Python installed on your system, and then run the following command:
|
|
54
|
+
```sh
|
|
55
|
+
pip install hue-entertainment-pykit
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
__Note:__ Python 3.13 and later are currently unsupported due to ___python-mbedtls___ not yet providing compatible
|
|
59
|
+
wheels. This sucks cause last update was in second quarter of 2024 and it looks like there won't be any anymore.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Usage
|
|
64
|
+
|
|
65
|
+
To interact with your Philips Hue lights you can do:
|
|
66
|
+
|
|
67
|
+
### Logging Configuration (Optional)
|
|
68
|
+
|
|
69
|
+
Hue Entertainment PyKit configures logging **only for its own logger namespace**
|
|
70
|
+
(`hue_entertainment_pykit.*`). It does not modify the root logger.
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
import logging
|
|
74
|
+
from hue_entertainment_pykit import setup_logs
|
|
75
|
+
|
|
76
|
+
# Enable library logging with the default formatter and handlers
|
|
77
|
+
setup_logs()
|
|
78
|
+
|
|
79
|
+
# Or customize the logging level (e.g., exclude DEBUG messages)
|
|
80
|
+
setup_logs(level=logging.INFO)
|
|
81
|
+
|
|
82
|
+
# You can also further customize logging by specifying the maximum log file size and the number of backup files
|
|
83
|
+
setup_logs(level=logging.INFO, max_file_size=1024 * 1024, backup_count=1)
|
|
84
|
+
|
|
85
|
+
# Each parameter is optional and comes with predefined default values
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
To log messages from your own application code in the same format, use a
|
|
89
|
+
named logger under the same namespace:
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
import logging
|
|
93
|
+
|
|
94
|
+
logger = logging.getLogger("hue_entertainment_pykit.example")
|
|
95
|
+
logger.info("Example started")
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
If you prefer to use logging.info(...) (root logger), configure it separately:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
import logging
|
|
102
|
+
logging.basicConfig(level=logging.INFO)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
#### Silencing noisy third-party logs
|
|
106
|
+
|
|
107
|
+
Some dependencies (e.g. `urllib3`, `zeroconf`) may emit verbose DEBUG logs if
|
|
108
|
+
root logging is enabled. You can reduce noise like this:
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
import logging
|
|
112
|
+
|
|
113
|
+
logging.getLogger("urllib3").setLevel(logging.WARNING)
|
|
114
|
+
logging.getLogger("zeroconf").setLevel(logging.WARNING)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Discovery (Optional)
|
|
118
|
+
|
|
119
|
+
Use only on your Local Area Network (LAN) to discover and fetch all Bridges that can be used then for streaming
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from hue_entertainment_pykit import Discovery
|
|
123
|
+
|
|
124
|
+
discovery = Discovery()
|
|
125
|
+
|
|
126
|
+
# returns dict[str, Bridge] where the key is name of the bridge and value is the Bridge model with all important info for connecting to Entertainment API
|
|
127
|
+
bridges = discovery.discover_bridges()
|
|
128
|
+
```
|
|
129
|
+
### Streaming
|
|
130
|
+
|
|
131
|
+
The Streaming service in Hue Entertainment PyKit provides thread-safe communication with Hue lights, ensuring smooth and uninterrupted interactions. To prevent connection timeouts, the service implements a keep-alive feature: if no command is sent for 9.5 seconds, the last message is automatically resent to maintain the connection.
|
|
132
|
+
|
|
133
|
+
Below is a streamlined example to set up and manage your streaming session:
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
import time
|
|
137
|
+
from hue_entertainment_pykit import create_bridge, Entertainment, Streaming
|
|
138
|
+
|
|
139
|
+
# Set up the Bridge instance with the all needed configuration
|
|
140
|
+
bridge = create_bridge(
|
|
141
|
+
identification="4abb74df-5b6b-410e-819b-bf4448355dff",
|
|
142
|
+
rid="d476df48-83ad-4430-a104-53c30b46b4d0",
|
|
143
|
+
ip_address="192.168.1.100",
|
|
144
|
+
swversion=1962097030,
|
|
145
|
+
username="8nuTIcK2nOf5oi88-5zPvV1YCt0wTHZIGG8MwXpu",
|
|
146
|
+
hue_app_id="94530efc-933a-4f7c-97e5-ccf1a9fc79af",
|
|
147
|
+
clientkey="B42753E1E1605A1AB90E1B6A0ECF9C51",
|
|
148
|
+
name="1st Bridge"
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# Set up the Entertainment API service
|
|
152
|
+
entertainment_service = Entertainment(bridge)
|
|
153
|
+
|
|
154
|
+
# Fetch all Entertainment Configurations on the Hue bridge
|
|
155
|
+
entertainment_configs = entertainment_service.get_entertainment_configs()
|
|
156
|
+
|
|
157
|
+
# Add some Entertainment Area selection logic
|
|
158
|
+
# For the purposes of example I'm going to do manual selection
|
|
159
|
+
entertainment_config = list(entertainment_configs.values())[0]
|
|
160
|
+
|
|
161
|
+
# Set up the Streaming service
|
|
162
|
+
streaming = Streaming(
|
|
163
|
+
bridge, entertainment_config, entertainment_service.get_ent_conf_repo()
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
# Start streaming messages to the bridge
|
|
167
|
+
streaming.start_stream()
|
|
168
|
+
|
|
169
|
+
# Set the color space to xyb or rgb
|
|
170
|
+
streaming.set_color_space("xyb")
|
|
171
|
+
|
|
172
|
+
# Set input commands for the lights
|
|
173
|
+
# First three values in the tuple are placeholders for the color RGB8(int) or (in this case) XYB(float) and the last integer is light ID inside the Entertainment API
|
|
174
|
+
streaming.set_input((0.0, 0.63435, 0.3, 0)) # Light command for the first light
|
|
175
|
+
streaming.set_input((0.63435, 0.0, 0.3, 1)) # Light command for the second light
|
|
176
|
+
# ... Add more inputs as needed for additional lights and logic
|
|
177
|
+
|
|
178
|
+
# For the purpose of example sleep is used for all inputs to process before stop_stream is called
|
|
179
|
+
# Inputs are set inside Event queue meaning they're on another thread so user can interact with application continuously
|
|
180
|
+
time.sleep(0.1)
|
|
181
|
+
|
|
182
|
+
# Stop the streaming session
|
|
183
|
+
streaming.stop_stream()
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Replace the placeholders in the `set_input` method with actual light IDs and the color and brightness values you intend to use. The `start_stream` method initiates the streaming session, `set_color_space` configures the color space, and `stop_stream` terminates the session.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Hue Entertainment PyKit
|
|
2
|
+

|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
<img align="right" alt="HEPK logo" src="docs/logo/horizontal.png" width="400">
|
|
11
|
+
|
|
12
|
+
## Introduction
|
|
13
|
+
|
|
14
|
+
Unlock the full spectrum of Philips Hue lighting with the Hue Entertainment PyKit. This Python library simplifies connecting to the Hue Bridge and controlling lights with minimal latency, empowering developers to create dynamic and responsive lighting environments.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Motivation
|
|
19
|
+
|
|
20
|
+
Confronted with the complexity of the official Hue EDK and challenges in DTLS handshake implementation which many in the community had, Hue Entertainment PyKit was crafted to provide a straightforward, Python-centric approach to light control using the Philips Hue Entertainment API.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
### Installing
|
|
27
|
+
|
|
28
|
+
To install Hue Entertainment PyKit, ensure you have Python installed on your system, and then run the following command:
|
|
29
|
+
```sh
|
|
30
|
+
pip install hue-entertainment-pykit
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
__Note:__ Python 3.13 and later are currently unsupported due to ___python-mbedtls___ not yet providing compatible
|
|
34
|
+
wheels. This sucks cause last update was in second quarter of 2024 and it looks like there won't be any anymore.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
To interact with your Philips Hue lights you can do:
|
|
41
|
+
|
|
42
|
+
### Logging Configuration (Optional)
|
|
43
|
+
|
|
44
|
+
Hue Entertainment PyKit configures logging **only for its own logger namespace**
|
|
45
|
+
(`hue_entertainment_pykit.*`). It does not modify the root logger.
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
import logging
|
|
49
|
+
from hue_entertainment_pykit import setup_logs
|
|
50
|
+
|
|
51
|
+
# Enable library logging with the default formatter and handlers
|
|
52
|
+
setup_logs()
|
|
53
|
+
|
|
54
|
+
# Or customize the logging level (e.g., exclude DEBUG messages)
|
|
55
|
+
setup_logs(level=logging.INFO)
|
|
56
|
+
|
|
57
|
+
# You can also further customize logging by specifying the maximum log file size and the number of backup files
|
|
58
|
+
setup_logs(level=logging.INFO, max_file_size=1024 * 1024, backup_count=1)
|
|
59
|
+
|
|
60
|
+
# Each parameter is optional and comes with predefined default values
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
To log messages from your own application code in the same format, use a
|
|
64
|
+
named logger under the same namespace:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
import logging
|
|
68
|
+
|
|
69
|
+
logger = logging.getLogger("hue_entertainment_pykit.example")
|
|
70
|
+
logger.info("Example started")
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
If you prefer to use logging.info(...) (root logger), configure it separately:
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
import logging
|
|
77
|
+
logging.basicConfig(level=logging.INFO)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Silencing noisy third-party logs
|
|
81
|
+
|
|
82
|
+
Some dependencies (e.g. `urllib3`, `zeroconf`) may emit verbose DEBUG logs if
|
|
83
|
+
root logging is enabled. You can reduce noise like this:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
import logging
|
|
87
|
+
|
|
88
|
+
logging.getLogger("urllib3").setLevel(logging.WARNING)
|
|
89
|
+
logging.getLogger("zeroconf").setLevel(logging.WARNING)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Discovery (Optional)
|
|
93
|
+
|
|
94
|
+
Use only on your Local Area Network (LAN) to discover and fetch all Bridges that can be used then for streaming
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from hue_entertainment_pykit import Discovery
|
|
98
|
+
|
|
99
|
+
discovery = Discovery()
|
|
100
|
+
|
|
101
|
+
# returns dict[str, Bridge] where the key is name of the bridge and value is the Bridge model with all important info for connecting to Entertainment API
|
|
102
|
+
bridges = discovery.discover_bridges()
|
|
103
|
+
```
|
|
104
|
+
### Streaming
|
|
105
|
+
|
|
106
|
+
The Streaming service in Hue Entertainment PyKit provides thread-safe communication with Hue lights, ensuring smooth and uninterrupted interactions. To prevent connection timeouts, the service implements a keep-alive feature: if no command is sent for 9.5 seconds, the last message is automatically resent to maintain the connection.
|
|
107
|
+
|
|
108
|
+
Below is a streamlined example to set up and manage your streaming session:
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
import time
|
|
112
|
+
from hue_entertainment_pykit import create_bridge, Entertainment, Streaming
|
|
113
|
+
|
|
114
|
+
# Set up the Bridge instance with the all needed configuration
|
|
115
|
+
bridge = create_bridge(
|
|
116
|
+
identification="4abb74df-5b6b-410e-819b-bf4448355dff",
|
|
117
|
+
rid="d476df48-83ad-4430-a104-53c30b46b4d0",
|
|
118
|
+
ip_address="192.168.1.100",
|
|
119
|
+
swversion=1962097030,
|
|
120
|
+
username="8nuTIcK2nOf5oi88-5zPvV1YCt0wTHZIGG8MwXpu",
|
|
121
|
+
hue_app_id="94530efc-933a-4f7c-97e5-ccf1a9fc79af",
|
|
122
|
+
clientkey="B42753E1E1605A1AB90E1B6A0ECF9C51",
|
|
123
|
+
name="1st Bridge"
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
# Set up the Entertainment API service
|
|
127
|
+
entertainment_service = Entertainment(bridge)
|
|
128
|
+
|
|
129
|
+
# Fetch all Entertainment Configurations on the Hue bridge
|
|
130
|
+
entertainment_configs = entertainment_service.get_entertainment_configs()
|
|
131
|
+
|
|
132
|
+
# Add some Entertainment Area selection logic
|
|
133
|
+
# For the purposes of example I'm going to do manual selection
|
|
134
|
+
entertainment_config = list(entertainment_configs.values())[0]
|
|
135
|
+
|
|
136
|
+
# Set up the Streaming service
|
|
137
|
+
streaming = Streaming(
|
|
138
|
+
bridge, entertainment_config, entertainment_service.get_ent_conf_repo()
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
# Start streaming messages to the bridge
|
|
142
|
+
streaming.start_stream()
|
|
143
|
+
|
|
144
|
+
# Set the color space to xyb or rgb
|
|
145
|
+
streaming.set_color_space("xyb")
|
|
146
|
+
|
|
147
|
+
# Set input commands for the lights
|
|
148
|
+
# First three values in the tuple are placeholders for the color RGB8(int) or (in this case) XYB(float) and the last integer is light ID inside the Entertainment API
|
|
149
|
+
streaming.set_input((0.0, 0.63435, 0.3, 0)) # Light command for the first light
|
|
150
|
+
streaming.set_input((0.63435, 0.0, 0.3, 1)) # Light command for the second light
|
|
151
|
+
# ... Add more inputs as needed for additional lights and logic
|
|
152
|
+
|
|
153
|
+
# For the purpose of example sleep is used for all inputs to process before stop_stream is called
|
|
154
|
+
# Inputs are set inside Event queue meaning they're on another thread so user can interact with application continuously
|
|
155
|
+
time.sleep(0.1)
|
|
156
|
+
|
|
157
|
+
# Stop the streaming session
|
|
158
|
+
streaming.stop_stream()
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Replace the placeholders in the `set_input` method with actual light IDs and the color and brightness values you intend to use. The `start_stream` method initiates the streaming session, `set_color_space` configures the color space, and `stop_stream` terminates the session.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=75.2.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "hue-entertainment-pykit"
|
|
7
|
+
version = "0.9.4"
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "Dominik Hrdas"}
|
|
10
|
+
]
|
|
11
|
+
description = "A comprehensive Python toolkit for Philips Hue Entertainment API"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
license = "MIT"
|
|
14
|
+
license-files = ["LICENSE.md"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3.10",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Operating System :: OS Independent",
|
|
20
|
+
"Topic :: Utilities"
|
|
21
|
+
]
|
|
22
|
+
requires-python = ">=3.10, <3.13"
|
|
23
|
+
dependencies = [
|
|
24
|
+
"python-mbedtls>=2.10.1, <3",
|
|
25
|
+
"requests>=2.32.5, <3",
|
|
26
|
+
"typing_extensions>=4.8.0, <5; python_version < '3.11'",
|
|
27
|
+
"zeroconf>=0.148.0, <1"
|
|
28
|
+
]
|
|
29
|
+
keywords = ["philips", "hue", "lights", "entertainment", "api"]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
dev = [
|
|
33
|
+
"flake8>=7, <8",
|
|
34
|
+
"pylint>=4, <5"
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Repository = "https://github.com/hrdasdominik/hue-entertainment-pykit"
|
|
39
|
+
|
|
40
|
+
[tool.setuptools]
|
|
41
|
+
package-dir = {"" = "src"}
|
|
42
|
+
|
|
43
|
+
[tool.setuptools.packages.find]
|
|
44
|
+
where = ["src"]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The `hue_entertainment_pykit` module offers a suite of tools designed to interface with
|
|
3
|
+
Philips Hue Entertainment capabilities. It provides high-level abstractions to discover and interact with Hue bridges,
|
|
4
|
+
manage entertainment configurations, and create responsive lighting experiences.
|
|
5
|
+
|
|
6
|
+
Available Classes and Functions:
|
|
7
|
+
- `Discovery`: A utility class to discover Hue bridges on the local network. It simplifies the process of finding and
|
|
8
|
+
connecting to available Hue bridges without needing to deal with network details.
|
|
9
|
+
- `Streaming`: Facilitates the creation of entertainment sessions, allowing for the control of Hue lights in real-time
|
|
10
|
+
for dynamic lighting effects synchronized with media or games.
|
|
11
|
+
- `create_bridge`: A factory function to instantiate a `Bridge` object, which represents a physical Hue bridge device
|
|
12
|
+
and serves as the central point of communication with the Hue system.
|
|
13
|
+
- `Bridge`: Represents a Philips Hue bridge. It provides methods to interact with the bridge, such as authenticating,
|
|
14
|
+
sending commands, and querying for connected lights and sensors.
|
|
15
|
+
- `EntertainmentConfiguration`: Encapsulates the configuration necessary for setting up entertainment areas,
|
|
16
|
+
defining which lights are used, and how they react during an entertainment session.
|
|
17
|
+
- `setup_logs`: Simplifies the logging setup process for the entire package, allowing for easy initialization of
|
|
18
|
+
logging with customizable settings for file size, backup counts, and log levels.
|
|
19
|
+
|
|
20
|
+
This module abstracts the complexities involved in directly handling the Hue Entertainment API and provides a
|
|
21
|
+
streamlined interface for building applications that can create immersive lighting experiences.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from .api import Discovery, Streaming, create_bridge, setup_logs, Entertainment
|
|
25
|
+
from .models.bridge import Bridge
|
|
26
|
+
from .models.entertainment_configuration import EntertainmentConfiguration
|
|
27
|
+
|
|
28
|
+
__all__ = [
|
|
29
|
+
"Discovery",
|
|
30
|
+
"Streaming",
|
|
31
|
+
"create_bridge",
|
|
32
|
+
"setup_logs",
|
|
33
|
+
"Bridge",
|
|
34
|
+
"EntertainmentConfiguration",
|
|
35
|
+
"Entertainment",
|
|
36
|
+
]
|