Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate CLOSE_COMM_ON_ERROR #99946

Merged
merged 10 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion homeassistant/components/modbus/modbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
gjohansson-ST marked this conversation as resolved.
Show resolved Hide resolved
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(
gjohansson-ST marked this conversation as resolved.
Show resolved Hide resolved
"`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
Expand All @@ -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],
}
Expand Down
6 changes: 6 additions & 0 deletions homeassistant/components/modbus/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
}