From bf0cf1c30ffc4699b0f6f787cb49d39b56cfafc0 Mon Sep 17 00:00:00 2001 From: G Johansson <goran.johansson@shiftit.se> Date: Mon, 6 Jan 2025 04:17:08 +0100 Subject: [PATCH] Set single_config_entry in System monitor manifest (#134838) --- homeassistant/components/systemmonitor/config_flow.py | 11 ----------- homeassistant/components/systemmonitor/manifest.json | 3 ++- homeassistant/components/systemmonitor/strings.json | 2 +- homeassistant/generated/integrations.json | 3 ++- tests/components/systemmonitor/test_config_flow.py | 10 +--------- 5 files changed, 6 insertions(+), 23 deletions(-) diff --git a/homeassistant/components/systemmonitor/config_flow.py b/homeassistant/components/systemmonitor/config_flow.py index 34b28a1d47a..4be31f6944c 100644 --- a/homeassistant/components/systemmonitor/config_flow.py +++ b/homeassistant/components/systemmonitor/config_flow.py @@ -8,8 +8,6 @@ from typing import Any import voluptuous as vol from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN -from homeassistant.config_entries import ConfigFlowResult -from homeassistant.core import callback from homeassistant.helpers import entity_registry as er from homeassistant.helpers.schema_config_entry_flow import ( SchemaCommonFlowHandler, @@ -100,12 +98,3 @@ class SystemMonitorConfigFlowHandler(SchemaConfigFlowHandler, domain=DOMAIN): def async_config_entry_title(self, options: Mapping[str, Any]) -> str: """Return config entry title.""" return "System Monitor" - - @callback - def async_create_entry( - self, data: Mapping[str, Any], **kwargs: Any - ) -> ConfigFlowResult: - """Finish config flow and create a config entry.""" - if self._async_current_entries(): - return self.async_abort(reason="already_configured") - return super().async_create_entry(data, **kwargs) diff --git a/homeassistant/components/systemmonitor/manifest.json b/homeassistant/components/systemmonitor/manifest.json index 21b9798ef46..bd16464b290 100644 --- a/homeassistant/components/systemmonitor/manifest.json +++ b/homeassistant/components/systemmonitor/manifest.json @@ -6,5 +6,6 @@ "documentation": "https://www.home-assistant.io/integrations/systemmonitor", "iot_class": "local_push", "loggers": ["psutil"], - "requirements": ["psutil-home-assistant==0.0.1", "psutil==6.1.1"] + "requirements": ["psutil-home-assistant==0.0.1", "psutil==6.1.1"], + "single_config_entry": true } diff --git a/homeassistant/components/systemmonitor/strings.json b/homeassistant/components/systemmonitor/strings.json index e595e628853..fb8a318ff45 100644 --- a/homeassistant/components/systemmonitor/strings.json +++ b/homeassistant/components/systemmonitor/strings.json @@ -1,7 +1,7 @@ { "config": { "abort": { - "already_configured": "[%key:common::config_flow::abort::already_configured_service%]" + "single_instance_allowed": "[%key:common::config_flow::abort::already_configured_service%]" }, "step": { "user": { diff --git a/homeassistant/generated/integrations.json b/homeassistant/generated/integrations.json index 96ca8a9f766..9b58587543d 100644 --- a/homeassistant/generated/integrations.json +++ b/homeassistant/generated/integrations.json @@ -6183,7 +6183,8 @@ "name": "System Monitor", "integration_type": "hub", "config_flow": true, - "iot_class": "local_push" + "iot_class": "local_push", + "single_config_entry": true }, "tado": { "name": "Tado", diff --git a/tests/components/systemmonitor/test_config_flow.py b/tests/components/systemmonitor/test_config_flow.py index f5cc46da096..60a70da27a2 100644 --- a/tests/components/systemmonitor/test_config_flow.py +++ b/tests/components/systemmonitor/test_config_flow.py @@ -48,17 +48,9 @@ async def test_form_already_configured( result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} ) - assert result["step_id"] == "user" - assert result["type"] is FlowResultType.FORM - - result = await hass.config_entries.flow.async_configure( - result["flow_id"], - {}, - ) - await hass.async_block_till_done() assert result["type"] is FlowResultType.ABORT - assert result["reason"] == "already_configured" + assert result["reason"] == "single_instance_allowed" async def test_add_and_remove_processes( -- GitLab