Skip to content

Commit

Permalink
Deprecate parameter "retries" in modbus (#105024)
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen authored Dec 24, 2023
1 parent 7714095 commit 9066555
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
20 changes: 19 additions & 1 deletion homeassistant/components/modbus/modbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,24 @@ class ModbusHub:
def __init__(self, hass: HomeAssistant, client_config: dict[str, Any]) -> None:
"""Initialize the Modbus hub."""

if CONF_RETRIES in client_config:
async_create_issue(
hass,
DOMAIN,
"deprecated_retries",
breaks_in_ha_version="2024.7.0",
is_fixable=False,
severity=IssueSeverity.WARNING,
translation_key="deprecated_retries",
translation_placeholders={
"config_key": "retries",
"integration": DOMAIN,
"url": "https://www.home-assistant.io/integrations/modbus",
},
)
_LOGGER.warning(
"`retries`: is deprecated and will be removed in version 2024.7"
)
if CONF_CLOSE_COMM_ON_ERROR in client_config:
async_create_issue(
hass,
Expand Down Expand Up @@ -315,7 +333,7 @@ def __init__(self, hass: HomeAssistant, client_config: dict[str, Any]) -> None:
self._pb_params = {
"port": client_config[CONF_PORT],
"timeout": client_config[CONF_TIMEOUT],
"retries": client_config[CONF_RETRIES],
"retries": 3,
"retry_on_empty": True,
}
if self._config_type == SERIAL:
Expand Down
4 changes: 4 additions & 0 deletions homeassistant/components/modbus/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
"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. All errors will be reported, as lazy_error_count is accepted but ignored"
},
"deprecated_retries": {
"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\nThe maximum number of retries is now fixed to 3."
},
"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. All errors will be reported, as `lazy_error_count` is accepted but ignored."
Expand Down

0 comments on commit 9066555

Please sign in to comment.