Hot fix version of Apply modbus interval patch (#51487)

This commit is contained in:
Paulus Schoutsen
2021-06-04 10:02:42 -07:00
committed by GitHub
parent a3c5022956
commit 6f4302ff70
2 changed files with 11 additions and 10 deletions

View File

@@ -99,7 +99,6 @@ from .const import (
DEFAULT_SCAN_INTERVAL,
DEFAULT_STRUCTURE_PREFIX,
DEFAULT_TEMP_UNIT,
MINIMUM_SCAN_INTERVAL,
MODBUS_DOMAIN as DOMAIN,
PLATFORMS,
)
@@ -139,27 +138,30 @@ def control_scan_interval(config: dict) -> dict:
for entry in hub[conf_key]:
scan_interval = entry.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
if scan_interval < MINIMUM_SCAN_INTERVAL:
if scan_interval == 0:
continue
if scan_interval == 0:
continue
if scan_interval < 5:
_LOGGER.warning(
"%s %s scan_interval(%d) is adjusted to minimum(%d)",
"%s %s scan_interval(%d) is lower than 5 seconds, "
"which may cause Home Assistant stability issues",
component,
entry.get(CONF_NAME),
scan_interval,
MINIMUM_SCAN_INTERVAL,
)
scan_interval = MINIMUM_SCAN_INTERVAL
entry[CONF_SCAN_INTERVAL] = scan_interval
minimum_scan_interval = min(scan_interval, minimum_scan_interval)
if CONF_TIMEOUT in hub and hub[CONF_TIMEOUT] > minimum_scan_interval - 1:
if (
CONF_TIMEOUT in hub
and hub[CONF_TIMEOUT] > minimum_scan_interval - 1
and minimum_scan_interval > 1
):
_LOGGER.warning(
"Modbus %s timeout(%d) is adjusted(%d) due to scan_interval",
hub.get(CONF_NAME, ""),
hub[CONF_TIMEOUT],
minimum_scan_interval - 1,
)
hub[CONF_TIMEOUT] = minimum_scan_interval - 1
hub[CONF_TIMEOUT] = minimum_scan_interval - 1
return config

View File

@@ -90,7 +90,6 @@ SERVICE_WRITE_REGISTER = "write_register"
# integration names
DEFAULT_HUB = "modbus_hub"
MINIMUM_SCAN_INTERVAL = 5 # seconds
DEFAULT_SCAN_INTERVAL = 15 # seconds
DEFAULT_SLAVE = 1
DEFAULT_STRUCTURE_PREFIX = ">f"