Skip to content

Commit

Permalink
Fix for blocking call warning, fixes #577
Browse files Browse the repository at this point in the history
  • Loading branch information
CJNE committed Oct 16, 2024
1 parent 16a839b commit 410c0f9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion custom_components/myenergi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from homeassistant.core import HomeAssistant
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from homeassistant.helpers.update_coordinator import UpdateFailed
from homeassistant.helpers.httpx_client import get_async_client
from pymyenergi.client import MyenergiClient
from pymyenergi.connection import Connection

Expand Down Expand Up @@ -48,8 +49,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
app_email = entry.data.get(CONF_APP_EMAIL)
app_password = entry.data.get(CONF_APP_PASSWORD)

async_client = get_async_client(hass)

conn = await hass.async_add_executor_job(
Connection, username, password, app_password, app_email
Connection, username, password, app_password, app_email, 20, async_client
)
if app_email and app_password:
await conn.discoverLocations()
Expand Down Expand Up @@ -107,6 +110,7 @@ async def _async_update_data(self):
await self.client.refresh()
await self.client.refresh_history(utc_today, 24, "hour")
except Exception as exception:
_LOGGER.debug(exception)
raise UpdateFailed() from exception


Expand Down
2 changes: 1 addition & 1 deletion custom_components/myenergi/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"documentation": "https://github.com/cjne/ha-myenergi",
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/cjne/ha-myenergi/issues",
"requirements": ["pymyenergi==0.2.1"],
"requirements": ["pymyenergi==0.2.2"],
"version": "0.0.28"
}

0 comments on commit 410c0f9

Please sign in to comment.