diff --git a/pywizlight/bulb.py b/pywizlight/bulb.py index 744c5f7..af181fb 100755 --- a/pywizlight/bulb.py +++ b/pywizlight/bulb.py @@ -247,6 +247,8 @@ def get_scene(self) -> Optional[str]: """Get the current scene name.""" if "schdPsetId" in self.pilotResult: # rhythm return SCENES[1000] + if "sceneId" not in self.pilotResult: + return None return SCENES.get(self.pilotResult["sceneId"]) def get_cold_white(self) -> Optional[int]: diff --git a/pywizlight/tests/test_bulb.py b/pywizlight/tests/test_bulb.py index d774387..d1d912c 100644 --- a/pywizlight/tests/test_bulb.py +++ b/pywizlight/tests/test_bulb.py @@ -125,6 +125,18 @@ async def test_PilotBuilder_scene(correct_bulb: wizlight) -> None: state = await correct_bulb.updateState() assert state and state.get_scene() == SCENES[1] + state.pilotResult["schdPsetId"] = True + assert state.get_scene() == SCENES[1000] + + +@pytest.mark.asyncio +async def test_PilotBuilder_scene_empty(correct_bulb: wizlight) -> None: + """Test scene with no scene set.""" + state = await correct_bulb.updateState() + assert state is not None + if "sceneId" in state.pilotResult: + del state.pilotResult["sceneId"] + assert state and state.get_scene() is None @pytest.mark.asyncio