diff --git a/pyomnilogic_local/colorlogiclight.py b/pyomnilogic_local/colorlogiclight.py index 2e90878..6d258d4 100644 --- a/pyomnilogic_local/colorlogiclight.py +++ b/pyomnilogic_local/colorlogiclight.py @@ -168,7 +168,7 @@ def state(self) -> ColorLogicPowerState: @property def show(self) -> LightShows: """Returns the current light show.""" - return self.telemetry.show + return self.telemetry.show_name(self.model, self.v2_active) @property def speed(self) -> ColorLogicSpeed: @@ -282,7 +282,7 @@ async def set_show( await self._api.async_set_light_show( self.bow_id, self.system_id, - show or self.show, # use current value if None - speed or self.speed, # use current value if None - brightness or self.brightness, # use current value if None + show if show is not None else self.show, # use current value if None + speed if speed is not None else self.speed, # use current value if None + brightness if brightness is not None else self.brightness, # use current value if None ) diff --git a/pyomnilogic_local/models/mspconfig.py b/pyomnilogic_local/models/mspconfig.py index b71fafe..24b26f2 100644 --- a/pyomnilogic_local/models/mspconfig.py +++ b/pyomnilogic_local/models/mspconfig.py @@ -289,14 +289,13 @@ class MSPColorLogicLight(OmniBase): omni_type: OmniType = OmniType.CL_LIGHT - equip_type: ColorLogicLightType = Field(alias="Type") v2_active: bool = Field(alias="V2-Active", default=False) + equip_type: ColorLogicLightType = Field(alias="Type") effects: list[LightShows] | None = None - def __init__(self, **data: Any) -> None: - super().__init__(**data) - - # Get the available light shows depending on the light type. + @model_validator(mode="after") + def set_effects(self) -> Any: + """Set the available light shows based on the light type.""" match self.equip_type: case ColorLogicLightType.TWO_FIVE: self.effects = list(ColorLogicShow25) @@ -311,6 +310,7 @@ def __init__(self, **data: Any) -> None: self.effects = list(PentairShow) case ColorLogicLightType.ZODIAC_COLOR: self.effects = list(ZodiacShow) + return self class MSPGroup(OmniBase): diff --git a/pyomnilogic_local/models/telemetry.py b/pyomnilogic_local/models/telemetry.py index 78663e3..2309c16 100644 --- a/pyomnilogic_local/models/telemetry.py +++ b/pyomnilogic_local/models/telemetry.py @@ -267,7 +267,7 @@ class TelemetryColorLogicLight(BaseModel): def show_name( self, model: ColorLogicLightType, v2: bool - ) -> ColorLogicShow25 | ColorLogicShow40 | ColorLogicShowUCL | ColorLogicShowUCLV2 | PentairShow | ZodiacShow | int: + ) -> ColorLogicShow25 | ColorLogicShow40 | ColorLogicShowUCL | ColorLogicShowUCLV2 | PentairShow | ZodiacShow: """Get the current light show depending on the light type. Returns: @@ -287,7 +287,8 @@ def show_name( return PentairShow(self.show) case ColorLogicLightType.ZODIAC_COLOR: return ZodiacShow(self.show) - return self.show # Return raw int if type is unknown + msg = f"Unknown ColorLogicLightType {model} for show name parsing" + raise OmniParsingError(msg) class TelemetryFilter(BaseModel):