mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 20:27:08 +00:00
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 <marhje52@gmail.com>
This commit is contained in:
parent
69a6e9f5d7
commit
535da483b6
@ -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."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user