Update default timeout to 60s in SMTP integration (#181035)

This commit is contained in:
Manu
2026-09-02 08:47:12 +02:00
committed by GitHub
parent 47d6ecb930
commit 2afe6fed10
5 changed files with 15 additions and 8 deletions
+9 -2
View File
@@ -26,7 +26,14 @@ from homeassistant.helpers import (
from homeassistant.helpers.typing import ConfigType
from homeassistant.util.ssl import client_context, client_context_no_verify
from .const import CONF_ENCRYPTION, CONF_ENTRY, CONF_OLD_RECIPIENT, CONF_SERVER, DOMAIN
from .const import (
CONF_ENCRYPTION,
CONF_ENTRY,
CONF_OLD_RECIPIENT,
CONF_SERVER,
DEFAULT_TIMEOUT,
DOMAIN,
)
from .services import async_setup_services
_LOGGER = logging.getLogger(__name__)
@@ -71,7 +78,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: SmtpConfigEntry) -> bool
port=entry.data[CONF_PORT],
username=entry.data.get(CONF_USERNAME),
password=entry.data.get(CONF_PASSWORD),
timeout=entry.options.get(CONF_TIMEOUT),
timeout=entry.options.get(CONF_TIMEOUT, DEFAULT_TIMEOUT),
use_tls=entry.data[CONF_ENCRYPTION] == "tls",
start_tls=entry.data[CONF_ENCRYPTION] == "starttls",
tls_context=(
+2 -2
View File
@@ -65,7 +65,7 @@ _LOGGER = logging.getLogger(__name__)
OPTIONS_SCHEMA = vol.Schema(
{
vol.Optional(CONF_TIMEOUT, default=DEFAULT_TIMEOUT): vol.All(
vol.Optional(CONF_TIMEOUT): vol.All(
NumberSelector(
NumberSelectorConfig(
min=1,
@@ -309,7 +309,7 @@ async def validate_input(
port=user_input[CONF_PORT],
username=user_input.get(CONF_USERNAME),
password=user_input.get(CONF_PASSWORD),
timeout=options.get(CONF_TIMEOUT),
timeout=options.get(CONF_TIMEOUT, DEFAULT_TIMEOUT),
use_tls=user_input[CONF_ENCRYPTION] == "tls",
start_tls=user_input[CONF_ENCRYPTION] == "starttls",
tls_context=(
+1 -1
View File
@@ -20,7 +20,7 @@ SECTION_OPTIONS: Final = "options"
DEFAULT_HOST: Final = "localhost"
DEFAULT_PORT: Final = 587
DEFAULT_TIMEOUT: Final = 5
DEFAULT_TIMEOUT: Final = 60
DEFAULT_DEBUG: Final = False
DEFAULT_ENCRYPTION: Final = "starttls"
+1 -1
View File
@@ -154,7 +154,7 @@
"timeout": "Connection timeout"
},
"data_description": {
"timeout": "Maximum time to wait for a response from the SMTP server before the connection attempt is aborted."
"timeout": "Maximum time to wait for a response from the SMTP server before the connection attempt is aborted. Defaults to 60 seconds."
}
}
}
+2 -2
View File
@@ -53,7 +53,7 @@ async def test_form(
result["flow_id"],
{
**USER_INPUT,
SECTION_OPTIONS: {CONF_TIMEOUT: 60},
SECTION_OPTIONS: {},
},
)
await hass.async_block_till_done()
@@ -61,7 +61,7 @@ async def test_form(
assert result["type"] is FlowResultType.CREATE_ENTRY
assert result["title"] == "Home Assistant"
assert result["data"] == USER_INPUT
assert result["options"] == {CONF_TIMEOUT: 60}
assert result["options"] == {}
assert len(mock_setup_entry.mock_calls) == 1
await hass.async_block_till_done(wait_background_tasks=True)