I developed a synchronous HA integration (initialized by synchronous
setup() function) and it’s working fine. However I’d like to use more HA features like device triggers etc, but these do require that a component is setup via a config entry, not via
configuration.yaml. So I started experimenting with Config Flow code, and it doesn’t seem complicated to use it, but I encountered a problem / question.
Config entries require component setup to be done via
async_setup_entry(). And here is where my problem starts. All my code is synchronous. The library I use for TCP communication is also synchronous.
I assume if I move the setup code I have from
async_setup_entry() it will block the asyncio loop, right? It won’t last long (3-5 seconds, but it may vary in different user setups) but I don’t like to do it this way.
Question 1: is there an easy way to combine these 2 things - sync component and
async_setup_entry()? I won’t be able to rewrite everything to asyncio, as this is beyond my python skills.
Question 2: will HA assume that the whole component is asynchronous if I use
async_setup_entry()? This wouldn’t be be nice as my component would block HA event loop and slow it down, and obviously I don’t want that.
Help / input much appreciated!