1

I've implemented a custom component for Home Assistant, which opens the SocketIO stream and feed the event bus with it.

Shorted version:

async def async_setup(hass: HomeAssistant, config: dict):
    sio = AsyncClient()
    await sio.connect(...)

    @sio.on("event")
    async def _handler(data: dict):
        hass.bus.async_fire(...)

    hass.async_create_task(sio.wait())
    return True

But when implemented this way it somehow blocks the initialization process. Dashboard is not populated until following line comes up in the log:

2022-08-27 19:45:43.586 WARNING (MainThread) [homeassistant.bootstrap] Setup timed out for bootstrap - moving forward

What I'm doing wrong? Should I resign from the async aproach and use threading instead?

majkrzak
  • 1,332
  • 3
  • 14
  • 30
  • I managed to find the reason. I will provide detailed answer soon. In short, the reason is that there is a list of tasks which have to be finished to finish bootstrap. To make it not timeout it have to be bypassed. – majkrzak Nov 06 '22 at 18:52

0 Answers0