<filename>custom_components/skorea_wallpad/__init__.py
"""The KoreAssistant integration."""
import asyncio
from homeassistant.helpers.dispatcher import async_dispatcher_connect
import logging

from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from .gateway import WallpadGateway

from .const import (DOMAIN, PLATFORMS, BRAND, RELOAD_SIGNAL)

_LOGGER = logging.getLogger(__name__)


@callback
async def async_reload_gateway(hass, entry):
    await hass.config_entries.async_reload(entry.entry_id)


async def async_setup(hass: HomeAssistant, config: dict):
    """Set up the KoreAssistant component."""
    return True


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
    """Set up KoreAssistant from a config entry."""
    if DOMAIN not in hass.data:
        hass.data[DOMAIN] = {}
    gateway = WallpadGateway(hass, entry)
    await gateway.async_update_device_registry()
    await gateway.async_get_entity_registry()
    connect = gateway.connect()
    if connect:
        gateway.initialize()
        hass.data[DOMAIN][entry.unique_id] = gateway
        for component in PLATFORMS:
            hass.async_create_task(
                hass.config_entries.async_forward_entry_setup(
                    entry, component))
        hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, gateway.stop)
    else:
        _LOGGER.info(f"[{BRAND}] 컴포넌트를 불러올 수 없습니다.")

    async_dispatcher_connect(hass, RELOAD_SIGNAL, async_reload_gateway)

    return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
    """Unload a config entry."""
    unload_ok = all(await asyncio.gather(*[
        hass.config_entries.async_forward_entry_unload(entry, component)
        for component in PLATFORMS
    ]))
    if unload_ok:
        hass.data[DOMAIN][entry.unique_id].stop(False)
        hass.data[DOMAIN].pop(entry.unique_id)

    return unload_ok
<filename>custom_components/skorea_wallpad/__init__.py
"""The KoreAssistant integration."""
import asyncio
from homeassistant.helpers.dispatcher import async_dispatcher_connect
import logging

from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from .gateway import WallpadGateway

from .const import (DOMAIN, PLATFORMS, BRAND, RELOAD_SIGNAL)

_LOGGER = logging.getLogger(__name__)


@callback
async def async_reload_gateway(hass, entry):
    await hass.config_entries.async_reload(entry.entry_id)


async def async_setup(hass: HomeAssistant, config: dict):
    """Set up the KoreAssistant component."""
    return True


async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
    """Set up KoreAssistant from a config entry."""
    if DOMAIN not in hass.data:
        hass.data[DOMAIN] = {}
    gateway = WallpadGateway(hass, entry)
    await gateway.async_update_device_registry()
    await gateway.async_get_entity_registry()
    connect = gateway.connect()
    if connect:
        gateway.initialize()
        hass.data[DOMAIN][entry.unique_id] = gateway
        for component in PLATFORMS:
            hass.async_create_task(
                hass.config_entries.async_forward_entry_setup(
                    entry, component))
        hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, gateway.stop)
    else:
        _LOGGER.info(f"[{BRAND}] 컴포넌트를 불러올 수 없습니다.")

    async_dispatcher_connect(hass, RELOAD_SIGNAL, async_reload_gateway)

    return True


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
    """Unload a config entry."""
    unload_ok = all(await asyncio.gather(*[
        hass.config_entries.async_forward_entry_unload(entry, component)
        for component in PLATFORMS
    ]))
    if unload_ok:
        hass.data[DOMAIN][entry.unique_id].stop(False)
        hass.data[DOMAIN].pop(entry.unique_id)

    return unload_ok
The KoreAssistant integration. Set up the KoreAssistant component. Set up KoreAssistant from a config entry. Unload a config entry.