Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
NerdBase-by-Stark committed Sep 23, 2024
1 parent 7a1f735 commit 9a1704e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion custom_components/stark_energy_monitor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import os
import yaml
import importlib
from homeassistant.core import HomeAssistant
from homeassistant.config_entries import ConfigEntry
from homeassistant.exceptions import ConfigEntryNotReady
Expand All @@ -19,6 +20,9 @@ async def async_setup(hass: HomeAssistant, config: dict):
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up Stark Energy Monitor from a config entry."""
try:
# Use async execution to avoid blocking the event loop
await hass.async_add_executor_job(importlib.import_module, "custom_components.stark_energy_monitor.config_flow")

# Initialize coordinator for handling updates
coordinator = StarkEnergyMonitorCoordinator(hass)
await coordinator.async_config_entry_first_refresh()
Expand All @@ -33,7 +37,6 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
if os.path.exists(dashboard_file_path):
with open(dashboard_file_path, 'r') as dashboard_file:
dashboard_config = yaml.safe_load(dashboard_file)
# Here, you could modify YAML config if needed
_LOGGER.info("Loaded Stark Energy Monitor dashboard in YAML mode.")
else:
_LOGGER.warning(f"Dashboard YAML file not found at {dashboard_file_path}")
Expand Down
1 change: 1 addition & 0 deletions custom_components/stark_energy_monitor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
CONF_SAMPLE_INTERVAL = "sample_interval"
CONF_ENABLE_NOTIFICATIONS = "enable_notifications"
CONF_DATA_RETENTION_DAYS = "data_retention_days"
CONF_TARIFFS = "tariffs"

0 comments on commit 9a1704e

Please sign in to comment.