Skip to content

Commit

Permalink
Perform blocking serial IO in the executor
Browse files Browse the repository at this point in the history
  • Loading branch information
davet2001 committed Apr 6, 2023
1 parent 4f0b15f commit d1ede77
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions homeassistant/components/aurora_abb_powerone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ def __init__(self, hass: HomeAssistant, comport: str, address: int) -> None:
self.client = AuroraSerialClient(address, comport, parity="N", timeout=1)
super().__init__(hass, _LOGGER, name=DOMAIN, update_interval=SCAN_INTERVAL)

async def _async_update_data(self) -> dict[str, float]:
def _update_data(self) -> dict[str, float]:
"""Fetch new state data for the sensor.
This is the only method that should fetch new data for Home Assistant.
This is the only function that should fetch new data for Home Assistant.
"""
data: dict[str, float] = {}
try:
Expand Down Expand Up @@ -103,3 +103,7 @@ async def _async_update_data(self) -> dict[str, float]:
self.client.close()

return data

async def _async_update_data(self) -> dict[str, float]:
"""Update inverter data in the executor."""
return await self.hass.async_add_executor_job(self._update_data)

0 comments on commit d1ede77

Please sign in to comment.