Skip to content

Commit

Permalink
Deprecate modbus parameter retry_on_empty (#100292)
Browse files Browse the repository at this point in the history
  • Loading branch information
janiversen authored Sep 16, 2023
1 parent 81af453 commit 9931f45
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/modbus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
vol.Optional(CONF_CLOSE_COMM_ON_ERROR): cv.boolean,
vol.Optional(CONF_DELAY, default=0): cv.positive_int,
vol.Optional(CONF_RETRIES, default=3): cv.positive_int,
vol.Optional(CONF_RETRY_ON_EMPTY, default=False): cv.boolean,
vol.Optional(CONF_RETRY_ON_EMPTY): cv.boolean,
vol.Optional(CONF_MSG_WAIT): cv.positive_int,
vol.Optional(CONF_BINARY_SENSORS): vol.All(
cv.ensure_list, [BINARY_SENSOR_SCHEMA]
Expand Down
22 changes: 20 additions & 2 deletions homeassistant/components/modbus/modbus.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,25 @@ def __init__(self, hass: HomeAssistant, client_config: dict[str, Any]) -> None:
},
)
_LOGGER.warning(
"`close_comm_on_error`: is deprecated and will be remove in version 2024.4"
"`close_comm_on_error`: is deprecated and will be removed in version 2024.4"
)
if CONF_RETRY_ON_EMPTY in client_config:
async_create_issue(
hass,
DOMAIN,
"deprecated_retry_on_empty",
breaks_in_ha_version="2024.4.0",
is_fixable=False,
severity=IssueSeverity.WARNING,
translation_key="deprecated_retry_on_empty",
translation_placeholders={
"config_key": "retry_on_empty",
"integration": DOMAIN,
"url": "https://www.home-assistant.io/integrations/modbus",
},
)
_LOGGER.warning(
"`retry_on_empty`: is deprecated and will be removed in version 2024.4"
)
# generic configuration
self._client: ModbusBaseClient | None = None
Expand All @@ -298,7 +316,7 @@ def __init__(self, hass: HomeAssistant, client_config: dict[str, Any]) -> None:
"port": client_config[CONF_PORT],
"timeout": client_config[CONF_TIMEOUT],
"retries": client_config[CONF_RETRIES],
"retry_on_empty": client_config[CONF_RETRY_ON_EMPTY],
"retry_on_empty": True,
}
if self._config_type == SERIAL:
# serial configuration
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 @@ -73,6 +73,10 @@
"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."
},
"deprecated_retry_on_empty": {
"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\nRetry on empty is automatically applied, see [the documentation]({url}) for other error handling parameters."
}
}
}
7 changes: 7 additions & 0 deletions tests/components/modbus/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
CONF_INPUT_TYPE,
CONF_MSG_WAIT,
CONF_PARITY,
CONF_RETRY_ON_EMPTY,
CONF_SLAVE_COUNT,
CONF_STOPBITS,
CONF_SWAP,
Expand Down Expand Up @@ -420,6 +421,12 @@ async def test_duplicate_entity_validator(do_config) -> None:
CONF_PORT: TEST_PORT_TCP,
CONF_CLOSE_COMM_ON_ERROR: True,
},
{
CONF_TYPE: TCP,
CONF_HOST: TEST_MODBUS_HOST,
CONF_PORT: TEST_PORT_TCP,
CONF_RETRY_ON_EMPTY: True,
},
{
CONF_TYPE: TCP,
CONF_HOST: TEST_MODBUS_HOST,
Expand Down

0 comments on commit 9931f45

Please sign in to comment.