1
mirror of https://github.com/home-assistant/core synced 2024-09-06 10:29:55 +02:00

Remove async_setup from econet (#93892)

This commit is contained in:
Erik Montnemery 2023-06-01 12:18:54 +02:00 committed by GitHub
parent fd08cfb074
commit c5dd540ffc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 21 deletions

View File

@ -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

View File

@ -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={