mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Remove deprecated yaml config from bmw_connected_drive (#66965)
Co-authored-by: rikroe <rikroe@users.noreply.github.com>
This commit is contained in:
parent
14059c5aa9
commit
a12870081e
@ -11,7 +11,7 @@ from bimmer_connected.vehicle import ConnectedDriveVehicle
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
|
from homeassistant.components.notify import DOMAIN as NOTIFY_DOMAIN
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_DEVICE_ID,
|
CONF_DEVICE_ID,
|
||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
@ -33,7 +33,6 @@ import homeassistant.util.dt as dt_util
|
|||||||
from .const import (
|
from .const import (
|
||||||
ATTRIBUTION,
|
ATTRIBUTION,
|
||||||
CONF_ACCOUNT,
|
CONF_ACCOUNT,
|
||||||
CONF_ALLOWED_REGIONS,
|
|
||||||
CONF_READ_ONLY,
|
CONF_READ_ONLY,
|
||||||
DATA_ENTRIES,
|
DATA_ENTRIES,
|
||||||
DATA_HASS_CONFIG,
|
DATA_HASS_CONFIG,
|
||||||
@ -44,16 +43,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
DOMAIN = "bmw_connected_drive"
|
DOMAIN = "bmw_connected_drive"
|
||||||
ATTR_VIN = "vin"
|
ATTR_VIN = "vin"
|
||||||
|
|
||||||
ACCOUNT_SCHEMA = vol.Schema(
|
CONFIG_SCHEMA = cv.removed(DOMAIN, raise_if_present=False)
|
||||||
{
|
|
||||||
vol.Required(CONF_USERNAME): cv.string,
|
|
||||||
vol.Required(CONF_PASSWORD): cv.string,
|
|
||||||
vol.Required(CONF_REGION): vol.In(CONF_ALLOWED_REGIONS),
|
|
||||||
vol.Optional(CONF_READ_ONLY): cv.boolean,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema({DOMAIN: {cv.string: ACCOUNT_SCHEMA}}, extra=vol.ALLOW_EXTRA)
|
|
||||||
|
|
||||||
SERVICE_SCHEMA = vol.Schema(
|
SERVICE_SCHEMA = vol.Schema(
|
||||||
vol.Any(
|
vol.Any(
|
||||||
@ -91,17 +81,10 @@ UNDO_UPDATE_LISTENER = "undo_update_listener"
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the BMW Connected Drive component from configuration.yaml."""
|
"""Set up the BMW Connected Drive component from configuration.yaml."""
|
||||||
|
# Store full yaml config in data for platform.NOTIFY
|
||||||
hass.data.setdefault(DOMAIN, {})
|
hass.data.setdefault(DOMAIN, {})
|
||||||
hass.data[DOMAIN][DATA_HASS_CONFIG] = config
|
hass.data[DOMAIN][DATA_HASS_CONFIG] = config
|
||||||
|
|
||||||
if DOMAIN in config:
|
|
||||||
for entry_config in config[DOMAIN].values():
|
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=entry_config
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -74,10 +74,6 @@ class BMWConnectedDriveConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||||||
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
step_id="user", data_schema=DATA_SCHEMA, errors=errors
|
||||||
)
|
)
|
||||||
|
|
||||||
async def async_step_import(self, user_input: dict[str, Any]) -> FlowResult:
|
|
||||||
"""Handle import."""
|
|
||||||
return await self.async_step_user(user_input)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@callback
|
@callback
|
||||||
def async_get_options_flow(
|
def async_get_options_flow(
|
||||||
|
@ -12,7 +12,6 @@ ATTR_DIRECTION = "direction"
|
|||||||
|
|
||||||
CONF_ALLOWED_REGIONS = ["china", "north_america", "rest_of_world"]
|
CONF_ALLOWED_REGIONS = ["china", "north_america", "rest_of_world"]
|
||||||
CONF_READ_ONLY = "read_only"
|
CONF_READ_ONLY = "read_only"
|
||||||
CONF_USE_LOCATION = "use_location"
|
|
||||||
|
|
||||||
CONF_ACCOUNT = "account"
|
CONF_ACCOUNT = "account"
|
||||||
|
|
||||||
|
@ -68,8 +68,6 @@ async def test_full_user_flow_implementation(hass):
|
|||||||
"bimmer_connected.account.ConnectedDriveAccount._get_vehicles",
|
"bimmer_connected.account.ConnectedDriveAccount._get_vehicles",
|
||||||
return_value=[],
|
return_value=[],
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.bmw_connected_drive.async_setup", return_value=True
|
|
||||||
) as mock_setup, patch(
|
|
||||||
"homeassistant.components.bmw_connected_drive.async_setup_entry",
|
"homeassistant.components.bmw_connected_drive.async_setup_entry",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
) as mock_setup_entry:
|
) as mock_setup_entry:
|
||||||
@ -82,32 +80,6 @@ async def test_full_user_flow_implementation(hass):
|
|||||||
assert result2["title"] == FIXTURE_COMPLETE_ENTRY[CONF_USERNAME]
|
assert result2["title"] == FIXTURE_COMPLETE_ENTRY[CONF_USERNAME]
|
||||||
assert result2["data"] == FIXTURE_COMPLETE_ENTRY
|
assert result2["data"] == FIXTURE_COMPLETE_ENTRY
|
||||||
|
|
||||||
assert len(mock_setup.mock_calls) == 1
|
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
|
||||||
|
|
||||||
|
|
||||||
async def test_full_config_flow_implementation(hass):
|
|
||||||
"""Test registering an integration and finishing flow works."""
|
|
||||||
with patch(
|
|
||||||
"bimmer_connected.account.ConnectedDriveAccount._get_vehicles",
|
|
||||||
return_value=[],
|
|
||||||
), patch(
|
|
||||||
"homeassistant.components.bmw_connected_drive.async_setup", return_value=True
|
|
||||||
) as mock_setup, patch(
|
|
||||||
"homeassistant.components.bmw_connected_drive.async_setup_entry",
|
|
||||||
return_value=True,
|
|
||||||
) as mock_setup_entry:
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": config_entries.SOURCE_IMPORT},
|
|
||||||
data=FIXTURE_USER_INPUT,
|
|
||||||
)
|
|
||||||
|
|
||||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
|
||||||
assert result["title"] == FIXTURE_IMPORT_ENTRY[CONF_USERNAME]
|
|
||||||
assert result["data"] == FIXTURE_IMPORT_ENTRY
|
|
||||||
|
|
||||||
assert len(mock_setup.mock_calls) == 1
|
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
|
||||||
|
|
||||||
@ -117,8 +89,6 @@ async def test_options_flow_implementation(hass):
|
|||||||
"bimmer_connected.account.ConnectedDriveAccount._get_vehicles",
|
"bimmer_connected.account.ConnectedDriveAccount._get_vehicles",
|
||||||
return_value=[],
|
return_value=[],
|
||||||
), patch(
|
), patch(
|
||||||
"homeassistant.components.bmw_connected_drive.async_setup", return_value=True
|
|
||||||
) as mock_setup, patch(
|
|
||||||
"homeassistant.components.bmw_connected_drive.async_setup_entry",
|
"homeassistant.components.bmw_connected_drive.async_setup_entry",
|
||||||
return_value=True,
|
return_value=True,
|
||||||
) as mock_setup_entry:
|
) as mock_setup_entry:
|
||||||
@ -143,5 +113,4 @@ async def test_options_flow_implementation(hass):
|
|||||||
CONF_READ_ONLY: False,
|
CONF_READ_ONLY: False,
|
||||||
}
|
}
|
||||||
|
|
||||||
assert len(mock_setup.mock_calls) == 1
|
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
assert len(mock_setup_entry.mock_calls) == 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user