From 21c3bf48f93d49703bcdfd73c53136f520b3aca6 Mon Sep 17 00:00:00 2001 From: Klaas Schoute Date: Tue, 17 Dec 2024 21:02:39 +0100 Subject: [PATCH] Allow only single instance of easyenergy integration (#133447) --- .../components/easyenergy/manifest.json | 4 +++- homeassistant/generated/integrations.json | 5 +++-- tests/components/easyenergy/test_config_flow.py | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/easyenergy/manifest.json b/homeassistant/components/easyenergy/manifest.json index 25432196169..5cecb1d49f6 100644 --- a/homeassistant/components/easyenergy/manifest.json +++ b/homeassistant/components/easyenergy/manifest.json @@ -4,6 +4,8 @@ "codeowners": ["@klaasnicolaas"], "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/easyenergy", + "integration_type": "service", "iot_class": "cloud_polling", - "requirements": ["easyenergy==2.1.2"] + "requirements": ["easyenergy==2.1.2"], + "single_config_entry": true } diff --git a/homeassistant/generated/integrations.json b/homeassistant/generated/integrations.json index 7cb7a5a1aef..5fc09fcd70f 100644 --- a/homeassistant/generated/integrations.json +++ b/homeassistant/generated/integrations.json @@ -1441,9 +1441,10 @@ }, "easyenergy": { "name": "easyEnergy", - "integration_type": "hub", + "integration_type": "service", "config_flow": true, - "iot_class": "cloud_polling" + "iot_class": "cloud_polling", + "single_config_entry": true }, "ebox": { "name": "EBox", diff --git a/tests/components/easyenergy/test_config_flow.py b/tests/components/easyenergy/test_config_flow.py index da7048793b3..44bc8421126 100644 --- a/tests/components/easyenergy/test_config_flow.py +++ b/tests/components/easyenergy/test_config_flow.py @@ -7,6 +7,8 @@ from homeassistant.config_entries import SOURCE_USER from homeassistant.core import HomeAssistant from homeassistant.data_entry_flow import FlowResultType +from tests.common import MockConfigEntry + async def test_full_user_flow( hass: HomeAssistant, @@ -31,3 +33,18 @@ async def test_full_user_flow( assert result2.get("data") == {} assert len(mock_setup_entry.mock_calls) == 1 + + +async def test_single_instance( + hass: HomeAssistant, + mock_config_entry: MockConfigEntry, +) -> None: + """Test abort when setting up a duplicate entry.""" + mock_config_entry.add_to_hass(hass) + + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": SOURCE_USER} + ) + + assert result.get("type") is FlowResultType.ABORT + assert result.get("reason") == "single_instance_allowed"