diff --git a/homeassistant/components/modbus/modbus.py b/homeassistant/components/modbus/modbus.py index fdb7be3d3cf84..238df4466c432 100644 --- a/homeassistant/components/modbus/modbus.py +++ b/homeassistant/components/modbus/modbus.py @@ -34,6 +34,7 @@ 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 @@ def __init__(self, hass: HomeAssistant, client_config: dict[str, Any]) -> None: 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], } diff --git a/homeassistant/components/modbus/strings.json b/homeassistant/components/modbus/strings.json index 61694074d7920..780757a3eeb8b 100644 --- a/homeassistant/components/modbus/strings.json +++ b/homeassistant/components/modbus/strings.json @@ -68,5 +68,11 @@ } } } + }, + "issues": { + "deprecated_close_comm_config": { + "title": "`{config_key}` configuration key is being removed", + "description": "Please remove the `{config_key}` key from the {integration} entry in your configuration.yaml file and restart Home Assistant to fix this issue.\n\nCommunication is automatically closed on errors, see [the documentation]({url}) for other error handling parameters." + } } }