Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for blocking listdir and HA 2025.6 deprecation warning #559

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions custom_components/energidataservice/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
_LOGGER.debug("Entry options: %s", entry.options)
result = await _setup(hass, entry)

hass.async_create_task(
hass.config_entries.async_forward_entry_setup(entry, "sensor")
)
await hass.config_entries.async_forward_entry_setups(entry, ["sensor"])

return result

Expand Down
5 changes: 4 additions & 1 deletion custom_components/energidataservice/connectors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import importlib
from asyncio import get_running_loop
from collections import namedtuple
from logging import getLogger
from os import listdir
Expand All @@ -26,7 +27,9 @@ def __init__(self, hass):

async def load_connectors(self) -> None:
"""Load available connectors."""
for module in sorted(listdir(f"{dirname(__file__)}")):
loop = get_running_loop()
modules = await loop.run_in_executor(None, listdir, f"{dirname(__file__)}")
for module in sorted(modules):
mod_path = f"{dirname(__file__)}/{module}"
if isdir(mod_path) and not module.endswith("__pycache__"):
Connector = namedtuple("Connector", "module namespace regions")
Expand Down
5 changes: 4 additions & 1 deletion custom_components/energidataservice/forecasts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import importlib
from asyncio import get_running_loop
from collections import namedtuple
from logging import getLogger
from os import listdir
Expand All @@ -26,7 +27,9 @@ def __init__(self, hass):

async def load_modules(self) -> None:
"""Load available modules."""
for module in sorted(listdir(f"{dirname(__file__)}")):
loop = get_running_loop()
modules = await loop.run_in_executor(None, listdir, f"{dirname(__file__)}")
for module in sorted(modules):
mod_path = f"{dirname(__file__)}/{module}"
if (
isdir(mod_path)
Expand Down
5 changes: 4 additions & 1 deletion custom_components/energidataservice/tariffs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import annotations

import importlib
from asyncio import get_running_loop
from collections import namedtuple
from logging import getLogger
from os import listdir
Expand All @@ -24,7 +25,9 @@ def __init__(self, hass):

async def load_modules(self) -> None:
"""Load available modules."""
for module in sorted(listdir(f"{dirname(__file__)}")):
loop = get_running_loop()
modules = await loop.run_in_executor(None, listdir, f"{dirname(__file__)}")
for module in sorted(modules):
mod_path = f"{dirname(__file__)}/{module}"
if (
isdir(mod_path)
Expand Down
Loading