Allow legacy nest integration with no configuration.yaml (#74222)

This commit is contained in:
Allen Porter 2022-06-29 23:54:51 -07:00 committed by GitHub
parent 48c5aab5ee
commit 0cf922cc4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 3 deletions

View File

@ -177,7 +177,7 @@ class SignalUpdateCallback:
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up Nest from a config entry with dispatch between old/new flows."""
config_mode = config_flow.get_config_mode(hass)
if config_mode == config_flow.ConfigMode.LEGACY:
if DATA_SDM not in entry.data or config_mode == config_flow.ConfigMode.LEGACY:
return await async_setup_legacy_entry(hass, entry)
if config_mode == config_flow.ConfigMode.SDM:

View File

@ -147,7 +147,17 @@ TEST_CONFIG_LEGACY = NestTestConfig(
},
},
},
credential=None,
)
TEST_CONFIG_ENTRY_LEGACY = NestTestConfig(
config_entry_data={
"auth_implementation": "local",
"tokens": {
"expires_at": time.time() + 86400,
"access_token": {
"token": "some-token",
},
},
},
)

View File

@ -4,7 +4,7 @@ from unittest.mock import MagicMock, PropertyMock, patch
import pytest
from .common import TEST_CONFIG_LEGACY
from .common import TEST_CONFIG_ENTRY_LEGACY, TEST_CONFIG_LEGACY
DOMAIN = "nest"
@ -33,6 +33,9 @@ def make_thermostat():
return device
@pytest.mark.parametrize(
"nest_test_config", [TEST_CONFIG_LEGACY, TEST_CONFIG_ENTRY_LEGACY]
)
async def test_thermostat(hass, setup_base_platform):
"""Test simple initialization for thermostat entities."""