remove hass.config_entries.async_setup_platforms
BenShen98 opened this issue · 5 comments
I had problem running the detailed_hello_world_push example.
After some search, I found it's because hass.config_entries.async_setup_platforms
was removed in the recent version. It's suggested from the blog, I should replace it with hass.config_entries.async_forward_entry_setups
or hass.config_entries.async_forward_entry_setup
?
Could someone provide a hint on how to do it? I'm still new to develop HA, so a guide to fix the example would be extermly useful to people like me.
PLATFORMS: list[str] = ["cover", "sensor"]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Hello World from a config entry."""
# Store an instance of the "connecting" class that does the work of speaking
# with your actual devices.
hass.data.setdefault(DOMAIN, {})[entry.entry_id] = hub.Hub(hass, entry.data["host"])
# This creates each HA object for each platform your device requires.
# It's done by calling the `async_setup_entry` function in each platform module.
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
return True
Copied related code here in case someone want to provide a quick patch. Happy to submit a pull request after get it working
Well, turns of the replacement are trivial. See the patch below.
I'm on a low-spec laptop on vacation, so happy to submit a patch in next months.
(also happy for others to create the patch before me)
diff --git a/custom_components/detailed_hello_world_push/__init__.py b/custom_components/detailed_hello_world_push/__init__.py
index 7824f2d..5a1a751 100644
--- a/custom_components/detailed_hello_world_push/__init__.py
+++ b/custom_components/detailed_hello_world_push/__init__.py
@@ -20,7 +20,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# This creates each HA object for each platform your device requires.
# It's done by calling the `async_setup_entry` function in each platform module.
- hass.config_entries.async_setup_platforms(entry, PLATFORMS)
+ await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True
@BenShen98 want to send a pull request to update the example? That'd be fantastic
@allenporter Happy to do that, once I finish my vacation (in the next months).
low spec laptop + bad internet = no incentive to do more than exploration
I had the same issue, so I've submitted a PR with @BenShen98 's fix :)