From 535da483b6c54216f74f39edc18ce6a839898c0a Mon Sep 17 00:00:00 2001 From: Fexiven <48439988+Fexiven@users.noreply.github.com> Date: Wed, 3 Apr 2024 20:51:55 +0200 Subject: [PATCH] Rework update_data starlink coordinator (#114642) * Update coordinator.py fixes https://github.com/home-assistant/core/issues/114353 * Rework update_data starlink coordinator * modify return handlung according to ruff * add type annotation for _get_srtarlink_data * add channel_context type annotation * Add docstring * ruff ruff here you go - modfied docstring * Clean up --------- Co-authored-by: Martin Hjelmare --- .../components/starlink/coordinator.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/starlink/coordinator.py b/homeassistant/components/starlink/coordinator.py index ff33b3ecc41..7a09b2f2dee 100644 --- a/homeassistant/components/starlink/coordinator.py +++ b/homeassistant/components/starlink/coordinator.py @@ -55,21 +55,21 @@ class StarlinkUpdateCoordinator(DataUpdateCoordinator[StarlinkData]): update_interval=timedelta(seconds=5), ) + def _get_starlink_data(self) -> StarlinkData: + """Retrieve Starlink data.""" + channel_context = self.channel_context + status = status_data(channel_context) + location = location_data(channel_context) + sleep = get_sleep_config(channel_context) + return StarlinkData(location, sleep, *status) + async def _async_update_data(self) -> StarlinkData: async with asyncio.timeout(4): try: - status = await self.hass.async_add_executor_job( - status_data, self.channel_context - ) - location = await self.hass.async_add_executor_job( - location_data, self.channel_context - ) - sleep = await self.hass.async_add_executor_job( - get_sleep_config, self.channel_context - ) - return StarlinkData(location, sleep, *status) + result = await self.hass.async_add_executor_job(self._get_starlink_data) except GrpcError as exc: raise UpdateFailed from exc + return result async def async_stow_starlink(self, stow: bool) -> None: """Set whether Starlink system tied to this coordinator should be stowed."""