From c6feb30c311a2b7fba4821f102842d9f43f1b4dc Mon Sep 17 00:00:00 2001 From: G Johansson Date: Sun, 28 May 2023 21:53:32 +0200 Subject: [PATCH] Raise issue "does not support platform setup" (#93585) * Raise issue on platform missing * Modify issue * Remove deprecation * Fix strings * Strings * Last strings * strings to common --- .../components/alarm_control_panel/strings.json | 6 ++++++ .../components/binary_sensor/strings.json | 6 ++++++ homeassistant/components/button/strings.json | 6 ++++++ homeassistant/components/calendar/strings.json | 6 ++++++ homeassistant/components/camera/strings.json | 6 ++++++ homeassistant/components/climate/strings.json | 6 ++++++ homeassistant/components/cover/strings.json | 6 ++++++ homeassistant/components/date/strings.json | 6 ++++++ .../components/device_tracker/strings.json | 6 ++++++ homeassistant/components/fan/strings.json | 6 ++++++ homeassistant/components/humidifier/strings.json | 6 ++++++ homeassistant/components/light/strings.json | 6 ++++++ homeassistant/components/lock/strings.json | 6 ++++++ homeassistant/components/media_player/strings.json | 6 ++++++ homeassistant/components/number/strings.json | 6 ++++++ homeassistant/components/remote/strings.json | 6 ++++++ homeassistant/components/select/strings.json | 6 ++++++ homeassistant/components/sensor/strings.json | 6 ++++++ homeassistant/components/siren/strings.json | 6 ++++++ homeassistant/components/switch/strings.json | 6 ++++++ homeassistant/components/text/strings.json | 6 ++++++ homeassistant/components/time/strings.json | 6 ++++++ homeassistant/components/update/strings.json | 6 ++++++ homeassistant/components/vacuum/strings.json | 6 ++++++ homeassistant/components/water_heater/strings.json | 6 ++++++ homeassistant/components/weather/strings.json | 6 ++++++ homeassistant/helpers/entity_platform.py | 14 ++++++++++++++ homeassistant/strings.json | 4 ++++ tests/helpers/test_entity_platform.py | 11 ++++++++++- 29 files changed, 184 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/alarm_control_panel/strings.json b/homeassistant/components/alarm_control_panel/strings.json index 6b01cab2bec..4025bbd4cc4 100644 --- a/homeassistant/components/alarm_control_panel/strings.json +++ b/homeassistant/components/alarm_control_panel/strings.json @@ -62,5 +62,11 @@ } } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/binary_sensor/strings.json b/homeassistant/components/binary_sensor/strings.json index d3045e6e8f7..ca349e19328 100644 --- a/homeassistant/components/binary_sensor/strings.json +++ b/homeassistant/components/binary_sensor/strings.json @@ -314,5 +314,11 @@ "smoke": "smoke", "sound": "sound", "vibration": "vibration" + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/button/strings.json b/homeassistant/components/button/strings.json index 4fd88853893..efad77f5c6d 100644 --- a/homeassistant/components/button/strings.json +++ b/homeassistant/components/button/strings.json @@ -18,5 +18,11 @@ "update": { "name": "Update" } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/calendar/strings.json b/homeassistant/components/calendar/strings.json index 898953c18ac..b28f741c381 100644 --- a/homeassistant/components/calendar/strings.json +++ b/homeassistant/components/calendar/strings.json @@ -32,5 +32,11 @@ } } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/camera/strings.json b/homeassistant/components/camera/strings.json index 0722ec1c5e6..f67097516b4 100644 --- a/homeassistant/components/camera/strings.json +++ b/homeassistant/components/camera/strings.json @@ -34,5 +34,11 @@ } } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/climate/strings.json b/homeassistant/components/climate/strings.json index 5e3fe15d566..00696b0738c 100644 --- a/homeassistant/components/climate/strings.json +++ b/homeassistant/components/climate/strings.json @@ -103,5 +103,11 @@ "temperature": { "name": "Target temperature" } } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/cover/strings.json b/homeassistant/components/cover/strings.json index 2f61bd95083..663df02a824 100644 --- a/homeassistant/components/cover/strings.json +++ b/homeassistant/components/cover/strings.json @@ -76,5 +76,11 @@ "window": { "name": "Window" } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/date/strings.json b/homeassistant/components/date/strings.json index 110a4cabb92..f2d2e5ef8e1 100644 --- a/homeassistant/components/date/strings.json +++ b/homeassistant/components/date/strings.json @@ -4,5 +4,11 @@ "_": { "name": "[%key:component::date::title%]" } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/device_tracker/strings.json b/homeassistant/components/device_tracker/strings.json index c15b9723c97..54e4f922053 100644 --- a/homeassistant/components/device_tracker/strings.json +++ b/homeassistant/components/device_tracker/strings.json @@ -41,5 +41,11 @@ } } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/fan/strings.json b/homeassistant/components/fan/strings.json index b16d6da6df5..b69068d3d64 100644 --- a/homeassistant/components/fan/strings.json +++ b/homeassistant/components/fan/strings.json @@ -52,5 +52,11 @@ } } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/humidifier/strings.json b/homeassistant/components/humidifier/strings.json index afaa05df462..015b3c08e9a 100644 --- a/homeassistant/components/humidifier/strings.json +++ b/homeassistant/components/humidifier/strings.json @@ -62,5 +62,11 @@ "humidifier": { "name": "[%key:component::humidifier::entity_component::_::name%]" } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/light/strings.json b/homeassistant/components/light/strings.json index 935e38d33d9..f89497b5ef9 100644 --- a/homeassistant/components/light/strings.json +++ b/homeassistant/components/light/strings.json @@ -86,5 +86,11 @@ } } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/lock/strings.json b/homeassistant/components/lock/strings.json index da4b5217b86..b77bf5e6900 100644 --- a/homeassistant/components/lock/strings.json +++ b/homeassistant/components/lock/strings.json @@ -34,5 +34,11 @@ } } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/media_player/strings.json b/homeassistant/components/media_player/strings.json index cee0ee200fe..4c33d1f27ef 100644 --- a/homeassistant/components/media_player/strings.json +++ b/homeassistant/components/media_player/strings.json @@ -159,5 +159,11 @@ "receiver": { "name": "Receiver" } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/number/strings.json b/homeassistant/components/number/strings.json index 46db471305c..9af54311129 100644 --- a/homeassistant/components/number/strings.json +++ b/homeassistant/components/number/strings.json @@ -154,5 +154,11 @@ "wind_speed": { "name": "[%key:component::sensor::entity_component::wind_speed::name%]" } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/remote/strings.json b/homeassistant/components/remote/strings.json index f0d2787b658..18a92494242 100644 --- a/homeassistant/components/remote/strings.json +++ b/homeassistant/components/remote/strings.json @@ -24,5 +24,11 @@ "on": "[%key:common::state::on%]" } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/select/strings.json b/homeassistant/components/select/strings.json index 9080b940b2a..53441d365b4 100644 --- a/homeassistant/components/select/strings.json +++ b/homeassistant/components/select/strings.json @@ -24,5 +24,11 @@ } } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/sensor/strings.json b/homeassistant/components/sensor/strings.json index c4c1f81109d..d3dbbc678b0 100644 --- a/homeassistant/components/sensor/strings.json +++ b/homeassistant/components/sensor/strings.json @@ -267,5 +267,11 @@ "wind_speed": { "name": "Wind speed" } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/siren/strings.json b/homeassistant/components/siren/strings.json index 60d8843c151..c3dde16a99f 100644 --- a/homeassistant/components/siren/strings.json +++ b/homeassistant/components/siren/strings.json @@ -13,5 +13,11 @@ } } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/switch/strings.json b/homeassistant/components/switch/strings.json index a7934ba4209..2bb6c82a8c1 100644 --- a/homeassistant/components/switch/strings.json +++ b/homeassistant/components/switch/strings.json @@ -30,5 +30,11 @@ "outlet": { "name": "Outlet" } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/text/strings.json b/homeassistant/components/text/strings.json index 034f1ab315b..d8f55dbe4e7 100644 --- a/homeassistant/components/text/strings.json +++ b/homeassistant/components/text/strings.json @@ -27,5 +27,11 @@ } } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/time/strings.json b/homeassistant/components/time/strings.json index e8d92a30e2e..9cbcf718d73 100644 --- a/homeassistant/components/time/strings.json +++ b/homeassistant/components/time/strings.json @@ -4,5 +4,11 @@ "_": { "name": "[%key:component::time::title%]" } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/update/strings.json b/homeassistant/components/update/strings.json index 776c2c59a3a..4d730d71721 100644 --- a/homeassistant/components/update/strings.json +++ b/homeassistant/components/update/strings.json @@ -14,5 +14,11 @@ "firmware": { "name": "firmware" } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/vacuum/strings.json b/homeassistant/components/vacuum/strings.json index a27a60bba4f..e0db3ba4e47 100644 --- a/homeassistant/components/vacuum/strings.json +++ b/homeassistant/components/vacuum/strings.json @@ -28,5 +28,11 @@ "returning": "Returning to dock" } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/water_heater/strings.json b/homeassistant/components/water_heater/strings.json index 6344b5a847a..b0784279667 100644 --- a/homeassistant/components/water_heater/strings.json +++ b/homeassistant/components/water_heater/strings.json @@ -18,5 +18,11 @@ "performance": "Performance" } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/components/weather/strings.json b/homeassistant/components/weather/strings.json index a64f8467224..461f715c8db 100644 --- a/homeassistant/components/weather/strings.json +++ b/homeassistant/components/weather/strings.json @@ -62,5 +62,11 @@ } } } + }, + "issues": { + "platform_integration_no_support": { + "title": "[%key:common::issues::platform_integration_no_support_title%]", + "description": "[%key:common::issues::platform_integration_no_support_description%]" + } } } diff --git a/homeassistant/helpers/entity_platform.py b/homeassistant/helpers/entity_platform.py index 52d436ca997..f7793a4329c 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -44,6 +44,7 @@ from . import ( from .device_registry import DeviceRegistry from .entity_registry import EntityRegistry, RegistryEntryDisabler, RegistryEntryHider from .event import async_call_later, async_track_time_interval +from .issue_registry import IssueSeverity, async_create_issue from .typing import ConfigType, DiscoveryInfoType if TYPE_CHECKING: @@ -211,6 +212,19 @@ class EntityPlatform: self.platform_name, self.domain, ) + async_create_issue( + self.hass, + self.domain, + f"platform_integration_no_support_{self.domain}_{self.platform_name}", + is_fixable=False, + severity=IssueSeverity.ERROR, + translation_key="platform_integration_no_support", + translation_placeholders={ + "domain": self.domain, + "platform": self.platform_name, + }, + ) + return @callback diff --git a/homeassistant/strings.json b/homeassistant/strings.json index c4cf0593aae..4da9c25ca10 100644 --- a/homeassistant/strings.json +++ b/homeassistant/strings.json @@ -87,6 +87,10 @@ "unknown_authorize_url_generation": "Unknown error generating an authorize URL.", "cloud_not_connected": "Not connected to Home Assistant Cloud." } + }, + "issues": { + "platform_integration_no_support_title": "Platform support not supported", + "platform_integration_no_support_description": "The {platform} platform for the {domain} integration does not support platform setup.\n\nPlease remove it from your configuration and restart Home Assistant to fix this issue." } } } diff --git a/tests/helpers/test_entity_platform.py b/tests/helpers/test_entity_platform.py index 346a124424e..dd39f664f7a 100644 --- a/tests/helpers/test_entity_platform.py +++ b/tests/helpers/test_entity_platform.py @@ -14,6 +14,7 @@ from homeassistant.helpers import ( device_registry as dr, entity_platform, entity_registry as er, + issue_registry as ir, ) from homeassistant.helpers.entity import ( DeviceInfo, @@ -1458,7 +1459,9 @@ async def test_override_restored_entities( async def test_platform_with_no_setup( - hass: HomeAssistant, caplog: pytest.LogCaptureFixture + hass: HomeAssistant, + caplog: pytest.LogCaptureFixture, + issue_registry: ir.IssueRegistry, ) -> None: """Test setting up a platform that does not support setup.""" entity_platform = MockEntityPlatform( @@ -1471,6 +1474,12 @@ async def test_platform_with_no_setup( "The mock-platform platform for the mock-integration integration does not support platform setup." in caplog.text ) + issue = issue_registry.async_get_issue( + domain="mock-integration", + issue_id="platform_integration_no_support_mock-integration_mock-platform", + ) + assert issue + assert issue.translation_key == "platform_integration_no_support" async def test_platforms_sharing_services(hass: HomeAssistant) -> None: