feat(api-input): expose timeout/interpolation, fix 422 on light turn-on
- coordinator.update_source now auto-injects source_type from cached data so the server's discriminated-union body validates (was rejecting fallback_color updates with 422). - Add Fallback Timeout (number) and Interpolation (select) entities per api_input CSS source. - Light no longer zeros fallback_color on turn_off; state restored across HA restarts via RestoreEntity so the chosen default color persists. - Bump manifest to 0.2.2 and update en/ru translations.
This commit is contained in:
@@ -349,7 +349,20 @@ class LedGrabCoordinator(DataUpdateCoordinator):
|
||||
await self.async_request_refresh()
|
||||
|
||||
async def update_source(self, source_id: str, **kwargs: Any) -> None:
|
||||
"""Update a color strip source's fields."""
|
||||
"""Update a color strip source's fields.
|
||||
|
||||
The server uses a discriminated-union body keyed on ``source_type``;
|
||||
if the caller didn't supply it, look it up from the cached sources so
|
||||
the request validates server-side.
|
||||
"""
|
||||
if "source_type" not in kwargs and self.data:
|
||||
for source in self.data.get("css_sources", []):
|
||||
if source.get("id") == source_id:
|
||||
src_type = source.get("source_type")
|
||||
if src_type:
|
||||
kwargs["source_type"] = src_type
|
||||
break
|
||||
|
||||
async with self.session.put(
|
||||
f"{self.server_url}/api/v1/color-strip-sources/{source_id}",
|
||||
headers={**self._auth_headers, "Content-Type": "application/json"},
|
||||
|
||||
Reference in New Issue
Block a user