diff --git a/homeassistant/components/proxmoxve/common.py b/homeassistant/components/proxmoxve/common.py index 32131808af7c..73dee442372a 100644 --- a/homeassistant/components/proxmoxve/common.py +++ b/homeassistant/components/proxmoxve/common.py @@ -3,7 +3,7 @@ from collections.abc import Mapping from typing import Any -from homeassistant.const import CONF_USERNAME +from homeassistant.const import CONF_TOKEN, CONF_USERNAME from .const import AUTH_OTHER, CONF_AUTH_METHOD, CONF_REALM, CONF_TOKEN_ID @@ -21,7 +21,7 @@ def sanitize_config_entry(input_data: Mapping[str, Any]) -> dict[str, Any]: data[CONF_REALM] = realm data[CONF_USERNAME] = f"{username}@{realm}" - if CONF_TOKEN_ID in data and "!" in data[CONF_TOKEN_ID]: + if data.get(CONF_TOKEN) and data.get(CONF_TOKEN_ID) and "!" in data[CONF_TOKEN_ID]: data[CONF_TOKEN_ID] = data[CONF_TOKEN_ID].split("!")[1] return data diff --git a/tests/components/proxmoxve/test_config_flow.py b/tests/components/proxmoxve/test_config_flow.py index a11c6637e571..3a6abc4c64ed 100644 --- a/tests/components/proxmoxve/test_config_flow.py +++ b/tests/components/proxmoxve/test_config_flow.py @@ -496,6 +496,11 @@ def sanitize_config_entry(data: dict[str, Any]) -> dict[str, Any]: MOCK_USER_AUTH_STEP_OTHER_TOKEN, MOCK_TEST_TOKEN_OTHER_CONFIG, ), + ( + MOCK_USER_STEP_TOKEN, + MOCK_USER_AUTH_STEP_TOKEN_FULL_ID, + MOCK_TEST_TOKEN_CONFIG, + ), ], ) @pytest.mark.usefixtures("mock_setup_entry")