Migrate cast to use async_forward_entry_setups (#86558)

Replaces deprecated async_setup_platforms with async_forward_entry_setups
This commit is contained in:
J. Nick Koston 2023-01-24 23:12:58 -10:00 committed by GitHub
parent 3bfdba50d9
commit 5285d057d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View file

@ -57,7 +57,7 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Cast from a config entry."""
await home_assistant_cast.async_setup_ha_cast(hass, entry)
hass.config_entries.async_setup_platforms(entry, PLATFORMS)
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
hass.data[DOMAIN] = {"cast_platform": {}, "unknown_models": {}}
await async_process_integration_platforms(hass, DOMAIN, _register_cast_platform)
return True

View file

@ -16,6 +16,7 @@ from .const import DOMAIN, SIGNAL_HASS_CAST_SHOW_VIEW
SERVICE_SHOW_VIEW = "show_lovelace_view"
ATTR_VIEW_PATH = "view_path"
ATTR_URL_PATH = "dashboard_path"
CAST_USER_NAME = "Home Assistant Cast"
NO_URL_AVAILABLE_ERROR = (
"Home Assistant Cast requires your instance to be reachable via HTTPS. Enable Home"
" Assistant Cloud or set up an external URL with valid SSL certificates"
@ -34,7 +35,7 @@ async def async_setup_ha_cast(
if user is None:
user = await hass.auth.async_create_system_user(
"Home Assistant Cast", group_ids=[auth.const.GROUP_ID_ADMIN]
CAST_USER_NAME, group_ids=[auth.const.GROUP_ID_ADMIN]
)
hass.config_entries.async_update_entry(
entry, data={**entry.data, "user_id": user.id}

View file

@ -5,6 +5,7 @@ import pytest
from homeassistant import config_entries, data_entry_flow
from homeassistant.components import cast
from homeassistant.components.cast.home_assistant_cast import CAST_USER_NAME
from tests.common import MockConfigEntry
@ -64,7 +65,7 @@ async def test_user_setup(hass):
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
users = await hass.auth.async_get_users()
assert len(users) == 1
assert next(user for user in users if user.name == CAST_USER_NAME)
assert result["type"] == "create_entry"
assert result["result"].data == {
"ignore_cec": [],
@ -86,7 +87,7 @@ async def test_user_setup_options(hass):
)
users = await hass.auth.async_get_users()
assert len(users) == 1
assert next(user for user in users if user.name == CAST_USER_NAME)
assert result["type"] == "create_entry"
assert result["result"].data == {
"ignore_cec": [],
@ -106,7 +107,7 @@ async def test_zeroconf_setup(hass):
result = await hass.config_entries.flow.async_configure(result["flow_id"], {})
users = await hass.auth.async_get_users()
assert len(users) == 1
assert next(user for user in users if user.name == CAST_USER_NAME)
assert result["type"] == "create_entry"
assert result["result"].data == {
"ignore_cec": [],
@ -126,7 +127,7 @@ async def test_zeroconf_setup_onboarding(hass):
)
users = await hass.auth.async_get_users()
assert len(users) == 1
assert next(user for user in users if user.name == CAST_USER_NAME)
assert result["type"] == "create_entry"
assert result["result"].data == {
"ignore_cec": [],