Deprecate CLOSE_COMM_ON_ERROR (#99946)

This commit is contained in:
jan iversen 2023-09-09 18:34:01 +02:00 committed by GitHub
parent 71726130c3
commit 743ce46311
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 1 deletions

View file

@ -34,6 +34,7 @@ import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.discovery import async_load_platform
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.event import async_call_later
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.typing import ConfigType
@ -255,6 +256,24 @@ class ModbusHub:
def __init__(self, hass: HomeAssistant, client_config: dict[str, Any]) -> None:
"""Initialize the Modbus hub."""
if CONF_CLOSE_COMM_ON_ERROR in client_config:
async_create_issue( # pragma: no cover
hass,
DOMAIN,
"deprecated_close_comm_config",
breaks_in_ha_version="2024.4.0",
is_fixable=False,
severity=IssueSeverity.WARNING,
translation_key="deprecated_close_comm_config",
translation_placeholders={
"config_key": "close_comm_on_error",
"integration": DOMAIN,
"url": "https://www.home-assistant.io/integrations/modbus",
},
)
_LOGGER.warning(
"`close_comm_on_error`: is deprecated and will be remove in version 2024.4"
)
# generic configuration
self._client: ModbusBaseClient | None = None
self._async_cancel_listener: Callable[[], None] | None = None
@ -274,7 +293,6 @@ class ModbusHub:
self._pb_params = {
"port": client_config[CONF_PORT],
"timeout": client_config[CONF_TIMEOUT],
"reset_socket": client_config[CONF_CLOSE_COMM_ON_ERROR],
"retries": client_config[CONF_RETRIES],
"retry_on_empty": client_config[CONF_RETRY_ON_EMPTY],
}