Allow only single instance of energyzero integration (#133443)

This commit is contained in:
Klaas Schoute 2024-12-17 20:44:24 +01:00 committed by GitHub
parent 5e5bebd7eb
commit c9ca1f63ea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 3 deletions

View File

@ -4,6 +4,8 @@
"codeowners": ["@klaasnicolaas"],
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/energyzero",
"integration_type": "service",
"iot_class": "cloud_polling",
"requirements": ["energyzero==2.1.1"]
"requirements": ["energyzero==2.1.1"],
"single_config_entry": true
}

View File

@ -1653,9 +1653,10 @@
},
"energyzero": {
"name": "EnergyZero",
"integration_type": "hub",
"integration_type": "service",
"config_flow": true,
"iot_class": "cloud_polling"
"iot_class": "cloud_polling",
"single_config_entry": true
},
"enigma2": {
"name": "Enigma2 (OpenWebif)",

View File

@ -9,6 +9,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,
@ -33,3 +35,18 @@ async def test_full_user_flow(
assert result2 == snapshot
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"