Add single config entry to Mullvad (#114426)

* Add single config entry to Mullvad

* Add single config entry to Mullvad

* Add single config entry to Mullvad

* Fix
This commit is contained in:
Joost Lekkerkerker 2024-03-29 11:04:37 +01:00 committed by GitHub
parent 247ee6e4f0
commit ed7e5c4de6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 10 additions and 9 deletions

View File

@ -1,5 +1,7 @@
"""Config flow for Mullvad VPN integration."""
from typing import Any
from mullvad_api import MullvadAPI, MullvadAPIError
from homeassistant.config_entries import ConfigFlow, ConfigFlowResult
@ -12,10 +14,10 @@ class MullvadConfigFlow(ConfigFlow, domain=DOMAIN):
VERSION = 1
async def async_step_user(self, user_input=None) -> ConfigFlowResult:
async def async_step_user(
self, user_input: dict[str, Any] | None = None
) -> ConfigFlowResult:
"""Handle the initial step."""
self._async_abort_entries_match()
errors = {}
if user_input is not None:
try:

View File

@ -5,5 +5,6 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/mullvad",
"iot_class": "cloud_polling",
"requirements": ["mullvad-api==1.0.0"]
"requirements": ["mullvad-api==1.0.0"],
"single_config_entry": true
}

View File

@ -1,8 +1,5 @@
{
"config": {
"abort": {
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
},
"error": {
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]",
"unknown": "[%key:common::config_flow::error::unknown%]"

View File

@ -3815,7 +3815,8 @@
"name": "Mullvad VPN",
"integration_type": "hub",
"config_flow": true,
"iot_class": "cloud_polling"
"iot_class": "cloud_polling",
"single_config_entry": true
},
"mutesync": {
"name": "mutesync",

View File

@ -51,7 +51,7 @@ async def test_form_user_only_once(hass: HomeAssistant) -> None:
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == FlowResultType.ABORT
assert result["reason"] == "already_configured"
assert result["reason"] == "single_instance_allowed"
async def test_connection_error(hass: HomeAssistant) -> None: