mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
Remove async_setup from econet (#93892)
This commit is contained in:
parent
fd08cfb074
commit
c5dd540ffc
@ -19,7 +19,6 @@ from homeassistant.exceptions import ConfigEntryNotReady
|
|||||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send
|
from homeassistant.helpers.dispatcher import async_dispatcher_connect, dispatcher_send
|
||||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||||
from homeassistant.helpers.event import async_track_time_interval
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
from homeassistant.helpers.typing import ConfigType
|
|
||||||
|
|
||||||
from .const import API_CLIENT, DOMAIN, EQUIPMENT
|
from .const import API_CLIENT, DOMAIN, EQUIPMENT
|
||||||
|
|
||||||
@ -36,14 +35,6 @@ PUSH_UPDATE = "econet.push_update"
|
|||||||
INTERVAL = timedelta(minutes=60)
|
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:
|
async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool:
|
||||||
"""Set up EcoNet as config entry."""
|
"""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:
|
except (ClientError, GenericHTTPError, InvalidResponseFormat) as err:
|
||||||
raise ConfigEntryNotReady from 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][API_CLIENT][config_entry.entry_id] = api
|
||||||
hass.data[DOMAIN][EQUIPMENT][config_entry.entry_id] = equipment
|
hass.data[DOMAIN][EQUIPMENT][config_entry.entry_id] = equipment
|
||||||
|
|
||||||
|
@ -25,9 +25,7 @@ async def test_bad_credentials(hass: HomeAssistant) -> None:
|
|||||||
with patch(
|
with patch(
|
||||||
"pyeconet.EcoNetApiInterface.login",
|
"pyeconet.EcoNetApiInterface.login",
|
||||||
side_effect=InvalidCredentialsError(),
|
side_effect=InvalidCredentialsError(),
|
||||||
), patch("homeassistant.components.econet.async_setup", return_value=True), patch(
|
), patch("homeassistant.components.econet.async_setup_entry", return_value=True):
|
||||||
"homeassistant.components.econet.async_setup_entry", return_value=True
|
|
||||||
):
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={
|
user_input={
|
||||||
@ -55,9 +53,7 @@ async def test_generic_error_from_library(hass: HomeAssistant) -> None:
|
|||||||
with patch(
|
with patch(
|
||||||
"pyeconet.EcoNetApiInterface.login",
|
"pyeconet.EcoNetApiInterface.login",
|
||||||
side_effect=PyeconetError(),
|
side_effect=PyeconetError(),
|
||||||
), patch("homeassistant.components.econet.async_setup", return_value=True), patch(
|
), patch("homeassistant.components.econet.async_setup_entry", return_value=True):
|
||||||
"homeassistant.components.econet.async_setup_entry", return_value=True
|
|
||||||
):
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={
|
user_input={
|
||||||
@ -85,9 +81,7 @@ async def test_auth_worked(hass: HomeAssistant) -> None:
|
|||||||
with patch(
|
with patch(
|
||||||
"pyeconet.EcoNetApiInterface.login",
|
"pyeconet.EcoNetApiInterface.login",
|
||||||
return_value=EcoNetApiInterface,
|
return_value=EcoNetApiInterface,
|
||||||
), patch("homeassistant.components.econet.async_setup", return_value=True), patch(
|
), patch("homeassistant.components.econet.async_setup_entry", return_value=True):
|
||||||
"homeassistant.components.econet.async_setup_entry", return_value=True
|
|
||||||
):
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={
|
user_input={
|
||||||
@ -122,9 +116,7 @@ async def test_already_configured(hass: HomeAssistant) -> None:
|
|||||||
with patch(
|
with patch(
|
||||||
"pyeconet.EcoNetApiInterface.login",
|
"pyeconet.EcoNetApiInterface.login",
|
||||||
return_value=EcoNetApiInterface,
|
return_value=EcoNetApiInterface,
|
||||||
), patch("homeassistant.components.econet.async_setup", return_value=True), patch(
|
), patch("homeassistant.components.econet.async_setup_entry", return_value=True):
|
||||||
"homeassistant.components.econet.async_setup_entry", return_value=True
|
|
||||||
):
|
|
||||||
result = await hass.config_entries.flow.async_configure(
|
result = await hass.config_entries.flow.async_configure(
|
||||||
result["flow_id"],
|
result["flow_id"],
|
||||||
user_input={
|
user_input={
|
||||||
|
Loading…
x
Reference in New Issue
Block a user