mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 11:47:06 +00:00
Remove deprecated YAML configuration from Yale Smart Alarm (#69025)
This commit is contained in:
parent
af6953157f
commit
a9a14d6544
@ -3,70 +3,28 @@ from __future__ import annotations
|
|||||||
|
|
||||||
from typing import TYPE_CHECKING
|
from typing import TYPE_CHECKING
|
||||||
|
|
||||||
import voluptuous as vol
|
|
||||||
from yalesmartalarmclient.const import (
|
from yalesmartalarmclient.const import (
|
||||||
YALE_STATE_ARM_FULL,
|
YALE_STATE_ARM_FULL,
|
||||||
YALE_STATE_ARM_PARTIAL,
|
YALE_STATE_ARM_PARTIAL,
|
||||||
YALE_STATE_DISARM,
|
YALE_STATE_DISARM,
|
||||||
)
|
)
|
||||||
|
|
||||||
from homeassistant.components.alarm_control_panel import (
|
from homeassistant.components.alarm_control_panel import AlarmControlPanelEntity
|
||||||
PLATFORM_SCHEMA as PARENT_PLATFORM_SCHEMA,
|
|
||||||
AlarmControlPanelEntity,
|
|
||||||
)
|
|
||||||
from homeassistant.components.alarm_control_panel.const import (
|
from homeassistant.components.alarm_control_panel.const import (
|
||||||
SUPPORT_ALARM_ARM_AWAY,
|
SUPPORT_ALARM_ARM_AWAY,
|
||||||
SUPPORT_ALARM_ARM_HOME,
|
SUPPORT_ALARM_ARM_HOME,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import CONF_NAME, CONF_PASSWORD, CONF_USERNAME
|
from homeassistant.const import CONF_NAME
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
import homeassistant.helpers.config_validation as cv
|
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, StateType
|
from homeassistant.helpers.typing import StateType
|
||||||
|
|
||||||
from .const import (
|
from .const import COORDINATOR, DOMAIN, STATE_MAP, YALE_ALL_ERRORS
|
||||||
CONF_AREA_ID,
|
|
||||||
COORDINATOR,
|
|
||||||
DEFAULT_AREA_ID,
|
|
||||||
DEFAULT_NAME,
|
|
||||||
DOMAIN,
|
|
||||||
LOGGER,
|
|
||||||
STATE_MAP,
|
|
||||||
YALE_ALL_ERRORS,
|
|
||||||
)
|
|
||||||
from .coordinator import YaleDataUpdateCoordinator
|
from .coordinator import YaleDataUpdateCoordinator
|
||||||
from .entity import YaleAlarmEntity
|
from .entity import YaleAlarmEntity
|
||||||
|
|
||||||
PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
|
|
||||||
{
|
|
||||||
vol.Required(CONF_USERNAME): cv.string,
|
|
||||||
vol.Required(CONF_PASSWORD): cv.string,
|
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
|
||||||
vol.Optional(CONF_AREA_ID, default=DEFAULT_AREA_ID): cv.string,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_platform(
|
|
||||||
hass: HomeAssistant,
|
|
||||||
config: ConfigType,
|
|
||||||
async_add_entities: AddEntitiesCallback,
|
|
||||||
discovery_info: DiscoveryInfoType | None = None,
|
|
||||||
) -> None:
|
|
||||||
"""Import Yale configuration from YAML."""
|
|
||||||
LOGGER.warning(
|
|
||||||
"Loading Yale Alarm via platform setup is deprecated; Please remove it from your configuration"
|
|
||||||
)
|
|
||||||
hass.async_create_task(
|
|
||||||
hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": SOURCE_IMPORT},
|
|
||||||
data=config,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
|
||||||
|
@ -53,11 +53,6 @@ class YaleConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
"""Get the options flow for this handler."""
|
"""Get the options flow for this handler."""
|
||||||
return YaleOptionsFlowHandler(config_entry)
|
return YaleOptionsFlowHandler(config_entry)
|
||||||
|
|
||||||
async def async_step_import(self, config: dict[str, Any]) -> FlowResult:
|
|
||||||
"""Import a configuration from config.yaml."""
|
|
||||||
|
|
||||||
return await self.async_step_user(user_input=config)
|
|
||||||
|
|
||||||
async def async_step_reauth(
|
async def async_step_reauth(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
) -> FlowResult:
|
) -> FlowResult:
|
||||||
|
@ -114,60 +114,6 @@ async def test_form_invalid_auth(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
"p_input,p_output",
|
|
||||||
[
|
|
||||||
(
|
|
||||||
{
|
|
||||||
"username": "test-username",
|
|
||||||
"password": "test-password",
|
|
||||||
"area_id": "1",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"username": "test-username",
|
|
||||||
"password": "test-password",
|
|
||||||
"name": "Yale Smart Alarm",
|
|
||||||
"area_id": "1",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
(
|
|
||||||
{
|
|
||||||
"username": "test-username",
|
|
||||||
"password": "test-password",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"username": "test-username",
|
|
||||||
"password": "test-password",
|
|
||||||
"name": "Yale Smart Alarm",
|
|
||||||
"area_id": "1",
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
async def test_import_flow_success(
|
|
||||||
hass, p_input: dict[str, str], p_output: dict[str, str]
|
|
||||||
):
|
|
||||||
"""Test a successful import of yaml."""
|
|
||||||
|
|
||||||
with patch(
|
|
||||||
"homeassistant.components.yale_smart_alarm.config_flow.YaleSmartAlarmClient",
|
|
||||||
), patch(
|
|
||||||
"homeassistant.components.yale_smart_alarm.async_setup_entry",
|
|
||||||
return_value=True,
|
|
||||||
) as mock_setup_entry:
|
|
||||||
result2 = await hass.config_entries.flow.async_init(
|
|
||||||
DOMAIN,
|
|
||||||
context={"source": config_entries.SOURCE_IMPORT},
|
|
||||||
data=p_input,
|
|
||||||
)
|
|
||||||
await hass.async_block_till_done()
|
|
||||||
|
|
||||||
assert result2["type"] == "create_entry"
|
|
||||||
assert result2["title"] == "test-username"
|
|
||||||
assert result2["data"] == p_output
|
|
||||||
assert len(mock_setup_entry.mock_calls) == 1
|
|
||||||
|
|
||||||
|
|
||||||
async def test_reauth_flow(hass: HomeAssistant) -> None:
|
async def test_reauth_flow(hass: HomeAssistant) -> None:
|
||||||
"""Test a reauthentication flow."""
|
"""Test a reauthentication flow."""
|
||||||
entry = MockConfigEntry(
|
entry = MockConfigEntry(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user