mqtt: push Klipper status updates after subscription

This resolves an issue where MQTT clients miss the first status
update after a Klipper restart.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan
2025-02-07 06:15:26 -05:00
parent b8388db18d
commit fb6e416e1c
2 changed files with 14 additions and 6 deletions

View File

@@ -266,12 +266,15 @@ class KlippyAPI(APITransport):
objects: Mapping[str, Optional[List[str]]],
transport: APITransport,
default: Union[Sentinel, _T] = Sentinel.MISSING,
full_response: bool = False
) -> Union[_T, Dict[str, Any]]:
params = {"objects": dict(objects)}
result = await self._send_klippy_request(
SUBSCRIPTION_ENDPOINT, params, default, transport
)
if isinstance(result, dict) and "status" in result:
if full_response:
return result
return result["status"]
if default is not Sentinel.MISSING:
return default