@@ -49,6 +49,7 @@ class LetPotDeviceClient:
4949
5050 _update_status : LetPotDeviceStatus | None = None
5151 _update_clear : asyncio .Task | None = None
52+ _status_event : asyncio .Event | None = None
5253 last_status : LetPotDeviceStatus | None = None
5354
5455 def __init__ (self , info : AuthenticationInfo , device_serial : str ) -> None :
@@ -118,6 +119,8 @@ def _handle_message(
118119 self ._update_status = None
119120 self .last_status = status
120121 callback (status )
122+ if self ._status_event is not None and not self ._status_event .is_set ():
123+ self ._status_event .set ()
121124
122125 async def _publish (self , message : list [int ]) -> None :
123126 """Publish a message to the device command topic."""
@@ -246,6 +249,13 @@ async def request_status_update(self) -> None:
246249 raise LetPotException ("Missing converter to build request message" )
247250 await self ._publish (self ._converter .get_current_status_message ())
248251
252+ async def get_current_status (self ) -> LetPotDeviceStatus | None :
253+ """Request an update of and return the current device status."""
254+ self ._status_event = asyncio .Event ()
255+ await self .request_status_update ()
256+ await self ._status_event .wait ()
257+ return self .last_status
258+
249259 async def set_light_brightness (self , level : int ) -> None :
250260 """Set the light brightness for this device (brightness level)."""
251261 if level not in self .get_light_brightness_levels ():
0 commit comments