diff --git a/homeassistant/components/cast/__init__.py b/homeassistant/components/cast/__init__.py index 1ef18081f93..4d1c00f967b 100644 --- a/homeassistant/components/cast/__init__.py +++ b/homeassistant/components/cast/__init__.py @@ -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 diff --git a/homeassistant/components/cast/home_assistant_cast.py b/homeassistant/components/cast/home_assistant_cast.py index 5460b831bcf..5eec2a28908 100644 --- a/homeassistant/components/cast/home_assistant_cast.py +++ b/homeassistant/components/cast/home_assistant_cast.py @@ -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} diff --git a/tests/components/cast/test_config_flow.py b/tests/components/cast/test_config_flow.py index 97218a396dd..f40e9701348 100644 --- a/tests/components/cast/test_config_flow.py +++ b/tests/components/cast/test_config_flow.py @@ -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": [],