def setup(hass, config):
    global TARGET_ID

    # Validate that all required config options are given.
    if not validate_config(config, {DOMAIN: [CONF_TARGET]}, _LOGGER):
        return False

    TARGET_ID = config[DOMAIN][CONF_TARGET]

    # Validate that the target entity id exists.
    if hass.states.get(TARGET_ID) is None:
        _LOGGER.error("Target entity id %s does not exist",
                      TARGET_ID)

        # Tell the bootstrapper that we failed to initialize and clear the
        # stored target id so our functions don't run.
        TARGET_ID = None
        return False

    # Tell the bootstrapper that we initialized successfully.
    return True
Setup example component.
dataset/ETHPy150Open home-assistant/home-assistant/config/custom_components/example.py/setup