From 9066555feb96c59442ad9c8214dec0b28c9194bb Mon Sep 17 00:00:00 2001 From: jan iversen Date: Sun, 24 Dec 2023 16:47:22 +0100 Subject: [PATCH] Deprecate parameter "retries" in modbus (#105024) --- homeassistant/components/modbus/modbus.py | 20 +++++++++++++++++++- homeassistant/components/modbus/strings.json | 4 ++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/modbus/modbus.py b/homeassistant/components/modbus/modbus.py index c0474ad75d5..1d755adace7 100644 --- a/homeassistant/components/modbus/modbus.py +++ b/homeassistant/components/modbus/modbus.py @@ -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, @@ -315,7 +333,7 @@ class ModbusHub: 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: diff --git a/homeassistant/components/modbus/strings.json b/homeassistant/components/modbus/strings.json index c549b59bf8f..12e66f5d2ca 100644 --- a/homeassistant/components/modbus/strings.json +++ b/homeassistant/components/modbus/strings.json @@ -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."