Unable to wake up switch.py in new custom component

Hi

I’m trying to put together a new component asynchronously offering some switches to HA. I’m running my code as custom component under Hassio 0.107.7 and while I’m able to initialize the component via config flow and async_setup and async_setup_entry in init.py gets called as expected, it seems that switch.py also including async_setup_entry is never loaded or at least async_setup_entry is never called.

Am I missing something? Should the switch.py (and sensor.py etc.) get loaded and async_setup_entry called automatically when config entry gets loaded, or am I just missing something basic?

My switch.py is pretty much simply as follows:

"""switches"""

import asyncio
import logging

from homeassistant.helpers.typing import HomeAssistantType

_LOGGER = logging.getLogger(__name__)

async def async_setup_entry(hass: HomeAssistantType, entry, async_add_entities):
        """switch setup entry"""
        _LOGGER.warning('SETTING UP SWITCH')
        return True

I got it working by doing

hass.async_create_task(hass.config_entries.async_forward_entry_setup(entry, 'switch'))

in __init__.py async_setup_entry. I don’t see it in any other components though for switch. Maybe it’s a custom component thing.

1 Like