Skip to content

Commit

Permalink
refactor: Move async_update_listener
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Dec 9, 2024
1 parent f0ee3c1 commit ba2077b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
12 changes: 10 additions & 2 deletions custom_components/solarman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions custom_components/solarman/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit ba2077b

Please sign in to comment.