From 49f91666469ee0ae5d058f4d557ce4f4587e4891 Mon Sep 17 00:00:00 2001 From: Robert Resch Date: Mon, 26 May 2025 16:48:41 +0200 Subject: [PATCH] Deprecate cups integration (#145615) --- CODEOWNERS | 1 + homeassistant/components/cups/__init__.py | 3 ++ homeassistant/components/cups/sensor.py | 21 +++++++++- .../components/homeassistant/strings.json | 4 ++ requirements_test_all.txt | 3 ++ tests/components/cups/__init__.py | 1 + tests/components/cups/test_sensor.py | 40 +++++++++++++++++++ 7 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 tests/components/cups/__init__.py create mode 100644 tests/components/cups/test_sensor.py diff --git a/CODEOWNERS b/CODEOWNERS index 45070195112..3f3ce07ce84 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -305,6 +305,7 @@ build.json @home-assistant/supervisor /homeassistant/components/crownstone/ @Crownstone @RicArch97 /tests/components/crownstone/ @Crownstone @RicArch97 /homeassistant/components/cups/ @fabaff +/tests/components/cups/ @fabaff /homeassistant/components/daikin/ @fredrike /tests/components/daikin/ @fredrike /homeassistant/components/date/ @home-assistant/core diff --git a/homeassistant/components/cups/__init__.py b/homeassistant/components/cups/__init__.py index 7cd5ce4ca0a..92679aec079 100644 --- a/homeassistant/components/cups/__init__.py +++ b/homeassistant/components/cups/__init__.py @@ -1 +1,4 @@ """The cups component.""" + +DOMAIN = "cups" +CONF_PRINTERS = "printers" diff --git a/homeassistant/components/cups/sensor.py b/homeassistant/components/cups/sensor.py index 701bad3f104..671c8c87a8c 100644 --- a/homeassistant/components/cups/sensor.py +++ b/homeassistant/components/cups/sensor.py @@ -14,12 +14,15 @@ from homeassistant.components.sensor import ( SensorEntity, ) from homeassistant.const import CONF_HOST, CONF_PORT, PERCENTAGE -from homeassistant.core import HomeAssistant +from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant from homeassistant.exceptions import PlatformNotReady from homeassistant.helpers import config_validation as cv from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.issue_registry import IssueSeverity, create_issue from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType +from . import CONF_PRINTERS, DOMAIN + _LOGGER = logging.getLogger(__name__) ATTR_MARKER_TYPE = "marker_type" @@ -36,7 +39,6 @@ ATTR_PRINTER_STATE_REASON = "printer_state_reason" ATTR_PRINTER_TYPE = "printer_type" ATTR_PRINTER_URI_SUPPORTED = "printer_uri_supported" -CONF_PRINTERS = "printers" CONF_IS_CUPS_SERVER = "is_cups_server" DEFAULT_HOST = "127.0.0.1" @@ -72,6 +74,21 @@ def setup_platform( printers: list[str] = config[CONF_PRINTERS] is_cups: bool = config[CONF_IS_CUPS_SERVER] + create_issue( + hass, + HOMEASSISTANT_DOMAIN, + f"deprecated_system_packages_yaml_integration_{DOMAIN}", + breaks_in_ha_version="2025.12.0", + is_fixable=False, + issue_domain=DOMAIN, + severity=IssueSeverity.WARNING, + translation_key="deprecated_system_packages_yaml_integration", + translation_placeholders={ + "domain": DOMAIN, + "integration_title": "CUPS", + }, + ) + if is_cups: data = CupsData(host, port, None) data.update() diff --git a/homeassistant/components/homeassistant/strings.json b/homeassistant/components/homeassistant/strings.json index b8b5f77cf52..0987461b4dc 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_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." + }, "historic_currency": { "title": "The configured currency is no longer in use", "description": "The currency {currency} is no longer in use, please reconfigure the currency configuration." diff --git a/requirements_test_all.txt b/requirements_test_all.txt index ecd2a1d2b31..2b156e3ca2a 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1560,6 +1560,9 @@ pycountry==24.6.1 # homeassistant.components.microsoft pycsspeechtts==1.0.8 +# homeassistant.components.cups +# pycups==2.0.4 + # homeassistant.components.daikin pydaikin==2.15.0 diff --git a/tests/components/cups/__init__.py b/tests/components/cups/__init__.py new file mode 100644 index 00000000000..c96e2d7c7dc --- /dev/null +++ b/tests/components/cups/__init__.py @@ -0,0 +1 @@ +"""CUPS tests.""" diff --git a/tests/components/cups/test_sensor.py b/tests/components/cups/test_sensor.py new file mode 100644 index 00000000000..60e7ce5fd44 --- /dev/null +++ b/tests/components/cups/test_sensor.py @@ -0,0 +1,40 @@ +"""Tests for the CUPS sensor platform.""" + +from unittest.mock import patch + +from homeassistant.components.cups import CONF_PRINTERS, DOMAIN as CUPS_DOMAIN +from homeassistant.components.sensor.const import DOMAIN as SENSOR_DOMAIN +from homeassistant.const import CONF_PLATFORM +from homeassistant.core import DOMAIN as HOMEASSISTANT_DOMAIN, HomeAssistant +from homeassistant.helpers import issue_registry as ir +from homeassistant.setup import async_setup_component + + +async def test_repair_issue_is_created( + hass: HomeAssistant, + issue_registry: ir.IssueRegistry, +) -> None: + """Test repair issue is created.""" + with patch( + "homeassistant.components.cups.sensor.CupsData", autospec=True + ) as cups_data: + cups_data.available = True + assert await async_setup_component( + hass, + SENSOR_DOMAIN, + { + SENSOR_DOMAIN: [ + { + CONF_PLATFORM: CUPS_DOMAIN, + CONF_PRINTERS: [ + "printer1", + ], + } + ], + }, + ) + await hass.async_block_till_done() + assert ( + HOMEASSISTANT_DOMAIN, + f"deprecated_system_packages_yaml_integration_{CUPS_DOMAIN}", + ) in issue_registry.issues