jseidl / hass-magic_areas

Areas with batteries included for Home Assistant
MIT License
273 stars 28 forks source link

Add async to load_entities method in add_entities_when_ready #315

Closed Julien-Decoen closed 9 months ago

Julien-Decoen commented 9 months ago

Related to https://github.com/jseidl/hass-magic_areas/issues/313

jseidl commented 9 months ago

Although I can't reproduce the issue, this fix doesn't break anything so it's probably the right thing.

Closes #313

bdraco commented 6 months ago

If you decorate the function with @callback it will run in the event loop instead and than you don't need to make it a coroutinue

https://developers.home-assistant.io/docs/asyncio_categorizing_functions#the-callback-function

Julien-Decoen commented 2 months ago

If you decorate the function with @callback it will run in the event loop instead and than you don't need to make it a coroutinue

https://developers.home-assistant.io/docs/asyncio_categorizing_functions#the-callback-function

Hi @bdraco ,

Thank you so much for your feedback on this pull request! To better understand your suggestion, would you mind providing a complete code example of how the function should look? It would help clarify the implementation and ensure I'm on the right track.

Thanks again for your time!

bdraco commented 2 months ago
@callback
def load_entities(event):
bdraco commented 2 months ago

Import callback from homeassistant.core

jseidl commented 2 months ago

I know what you folks are talking about. Had to deal with it in another issue Thanks for the feedback. I'm going to move this function back into utils and will change to a callback annotation. Thank you all on this ♥️