h4 / LYWSD02-home-assistant

Home-Assistant sensor for LYWSD02 Thermometer
75 stars 12 forks source link

Update data in parallel thread hence not blocking main HASS thread #15

Closed BoOmka closed 4 years ago

BoOmka commented 4 years ago

Closes #14

h4 commented 4 years ago

May be it'll be better to update h4/lywsd02 using asyncio?

BoOmka commented 4 years ago

May be it'll be better to update h4/lywsd02 using asyncio?

I tried to go this way first, but found it way more complicated. Firstly, there is a lot of properties with setters which don't pair well with asyncio. The will need to be rewritten. Secondly, bluepy doesn't have any asyncio-friendly realisation, so all we can do is slap loop.run_in_executor here and there. Spawning multiple threads for just one operation seems a bit of overkill.

h4 commented 4 years ago

Thank you!