From 86a397720f6c1e90bd3ce2cdde64d8d06e3e3402 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Fri, 7 Jul 2023 13:31:54 +0200 Subject: [PATCH] Move platform_integration_no_support issue to the homeassistant integration (#95927) * Move platform_integration_no_support issue to the homeassistant integration * Update test * Improve repair text * Update test --- .../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 ------ .../components/homeassistant/strings.json | 4 ++++ homeassistant/components/humidifier/strings.json | 6 ------ homeassistant/components/light/strings.json | 6 ------ homeassistant/components/lock/strings.json | 6 ------ .../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 ------ .../components/water_heater/strings.json | 6 ------ homeassistant/components/weather/strings.json | 6 ------ homeassistant/helpers/entity_platform.py | 16 ++++++++++++++-- homeassistant/strings.json | 4 ---- tests/helpers/test_entity_platform.py | 12 ++++++++++-- 30 files changed, 28 insertions(+), 164 deletions(-) diff --git a/homeassistant/components/alarm_control_panel/strings.json b/homeassistant/components/alarm_control_panel/strings.json index 4025bbd4cc4..6b01cab2bec 100644 --- a/homeassistant/components/alarm_control_panel/strings.json +++ b/homeassistant/components/alarm_control_panel/strings.json @@ -62,11 +62,5 @@ } } } - }, - "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 b9c9b19a93c..ee70420fec0 100644 --- a/homeassistant/components/binary_sensor/strings.json +++ b/homeassistant/components/binary_sensor/strings.json @@ -314,11 +314,5 @@ "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 006959d1b4c..a92a5a0f38a 100644 --- a/homeassistant/components/button/strings.json +++ b/homeassistant/components/button/strings.json @@ -21,11 +21,5 @@ "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 b28f741c381..898953c18ac 100644 --- a/homeassistant/components/calendar/strings.json +++ b/homeassistant/components/calendar/strings.json @@ -32,11 +32,5 @@ } } } - }, - "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 f67097516b4..0722ec1c5e6 100644 --- a/homeassistant/components/camera/strings.json +++ b/homeassistant/components/camera/strings.json @@ -34,11 +34,5 @@ } } } - }, - "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 5879c44db83..8034799a6d0 100644 --- a/homeassistant/components/climate/strings.json +++ b/homeassistant/components/climate/strings.json @@ -104,11 +104,5 @@ "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 663df02a824..2f61bd95083 100644 --- a/homeassistant/components/cover/strings.json +++ b/homeassistant/components/cover/strings.json @@ -76,11 +76,5 @@ "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 f2d2e5ef8e1..110a4cabb92 100644 --- a/homeassistant/components/date/strings.json +++ b/homeassistant/components/date/strings.json @@ -4,11 +4,5 @@ "_": { "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 54e4f922053..c15b9723c97 100644 --- a/homeassistant/components/device_tracker/strings.json +++ b/homeassistant/components/device_tracker/strings.json @@ -41,11 +41,5 @@ } } } - }, - "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 b69068d3d64..b16d6da6df5 100644 --- a/homeassistant/components/fan/strings.json +++ b/homeassistant/components/fan/strings.json @@ -52,11 +52,5 @@ } } } - }, - "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/homeassistant/strings.json b/homeassistant/components/homeassistant/strings.json index 0a41f9c7a99..edb26c3622e 100644 --- a/homeassistant/components/homeassistant/strings.json +++ b/homeassistant/components/homeassistant/strings.json @@ -19,6 +19,10 @@ "platform_only": { "title": "The {domain} integration does not support YAML configuration under its own key", "description": "The {domain} integration does not support configuration under its own key, it must be configured under its supported platforms.\n\nTo resolve this:\n\n1. Remove `{domain}:` from your YAML configuration file.\n\n2. Restart Home Assistant." + }, + "no_platform_setup": { + "title": "Unused YAML configuration for the {platform} integration", + "description": "It's not possible to configure {platform} {domain} by adding `{platform_key}` to the {domain} configuration. Please check the documentation for more information on how to set up this integration.\n\nTo resolve this:\n1. Remove `{platform_key}` occurences from the `{domain}:` configuration in your YAML configuration file.\n2. Restart Home Assistant.\n\nExample that should be removed:\n{yaml_example}\n" } }, "system_health": { diff --git a/homeassistant/components/humidifier/strings.json b/homeassistant/components/humidifier/strings.json index 7a2e371024f..f06bf7ccd59 100644 --- a/homeassistant/components/humidifier/strings.json +++ b/homeassistant/components/humidifier/strings.json @@ -74,11 +74,5 @@ "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 f89497b5ef9..935e38d33d9 100644 --- a/homeassistant/components/light/strings.json +++ b/homeassistant/components/light/strings.json @@ -86,11 +86,5 @@ } } } - }, - "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 b77bf5e6900..da4b5217b86 100644 --- a/homeassistant/components/lock/strings.json +++ b/homeassistant/components/lock/strings.json @@ -34,11 +34,5 @@ } } } - }, - "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 eed54ef58c3..2c63a543119 100644 --- a/homeassistant/components/media_player/strings.json +++ b/homeassistant/components/media_player/strings.json @@ -159,11 +159,5 @@ "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 9af54311129..46db471305c 100644 --- a/homeassistant/components/number/strings.json +++ b/homeassistant/components/number/strings.json @@ -154,11 +154,5 @@ "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 18a92494242..f0d2787b658 100644 --- a/homeassistant/components/remote/strings.json +++ b/homeassistant/components/remote/strings.json @@ -24,11 +24,5 @@ "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 53441d365b4..9080b940b2a 100644 --- a/homeassistant/components/select/strings.json +++ b/homeassistant/components/select/strings.json @@ -24,11 +24,5 @@ } } } - }, - "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 d3dbbc678b0..c4c1f81109d 100644 --- a/homeassistant/components/sensor/strings.json +++ b/homeassistant/components/sensor/strings.json @@ -267,11 +267,5 @@ "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 c3dde16a99f..60d8843c151 100644 --- a/homeassistant/components/siren/strings.json +++ b/homeassistant/components/siren/strings.json @@ -13,11 +13,5 @@ } } } - }, - "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 2bb6c82a8c1..a7934ba4209 100644 --- a/homeassistant/components/switch/strings.json +++ b/homeassistant/components/switch/strings.json @@ -30,11 +30,5 @@ "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 d8f55dbe4e7..034f1ab315b 100644 --- a/homeassistant/components/text/strings.json +++ b/homeassistant/components/text/strings.json @@ -27,11 +27,5 @@ } } } - }, - "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 9cbcf718d73..e8d92a30e2e 100644 --- a/homeassistant/components/time/strings.json +++ b/homeassistant/components/time/strings.json @@ -4,11 +4,5 @@ "_": { "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 518b8605aa7..b69e0acf65e 100644 --- a/homeassistant/components/update/strings.json +++ b/homeassistant/components/update/strings.json @@ -14,11 +14,5 @@ "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 e0db3ba4e47..a27a60bba4f 100644 --- a/homeassistant/components/vacuum/strings.json +++ b/homeassistant/components/vacuum/strings.json @@ -28,11 +28,5 @@ "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 b0784279667..6344b5a847a 100644 --- a/homeassistant/components/water_heater/strings.json +++ b/homeassistant/components/water_heater/strings.json @@ -18,11 +18,5 @@ "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 53eca9c7f91..26ccd731828 100644 --- a/homeassistant/components/weather/strings.json +++ b/homeassistant/components/weather/strings.json @@ -74,11 +74,5 @@ } } } - }, - "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 66a74edf8f9..55d167ae253 100644 --- a/homeassistant/helpers/entity_platform.py +++ b/homeassistant/helpers/entity_platform.py @@ -19,6 +19,7 @@ from homeassistant.const import ( ) from homeassistant.core import ( CALLBACK_TYPE, + DOMAIN as HOMEASSISTANT_DOMAIN, CoreState, HomeAssistant, ServiceCall, @@ -216,16 +217,27 @@ class EntityPlatform: self.platform_name, self.domain, ) + learn_more_url = None + if self.platform and "custom_components" not in self.platform.__file__: # type: ignore[attr-defined] + learn_more_url = ( + f"https://www.home-assistant.io/integrations/{self.platform_name}/" + ) + platform_key = f"platform: {self.platform_name}" + yaml_example = f"```yaml\n{self.domain}:\n - {platform_key}\n```" async_create_issue( self.hass, - self.domain, + HOMEASSISTANT_DOMAIN, f"platform_integration_no_support_{self.domain}_{self.platform_name}", is_fixable=False, + issue_domain=self.platform_name, + learn_more_url=learn_more_url, severity=IssueSeverity.ERROR, - translation_key="platform_integration_no_support", + translation_key="no_platform_setup", translation_placeholders={ "domain": self.domain, "platform": self.platform_name, + "platform_key": platform_key, + "yaml_example": yaml_example, }, ) diff --git a/homeassistant/strings.json b/homeassistant/strings.json index 4da9c25ca10..c4cf0593aae 100644 --- a/homeassistant/strings.json +++ b/homeassistant/strings.json @@ -87,10 +87,6 @@ "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 df4f4d1c643..711c333c5ff 100644 --- a/tests/helpers/test_entity_platform.py +++ b/tests/helpers/test_entity_platform.py @@ -1477,11 +1477,19 @@ async def test_platform_with_no_setup( in caplog.text ) issue = issue_registry.async_get_issue( - domain="mock-integration", + domain="homeassistant", issue_id="platform_integration_no_support_mock-integration_mock-platform", ) assert issue - assert issue.translation_key == "platform_integration_no_support" + assert issue.issue_domain == "mock-platform" + assert issue.learn_more_url is None + assert issue.translation_key == "no_platform_setup" + assert issue.translation_placeholders == { + "domain": "mock-integration", + "platform": "mock-platform", + "platform_key": "platform: mock-platform", + "yaml_example": "```yaml\nmock-integration:\n - platform: mock-platform\n```", + } async def test_platforms_sharing_services(hass: HomeAssistant) -> None: