From 8523c66bb5dc6f7046286494a44a0c58e192094d Mon Sep 17 00:00:00 2001
From: Franck Nijhof <git@frenck.dev>
Date: Thu, 21 Jul 2022 13:56:55 +0200
Subject: [PATCH] Deprecate U.S. Citizenship and Immigration Services (USCIS)
 integration (#75562)

---
 homeassistant/components/uscis/manifest.json        |  1 +
 homeassistant/components/uscis/sensor.py            | 13 +++++++++++++
 homeassistant/components/uscis/strings.json         |  8 ++++++++
 homeassistant/components/uscis/translations/en.json |  8 ++++++++
 4 files changed, 30 insertions(+)
 create mode 100644 homeassistant/components/uscis/strings.json
 create mode 100644 homeassistant/components/uscis/translations/en.json

diff --git a/homeassistant/components/uscis/manifest.json b/homeassistant/components/uscis/manifest.json
index 0680848f70a..882dc588eba 100644
--- a/homeassistant/components/uscis/manifest.json
+++ b/homeassistant/components/uscis/manifest.json
@@ -3,6 +3,7 @@
   "name": "U.S. Citizenship and Immigration Services (USCIS)",
   "documentation": "https://www.home-assistant.io/integrations/uscis",
   "requirements": ["uscisstatus==0.1.1"],
+  "dependencies": ["repairs"],
   "codeowners": [],
   "iot_class": "cloud_polling",
   "loggers": ["uscisstatus"]
diff --git a/homeassistant/components/uscis/sensor.py b/homeassistant/components/uscis/sensor.py
index 564c449e8b6..b4719243a8b 100644
--- a/homeassistant/components/uscis/sensor.py
+++ b/homeassistant/components/uscis/sensor.py
@@ -7,6 +7,7 @@ import logging
 import uscisstatus
 import voluptuous as vol
 
+from homeassistant.components.repairs import IssueSeverity, create_issue
 from homeassistant.components.sensor import PLATFORM_SCHEMA, SensorEntity
 from homeassistant.const import CONF_NAME
 from homeassistant.core import HomeAssistant
@@ -34,6 +35,18 @@ def setup_platform(
     discovery_info: DiscoveryInfoType | None = None,
 ) -> None:
     """Set up the platform in Home Assistant and Case Information."""
+    create_issue(
+        hass,
+        "uscis",
+        "pending_removal",
+        breaks_in_ha_version="2022.10.0",
+        is_fixable=False,
+        severity=IssueSeverity.WARNING,
+        translation_key="pending_removal",
+    )
+    _LOGGER.warning(
+        "The USCIS sensor component is deprecated and will be removed in Home Assistant 2022.10"
+    )
     uscis = UscisSensor(config["case_id"], config[CONF_NAME])
     uscis.update()
     if uscis.valid_case_id:
diff --git a/homeassistant/components/uscis/strings.json b/homeassistant/components/uscis/strings.json
new file mode 100644
index 00000000000..b8dec86db18
--- /dev/null
+++ b/homeassistant/components/uscis/strings.json
@@ -0,0 +1,8 @@
+{
+  "issues": {
+    "pending_removal": {
+      "title": "The USCIS integration is being removed",
+      "description": "The U.S. Citizenship and Immigration Services (USCIS) integration is pending removal from Home Assistant and will no longer be available as of Home Assistant 2022.10.\n\nThe integration is being removed, because it relies on webscraping, which is not allowed.\n\nRemove the YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue."
+    }
+  }
+}
diff --git a/homeassistant/components/uscis/translations/en.json b/homeassistant/components/uscis/translations/en.json
new file mode 100644
index 00000000000..24e7e9ceea0
--- /dev/null
+++ b/homeassistant/components/uscis/translations/en.json
@@ -0,0 +1,8 @@
+{
+    "issues": {
+        "pending_removal": {
+            "description": "The U.S. Citizenship and Immigration Services (USCIS) integration is pending removal from Home Assistant and will no longer be available as of Home Assistant 2022.10.\n\nThe integration is being removed, because it relies on webscraping, which is not allowed.\n\nRemove the YAML configuration from your configuration.yaml file and restart Home Assistant to fix this issue.",
+            "title": "The USCIS integration is being removed"
+        }
+    }
+}
\ No newline at end of file
-- 
GitLab