Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions govee/api/cloud/device_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def scene(
api_key: str,
device_id: str,
sku: str,
scene_id: int,
scene_value: dict,
base_url: str = "https://openapi.api.govee.com/router/api/v1",
timeout: float = 10.0,
) -> Dict[str, Any]:
Expand All @@ -247,7 +247,7 @@ def scene(
api_key: Govee API key
device_id: Device ID
sku: Device SKU
scene_id: Scene ID from Govee API
scene_value: Scene value from Govee API
base_url: Base URL for Govee API
timeout: Request timeout

Expand All @@ -260,7 +260,7 @@ def scene(
sku=sku,
capability_type="devices.capabilities.dynamic_scene",
capability_instance="diyScene",
value=scene_id,
value=scene_value,
base_url=base_url,
timeout=timeout,
)
Expand Down Expand Up @@ -395,7 +395,7 @@ def light_scene(
api_key: str,
device_id: str,
sku: str,
scene_id: int,
scene_value: dict,
base_url: str = "https://openapi.api.govee.com/router/api/v1",
timeout: float = 10.0,
) -> Dict[str, Any]:
Expand All @@ -406,7 +406,7 @@ def light_scene(
api_key: Govee API key
device_id: Device ID
sku: Device SKU
scene_id: Light scene ID from Govee API
scene_value: Light scene value from Govee API
base_url: Base URL for Govee API
timeout: Request timeout

Expand All @@ -419,7 +419,7 @@ def light_scene(
sku=sku,
capability_type="devices.capabilities.dynamic_scene",
capability_instance="lightScene",
value=scene_id,
value=scene_value,
base_url=base_url,
timeout=timeout,
)
Expand Down
11 changes: 5 additions & 6 deletions govee/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1466,21 +1466,20 @@ def _apply_scene_sync():
api_key=self.api_key,
device_id=device.id,
sku=device.sku,
scene_id=scene.id,
scene_value=scene.value,
base_url=self.base_url,
timeout=self.timeout
)
else:
# Built-in scenes use lightScene capability with scene.value['id']
scene_id = scene.value.get('id')
if scene_id is None:
raise ValueError(f"Scene '{scene.name}' has no valid id in value field")
# Updated API, light_scene now uses the whole scene.value
if scene.value is None:
raise ValueError(f"Scene '{scene.name}' has no valid value dict")

cloud_control.light_scene(
api_key=self.api_key,
device_id=device.id,
sku=device.sku,
scene_id=scene_id,
scene_value=scene.value,
base_url=self.base_url,
timeout=self.timeout
)
Expand Down
10 changes: 4 additions & 6 deletions tests/test_cloud_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,10 @@ def test_cloud_light_scenes():
for scene_name in test_scenes:
if scene_name in scene_options:
scene_value = scene_options[scene_name]
scene_id = scene_value.get('id')
print(f"\n--- Applying built-in scene: {scene_name} (id={scene_id}) ---")
print(f"\n--- Applying built-in scene: {scene_name} (id={scene.value.get("id", "no_id")}) ---")
try:
result = device_control.light_scene(
TEST_API_KEY, TEST_DEVICE_ID, TEST_DEVICE_SKU, scene_id
TEST_API_KEY, TEST_DEVICE_ID, TEST_DEVICE_SKU, scene.value
)
code = result.get('code')
print(f"✓ Scene {scene_name}: code={code}")
Expand Down Expand Up @@ -272,11 +271,10 @@ def test_cloud_diy_scenes():

for i, scene in enumerate(diy_scenes_data[:test_count]):
scene_name = scene.get('name')
scene_id = scene.get('id')
print(f"\n--- Applying DIY scene: {scene_name} (id={scene_id}) ---")
print(f"\n--- Applying DIY scene: {scene_name} (id={scene.value.get("id", "no_id")}) ---")
try:
result = device_control.scene(
TEST_API_KEY, TEST_DEVICE_ID, TEST_DEVICE_SKU, scene_id
TEST_API_KEY, TEST_DEVICE_ID, TEST_DEVICE_SKU, scene.value
)
code = result.get('code')
print(f"✓ DIY Scene {scene_name}: code={code}")
Expand Down