mirror of
https://github.com/home-assistant/core.git
synced 2025-08-05 21:55:10 +02:00
fix recursion
This commit is contained in:
@@ -43,8 +43,10 @@ async def async_setup(hass, config):
|
|||||||
"""Set up the Samsung TV integration."""
|
"""Set up the Samsung TV integration."""
|
||||||
if DOMAIN in config:
|
if DOMAIN in config:
|
||||||
for entry_config in config[DOMAIN]:
|
for entry_config in config[DOMAIN]:
|
||||||
await hass.config_entries.flow.async_init(
|
hass.async_create_task(
|
||||||
DOMAIN, context={"source": "import"}, data=entry_config
|
hass.config_entries.flow.async_init(
|
||||||
|
DOMAIN, context={"source": "import"}, data=entry_config
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@@ -34,6 +34,10 @@ RESULT_NOT_FOUND = "not_found"
|
|||||||
RESULT_NOT_SUPPORTED = "not_supported"
|
RESULT_NOT_SUPPORTED = "not_supported"
|
||||||
|
|
||||||
|
|
||||||
|
def _is_already_in_progress(flows, ip_address):
|
||||||
|
return any(ip_address == flow["context"].get(CONF_IP_ADDRESS) for flow in flows)
|
||||||
|
|
||||||
|
|
||||||
def _is_already_configured(hass, ip_address):
|
def _is_already_configured(hass, ip_address):
|
||||||
return any(
|
return any(
|
||||||
ip_address == entry.data.get(CONF_IP_ADDRESS)
|
ip_address == entry.data.get(CONF_IP_ADDRESS)
|
||||||
@@ -127,6 +131,9 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
_get_ip, user_input[CONF_HOST]
|
_get_ip, user_input[CONF_HOST]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if _is_already_in_progress(self._async_in_progress(), ip_address):
|
||||||
|
return self.async_abort(reason="already_in_progress")
|
||||||
|
|
||||||
if _is_already_configured(self.hass, ip_address):
|
if _is_already_configured(self.hass, ip_address):
|
||||||
return self.async_abort(reason="already_configured")
|
return self.async_abort(reason="already_configured")
|
||||||
|
|
||||||
@@ -154,10 +161,7 @@ class SamsungTVConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
_get_ip, user_input[ATTR_SSDP_LOCATION]
|
_get_ip, user_input[ATTR_SSDP_LOCATION]
|
||||||
)
|
)
|
||||||
|
|
||||||
if any(
|
if _is_already_in_progress(self._async_in_progress(), ip_address):
|
||||||
ip_address == flow["context"].get(CONF_IP_ADDRESS)
|
|
||||||
for flow in self._async_in_progress()
|
|
||||||
):
|
|
||||||
return self.async_abort(reason="already_in_progress")
|
return self.async_abort(reason="already_in_progress")
|
||||||
|
|
||||||
if _is_already_configured(self.hass, ip_address):
|
if _is_already_configured(self.hass, ip_address):
|
||||||
|
@@ -10,7 +10,6 @@ from samsungctl import exceptions
|
|||||||
import wakeonlan
|
import wakeonlan
|
||||||
from websocket import WebSocketException
|
from websocket import WebSocketException
|
||||||
|
|
||||||
from homeassistant.components import samsungtv
|
|
||||||
from homeassistant.components.media_player import DEVICE_CLASS_TV
|
from homeassistant.components.media_player import DEVICE_CLASS_TV
|
||||||
from homeassistant.components.media_player.const import (
|
from homeassistant.components.media_player.const import (
|
||||||
ATTR_INPUT_SOURCE,
|
ATTR_INPUT_SOURCE,
|
||||||
@@ -24,7 +23,10 @@ from homeassistant.components.media_player.const import (
|
|||||||
SERVICE_SELECT_SOURCE,
|
SERVICE_SELECT_SOURCE,
|
||||||
SUPPORT_TURN_ON,
|
SUPPORT_TURN_ON,
|
||||||
)
|
)
|
||||||
from homeassistant.components.samsungtv.const import DOMAIN as SAMSUNGTV_DOMAIN
|
from homeassistant.components.samsungtv.const import (
|
||||||
|
DEFAULT_TIMEOUT,
|
||||||
|
DOMAIN as SAMSUNGTV_DOMAIN,
|
||||||
|
)
|
||||||
from homeassistant.components.samsungtv.media_player import (
|
from homeassistant.components.samsungtv.media_player import (
|
||||||
CONF_TIMEOUT,
|
CONF_TIMEOUT,
|
||||||
SUPPORT_SAMSUNGTV,
|
SUPPORT_SAMSUNGTV,
|
||||||
@@ -52,6 +54,7 @@ from homeassistant.const import (
|
|||||||
STATE_ON,
|
STATE_ON,
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
)
|
)
|
||||||
|
from homeassistant.setup import async_setup_component
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
from tests.common import async_fire_time_changed
|
from tests.common import async_fire_time_changed
|
||||||
@@ -131,7 +134,7 @@ AUTODETECT_WEBSOCKET = {
|
|||||||
"method": "websocket",
|
"method": "websocket",
|
||||||
"port": None,
|
"port": None,
|
||||||
"host": "fake_auto",
|
"host": "fake_auto",
|
||||||
"timeout": None,
|
"timeout": DEFAULT_TIMEOUT,
|
||||||
}
|
}
|
||||||
AUTODETECT_LEGACY = {
|
AUTODETECT_LEGACY = {
|
||||||
"name": "HomeAssistant",
|
"name": "HomeAssistant",
|
||||||
@@ -140,7 +143,7 @@ AUTODETECT_LEGACY = {
|
|||||||
"method": "legacy",
|
"method": "legacy",
|
||||||
"port": None,
|
"port": None,
|
||||||
"host": "fake_auto",
|
"host": "fake_auto",
|
||||||
"timeout": None,
|
"timeout": DEFAULT_TIMEOUT,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -175,7 +178,7 @@ def mock_now():
|
|||||||
|
|
||||||
async def setup_samsungtv(hass, config):
|
async def setup_samsungtv(hass, config):
|
||||||
"""Set up mock Samsung TV."""
|
"""Set up mock Samsung TV."""
|
||||||
await samsungtv.async_setup(hass, config)
|
await async_setup_component(hass, SAMSUNGTV_DOMAIN, config)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user