phue2 0.0.1.dev279__tar.gz → 0.0.1.dev280__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.
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/PKG-INFO +1 -1
- phue2-0.0.1.dev280/examples/repros/smart_home.py +53 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/src/phue2/scene.py +2 -0
- phue2-0.0.1.dev280/tests/test_scene.py +65 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/.github/workflows/lint.yml +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/.github/workflows/publish.yml +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/.github/workflows/test.yml +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/.gitignore +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/.pre-commit-config.yaml +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/LICENSE +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/README.md +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/examples/connect_bridge.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/examples/flicker.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/examples/hue-rainbow.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/examples/random_colors.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/examples/rgb_colors.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/examples/sine_wave_lights.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/examples/tk_gui_complex.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/examples/tk_gui_hsb.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/examples/tk_gui_simple.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/justfile +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/pyproject.toml +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/src/phue2/__init__.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/src/phue2/__main__.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/src/phue2/_internal/__init__.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/src/phue2/_internal/console.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/src/phue2/bridge.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/src/phue2/exceptions.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/src/phue2/group.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/src/phue2/light.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/src/phue2/sensor.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/tests/__init__.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/tests/samples.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/tests/test_basic_import.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/tests/test_bridge.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/tests/test_cli.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/tests/test_request.py +0 -0
- {phue2-0.0.1.dev279 → phue2-0.0.1.dev280}/uv.lock +0 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
from phue2 import Bridge
|
|
2
|
+
|
|
3
|
+
modes = {
|
|
4
|
+
"main": {
|
|
5
|
+
"kitchen": "Arctic aurora",
|
|
6
|
+
"office": "Blood moon",
|
|
7
|
+
"living room": "sahara",
|
|
8
|
+
"bedroom": "Nightlight",
|
|
9
|
+
},
|
|
10
|
+
"clean": {
|
|
11
|
+
"kitchen": "Bright",
|
|
12
|
+
"office": "Bright",
|
|
13
|
+
"living room": "Bright",
|
|
14
|
+
"bedroom": "Bright",
|
|
15
|
+
},
|
|
16
|
+
"morning": {
|
|
17
|
+
"kitchen": "Ocean dawn",
|
|
18
|
+
"office": "Tropical twilight",
|
|
19
|
+
"living room": "monet",
|
|
20
|
+
"bedroom": "Relax",
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def update_group_lights(
|
|
26
|
+
bridge: Bridge,
|
|
27
|
+
group_name: str,
|
|
28
|
+
scene_name: str,
|
|
29
|
+
transition: int = 100, # 100 * 0.1 second
|
|
30
|
+
) -> bool:
|
|
31
|
+
print(f"Setting {group_name} to {scene_name}")
|
|
32
|
+
|
|
33
|
+
return bridge.run_scene(
|
|
34
|
+
group_name=group_name, scene_name=scene_name, transition_time=transition
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def smart_home(choice: str) -> None:
|
|
39
|
+
bridge = Bridge()
|
|
40
|
+
|
|
41
|
+
mode = modes[choice]
|
|
42
|
+
|
|
43
|
+
for group_name, scene_name in mode.items():
|
|
44
|
+
try:
|
|
45
|
+
assert update_group_lights(bridge, group_name, scene_name)
|
|
46
|
+
|
|
47
|
+
except AssertionError:
|
|
48
|
+
print(f"Failed to run scene in {group_name}")
|
|
49
|
+
raise
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
if __name__ == "__main__":
|
|
53
|
+
smart_home("main")
|
|
@@ -20,6 +20,7 @@ class Scene:
|
|
|
20
20
|
version: int = 0,
|
|
21
21
|
type: str = "",
|
|
22
22
|
group: str = "",
|
|
23
|
+
**kwargs: Any, # Accept additional parameters from API
|
|
23
24
|
):
|
|
24
25
|
"""Initialize a Scene object.
|
|
25
26
|
|
|
@@ -36,6 +37,7 @@ class Scene:
|
|
|
36
37
|
version: Version of the scene
|
|
37
38
|
type: Type of the scene
|
|
38
39
|
group: Group associated with the scene
|
|
40
|
+
**kwargs: Additional parameters from the API (e.g., 'image')
|
|
39
41
|
"""
|
|
40
42
|
self.scene_id = sid
|
|
41
43
|
self.appdata = appdata or {}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Test the Scene class."""
|
|
2
|
+
|
|
3
|
+
from phue2.scene import Scene
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_scene_creation():
|
|
7
|
+
"""Test creating a Scene object with standard parameters."""
|
|
8
|
+
scene = Scene(
|
|
9
|
+
sid="1",
|
|
10
|
+
name="Test Scene",
|
|
11
|
+
lights=["1", "2", "3"],
|
|
12
|
+
group="0",
|
|
13
|
+
type="GroupScene",
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
assert scene.scene_id == "1"
|
|
17
|
+
assert scene.name == "Test Scene"
|
|
18
|
+
assert scene.lights == [1, 2, 3]
|
|
19
|
+
assert scene.group == "0"
|
|
20
|
+
assert scene.type == "GroupScene"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_scene_with_additional_parameters():
|
|
24
|
+
"""Test that the Scene class handles additional parameters from the API."""
|
|
25
|
+
# This test verifies the specific issue with the 'image' parameter
|
|
26
|
+
scene = Scene(
|
|
27
|
+
sid="1",
|
|
28
|
+
name="Test Scene",
|
|
29
|
+
lights=["1", "2", "3"],
|
|
30
|
+
image="/path/to/image.png", # This parameter was causing issues
|
|
31
|
+
extra_param="value", # Another future parameter
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
assert scene.scene_id == "1"
|
|
35
|
+
assert scene.name == "Test Scene"
|
|
36
|
+
assert scene.lights == [1, 2, 3]
|
|
37
|
+
# We don't assert on image or extra_param because we don't store them
|
|
38
|
+
# The point is just to verify that the constructor doesn't raise an exception
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_scene_repr():
|
|
42
|
+
"""Test the string representation of a Scene object."""
|
|
43
|
+
scene = Scene(
|
|
44
|
+
sid="1",
|
|
45
|
+
name="Test Scene",
|
|
46
|
+
lights=["1", "2", "3"],
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
# Check that the repr includes the scene_id, name, and lights
|
|
50
|
+
repr_str = repr(scene)
|
|
51
|
+
assert 'id="1"' in repr_str
|
|
52
|
+
assert 'name="Test Scene"' in repr_str
|
|
53
|
+
assert "lights=[1, 2, 3]" in repr_str
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def test_scene_empty_lights():
|
|
57
|
+
"""Test that the Scene class handles empty lights list."""
|
|
58
|
+
scene = Scene(
|
|
59
|
+
sid="1",
|
|
60
|
+
name="Test Scene",
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
assert scene.scene_id == "1"
|
|
64
|
+
assert scene.name == "Test Scene"
|
|
65
|
+
assert scene.lights == []
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|