diff --git a/custom_components/solarman/__init__.py b/custom_components/solarman/__init__.py index 648c485..dd28d89 100644 --- a/custom_components/solarman/__init__.py +++ b/custom_components/solarman/__init__.py @@ -14,9 +14,9 @@ from .common import * from .provider import ConfigurationProvider from .coordinator import Inverter, InverterCoordinator +from .config_flow import ConfigFlowHandler from .entity import migrate_unique_ids -from .config_flow import async_update_listener, ConfigFlowHandler -from .services import * +from .services import register_services _LOGGER = logging.getLogger(__name__) @@ -61,6 +61,14 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS) + # Add update listener + # + _LOGGER.debug(f"async_setup: config_entry.add_update_listener(async_update_listener)") + + async def async_update_listener(hass: HomeAssistant, config_entry: ConfigEntry) -> None: + _LOGGER.debug(f"async_update_listener({config_entry.as_dict()})") + await hass.config_entries.async_reload(config_entry.entry_id) + config_entry.async_on_unload(config_entry.add_update_listener(async_update_listener)) return True diff --git a/custom_components/solarman/config_flow.py b/custom_components/solarman/config_flow.py index 626c2d2..8d17625 100644 --- a/custom_components/solarman/config_flow.py +++ b/custom_components/solarman/config_flow.py @@ -43,12 +43,6 @@ ) } -async def async_update_listener(hass: HomeAssistant, config_entry: ConfigEntry) -> None: - _LOGGER.debug(f"async_update_listener: entry: {config_entry.as_dict()}") - #hass.data[DOMAIN][entry.entry_id].config(entry) - #entry.title = entry.options[CONF_NAME] - await hass.config_entries.async_reload(config_entry.entry_id) - async def data_schema(hass: HomeAssistant, data_schema: dict[str, Any]) -> vol.Schema: lookup_files = [DEFAULT_[CONF_LOOKUP_FILE]] + await async_listdir(hass.config.path(LOOKUP_DIRECTORY_PATH)) + await async_listdir(hass.config.path(LOOKUP_CUSTOM_DIRECTORY_PATH), "custom/") _LOGGER.debug(f"step_user_data_schema: {LOOKUP_DIRECTORY_PATH}: {lookup_files}")