From c5dd540ffc96b20346f4253a540e3a3e82d18d43 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Thu, 1 Jun 2023 12:18:54 +0200 Subject: [PATCH] Remove async_setup from econet (#93892) --- homeassistant/components/econet/__init__.py | 10 +--------- tests/components/econet/test_config_flow.py | 16 ++++------------ 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/homeassistant/components/econet/__init__.py b/homeassistant/components/econet/__init__.py index 6fa54fc70fb..afba9ba6837 100644 --- a/homeassistant/components/econet/__init__.py +++ b/homeassistant/components/econet/__init__.py @@ -19,7 +19,6 @@ from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send from homeassistant.helpers.entity import DeviceInfo, Entity from homeassistant.helpers.event import async_track_time_interval -from homeassistant.helpers.typing import ConfigType from .const import API_CLIENT, DOMAIN, EQUIPMENT @@ -36,14 +35,6 @@ PUSH_UPDATE = "econet.push_update" INTERVAL = timedelta(minutes=60) -async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Set up the EcoNet component.""" - hass.data[DOMAIN] = {} - hass.data[DOMAIN][API_CLIENT] = {} - hass.data[DOMAIN][EQUIPMENT] = {} - return True - - async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: """Set up EcoNet as config entry.""" @@ -65,6 +56,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b ) except (ClientError, GenericHTTPError, InvalidResponseFormat) as err: raise ConfigEntryNotReady from err + hass.data.setdefault(DOMAIN, {API_CLIENT: {}, EQUIPMENT: {}}) hass.data[DOMAIN][API_CLIENT][config_entry.entry_id] = api hass.data[DOMAIN][EQUIPMENT][config_entry.entry_id] = equipment diff --git a/tests/components/econet/test_config_flow.py b/tests/components/econet/test_config_flow.py index d01d6163285..3444cc83834 100644 --- a/tests/components/econet/test_config_flow.py +++ b/tests/components/econet/test_config_flow.py @@ -25,9 +25,7 @@ async def test_bad_credentials(hass: HomeAssistant) -> None: with patch( "pyeconet.EcoNetApiInterface.login", side_effect=InvalidCredentialsError(), - ), patch("homeassistant.components.econet.async_setup", return_value=True), patch( - "homeassistant.components.econet.async_setup_entry", return_value=True - ): + ), patch("homeassistant.components.econet.async_setup_entry", return_value=True): result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={ @@ -55,9 +53,7 @@ async def test_generic_error_from_library(hass: HomeAssistant) -> None: with patch( "pyeconet.EcoNetApiInterface.login", side_effect=PyeconetError(), - ), patch("homeassistant.components.econet.async_setup", return_value=True), patch( - "homeassistant.components.econet.async_setup_entry", return_value=True - ): + ), patch("homeassistant.components.econet.async_setup_entry", return_value=True): result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={ @@ -85,9 +81,7 @@ async def test_auth_worked(hass: HomeAssistant) -> None: with patch( "pyeconet.EcoNetApiInterface.login", return_value=EcoNetApiInterface, - ), patch("homeassistant.components.econet.async_setup", return_value=True), patch( - "homeassistant.components.econet.async_setup_entry", return_value=True - ): + ), patch("homeassistant.components.econet.async_setup_entry", return_value=True): result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={ @@ -122,9 +116,7 @@ async def test_already_configured(hass: HomeAssistant) -> None: with patch( "pyeconet.EcoNetApiInterface.login", return_value=EcoNetApiInterface, - ), patch("homeassistant.components.econet.async_setup", return_value=True), patch( - "homeassistant.components.econet.async_setup_entry", return_value=True - ): + ), patch("homeassistant.components.econet.async_setup_entry", return_value=True): result = await hass.config_entries.flow.async_configure( result["flow_id"], user_input={