jcgoette / baby_buddy_homeassistant

This custom integration provides sensors for Baby Buddy API endpoints.
MIT License
64 stars 30 forks source link

Use async_forward_entry_setups in async_setup_entry #102

Closed pem884 closed 1 year ago

pem884 commented 1 year ago

Hope this will address #99 - I don't have a thorough understanding & have not tested but hope it saves time for someone.

pem884 commented 1 year ago

Sharing some background info in case it is useful to someone. My understanding, again, is extremely limited but I'm reading it over a few times:

Before 2022.8, it was impossible to await config entry platforms forwards without a deadlock if one of the platforms loaded by the config entry was not already loaded.

Integrations need to be refactored to replace calls to hass.config_entries.async_setup_platforms with hass.config_entries.async_forward_entry_setups and/or await all hass.config_entries.async_forward_entry_setup to ensure that Home Assistant does not inadvertently reload the integration while entities and platforms are still being set up.

hass.config_entries.async_setup_platforms is scheduled to be removed in 2022.12.

Original: https://developers.home-assistant.io/blog/2022/07/08/config_entry_forwards/

jcgoette commented 1 year ago

Looks good to me. Can you just run black and isort on __init__.py?

pem884 commented 1 year ago

There you go! Looks like the diff is ~1 line of space for black; no changes after isort.exe --profile black .\__init__.py (Windows filesystem; running through a Powershell prompt). Please don't hesitate to ask me to retry something in case that sounds wrong to you; I haven't used the utils much.

jcgoette commented 1 year ago

Thanks @pem884 !