From d1d1bca29d838a48ab40f972edbd77a9715d47e0 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Thu, 29 May 2025 14:12:51 +0200 Subject: [PATCH] Deprecate sms integration (#145847) --- .../components/homeassistant/strings.json | 4 ++ homeassistant/components/sms/__init__.py | 24 +++++++- tests/components/sms/test_init.py | 59 +++++++++++++++++++ 3 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 tests/components/sms/test_init.py diff --git a/homeassistant/components/homeassistant/strings.json b/homeassistant/components/homeassistant/strings.json index e4c3e19cf7c..123e625d0fc 100644 --- a/homeassistant/components/homeassistant/strings.json +++ b/homeassistant/components/homeassistant/strings.json @@ -18,6 +18,10 @@ "title": "The {integration_title} YAML configuration is being removed", "description": "Configuring {integration_title} using YAML is being removed.\n\nYour existing YAML configuration has been imported into the UI automatically.\n\nRemove the `{domain}` configuration from your configuration.yaml file and restart Home Assistant to fix this issue." }, + "deprecated_system_packages_config_flow_integration": { + "title": "The {integration_title} integration is being removed", + "description": "The {integration_title} integration is being removed as it requires additional system packages, which can't be installed on supported Home Assistant installations. Remove all \"{integration_title}\" config entries to fix this issue." + }, "deprecated_system_packages_yaml_integration": { "title": "The {integration_title} integration is being removed", "description": "The {integration_title} integration is being removed as it requires additional system packages, which can't be installed on supported Home Assistant installations. Remove the `{domain}` configuration from your configuration.yaml file and restart Home Assistant to fix this issue." diff --git a/homeassistant/components/sms/__init__.py b/homeassistant/components/sms/__init__.py index 2d18d44de3a..6c7c5374f7d 100644 --- a/homeassistant/components/sms/__init__.py +++ b/homeassistant/components/sms/__init__.py @@ -6,9 +6,14 @@ import voluptuous as vol from homeassistant.config_entries import ConfigEntry from homeassistant.const import CONF_DEVICE, CONF_NAME, Platform -from homeassistant.core import HomeAssistant +from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import config_validation as cv, discovery +from homeassistant.helpers.issue_registry import ( + IssueSeverity, + async_create_issue, + async_delete_issue, +) from homeassistant.helpers.typing import ConfigType from .const import ( @@ -41,6 +46,7 @@ CONFIG_SCHEMA = vol.Schema( }, extra=vol.ALLOW_EXTRA, ) +DEPRECATED_ISSUE_ID = f"deprecated_system_packages_config_flow_integration_{DOMAIN}" async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: @@ -52,6 +58,19 @@ async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Configure Gammu state machine.""" + async_create_issue( + hass, + HOMEASSISTANT_DOMAIN, + DEPRECATED_ISSUE_ID, + breaks_in_ha_version="2025.12.0", + is_fixable=False, + issue_domain=DOMAIN, + severity=IssueSeverity.WARNING, + translation_key="deprecated_system_packages_config_flow_integration", + translation_placeholders={ + "integration_title": "SMS notifications via GSM-modem", + }, + ) device = entry.data[CONF_DEVICE] connection_mode = "at" @@ -101,4 +120,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: gateway = hass.data[DOMAIN].pop(SMS_GATEWAY)[GATEWAY] await gateway.terminate_async() + if not hass.config_entries.async_loaded_entries(DOMAIN): + async_delete_issue(hass, HOMEASSISTANT_DOMAIN, DEPRECATED_ISSUE_ID) + return unload_ok diff --git a/tests/components/sms/test_init.py b/tests/components/sms/test_init.py new file mode 100644 index 00000000000..03cebfe9b52 --- /dev/null +++ b/tests/components/sms/test_init.py @@ -0,0 +1,59 @@ +"""Test init.""" + +from unittest.mock import Mock, patch + +from homeassistant.config_entries import ConfigEntryState +from homeassistant.const import CONF_DEVICE +from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant +from homeassistant.helpers import issue_registry as ir + +from tests.common import MockConfigEntry + + +@patch.dict( + "sys.modules", + { + "gammu": Mock(), + "gammu.asyncworker": Mock(), + }, +) +async def test_repair_issue_is_created( + hass: HomeAssistant, + issue_registry: ir.IssueRegistry, +) -> None: + """Test repair issue is created.""" + from homeassistant.components.sms import ( # pylint: disable=import-outside-toplevel + DEPRECATED_ISSUE_ID, + DOMAIN as SMS_DOMAIN, + ) + + with ( + patch("homeassistant.components.sms.create_sms_gateway", autospec=True), + patch("homeassistant.components.sms.PLATFORMS", []), + ): + config_entry = MockConfigEntry( + title="test", + domain=SMS_DOMAIN, + data={ + CONF_DEVICE: "/dev/ttyUSB0", + }, + ) + + config_entry.add_to_hass(hass) + await hass.config_entries.async_setup(config_entry.entry_id) + await hass.async_block_till_done() + + assert config_entry.state is ConfigEntryState.LOADED + assert ( + HOMEASSISTANT_DOMAIN, + DEPRECATED_ISSUE_ID, + ) in issue_registry.issues + + await hass.config_entries.async_unload(config_entry.entry_id) + await hass.async_block_till_done() + + assert config_entry.state is ConfigEntryState.NOT_LOADED + assert ( + HOMEASSISTANT_DOMAIN, + DEPRECATED_ISSUE_ID, + ) not in issue_registry.issues