Fix RFLink TCP KeepAlive error log (#47395)

pull/47431/head
Christophe Painchaud 2021-03-05 01:09:54 +01:00 committed by GitHub
parent 35d5522e79
commit a1faba29f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 19 deletions

View File

@ -203,25 +203,28 @@ async def async_setup(hass, config):
# TCP port when host configured, otherwise serial port # TCP port when host configured, otherwise serial port
port = config[DOMAIN][CONF_PORT] port = config[DOMAIN][CONF_PORT]
# TCP KEEPALIVE will be enabled if value > 0 keepalive_idle_timer = None
keepalive_idle_timer = config[DOMAIN][CONF_KEEPALIVE_IDLE] # TCP KeepAlive only if this is TCP based connection (not serial)
if keepalive_idle_timer < 0: if host is not None:
_LOGGER.error( # TCP KEEPALIVE will be enabled if value > 0
"A bogus TCP Keepalive IDLE timer was provided (%d secs), " keepalive_idle_timer = config[DOMAIN][CONF_KEEPALIVE_IDLE]
"default value will be used. " if keepalive_idle_timer < 0:
"Recommended values: 60-3600 (seconds)", _LOGGER.error(
keepalive_idle_timer, "A bogus TCP Keepalive IDLE timer was provided (%d secs), "
) "it will be disabled. "
keepalive_idle_timer = DEFAULT_TCP_KEEPALIVE_IDLE_TIMER "Recommended values: 60-3600 (seconds)",
elif keepalive_idle_timer == 0: keepalive_idle_timer,
keepalive_idle_timer = None )
elif keepalive_idle_timer <= 30: keepalive_idle_timer = None
_LOGGER.warning( elif keepalive_idle_timer == 0:
"A very short TCP Keepalive IDLE timer was provided (%d secs), " keepalive_idle_timer = None
"and may produce unexpected disconnections from RFlink device." elif keepalive_idle_timer <= 30:
" Recommended values: 60-3600 (seconds)", _LOGGER.warning(
keepalive_idle_timer, "A very short TCP Keepalive IDLE timer was provided (%d secs) "
) "and may produce unexpected disconnections from RFlink device."
" Recommended values: 60-3600 (seconds)",
keepalive_idle_timer,
)
@callback @callback
def reconnect(exc=None): def reconnect(exc=None):