Remove YAML support from gogogate2/ismartgate (#50312)
parent
29cd5f20b9
commit
2bff7f8020
|
@ -6,7 +6,7 @@ from ismartgate.common import AbstractInfoResponse, ApiError
|
|||
from ismartgate.const import GogoGate2ApiErrorCode, ISmartGateApiErrorCode
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigFlow
|
||||
from homeassistant.config_entries import ConfigFlow
|
||||
from homeassistant.const import (
|
||||
CONF_DEVICE,
|
||||
CONF_IP_ADDRESS,
|
||||
|
@ -28,12 +28,6 @@ class Gogogate2FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
self._ip_address = None
|
||||
self._device_type = None
|
||||
|
||||
async def async_step_import(self, config_data: dict = None):
|
||||
"""Handle importing of configuration."""
|
||||
result = await self.async_step_user(config_data)
|
||||
self._abort_if_unique_id_configured()
|
||||
return result
|
||||
|
||||
async def async_step_homekit(self, discovery_info):
|
||||
"""Handle homekit discovery."""
|
||||
await self.async_set_unique_id(discovery_info["properties"]["id"])
|
||||
|
@ -91,9 +85,6 @@ class Gogogate2FlowHandler(ConfigFlow, domain=DOMAIN):
|
|||
except Exception: # pylint: disable=broad-except
|
||||
errors["base"] = "cannot_connect"
|
||||
|
||||
if errors and self.source == SOURCE_IMPORT:
|
||||
return self.async_abort(reason="cannot_connect")
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=vol.Schema(
|
||||
|
|
|
@ -17,7 +17,7 @@ from homeassistant.components.cover import (
|
|||
SUPPORT_OPEN,
|
||||
CoverEntity,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
|
@ -27,29 +27,10 @@ from .common import (
|
|||
cover_unique_id,
|
||||
get_data_update_coordinator,
|
||||
)
|
||||
from .const import DOMAIN
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass: HomeAssistant,
|
||||
config: dict,
|
||||
add_entities: AddEntitiesCallback,
|
||||
discovery_info=None,
|
||||
) -> None:
|
||||
"""Convert old style file configs to new style configs."""
|
||||
_LOGGER.warning(
|
||||
"Loading gogogate2 via platform config is deprecated; The configuration"
|
||||
" has been migrated to a config entry and can be safely removed"
|
||||
)
|
||||
hass.async_create_task(
|
||||
hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_IMPORT}, data=config
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
async def async_setup_entry(
|
||||
hass: HomeAssistant,
|
||||
config_entry: ConfigEntry,
|
||||
|
|
|
@ -4,7 +4,6 @@ from unittest.mock import MagicMock, patch
|
|||
|
||||
from ismartgate import GogoGate2Api, ISmartGateApi
|
||||
from ismartgate.common import (
|
||||
ApiError,
|
||||
DoorMode,
|
||||
DoorStatus,
|
||||
GogoGate2ActivateResponse,
|
||||
|
@ -31,18 +30,12 @@ from homeassistant.components.gogogate2.const import (
|
|||
DOMAIN,
|
||||
MANUFACTURER,
|
||||
)
|
||||
from homeassistant.components.homeassistant import DOMAIN as HA_DOMAIN
|
||||
from homeassistant.config import async_process_ha_core_config
|
||||
from homeassistant.config_entries import SOURCE_USER
|
||||
from homeassistant.const import (
|
||||
ATTR_DEVICE_CLASS,
|
||||
CONF_DEVICE,
|
||||
CONF_IP_ADDRESS,
|
||||
CONF_NAME,
|
||||
CONF_PASSWORD,
|
||||
CONF_PLATFORM,
|
||||
CONF_UNIT_SYSTEM,
|
||||
CONF_UNIT_SYSTEM_METRIC,
|
||||
CONF_USERNAME,
|
||||
STATE_CLOSED,
|
||||
STATE_CLOSING,
|
||||
|
@ -52,7 +45,6 @@ from homeassistant.const import (
|
|||
STATE_UNKNOWN,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.util.dt import utcnow
|
||||
|
||||
from tests.common import MockConfigEntry, async_fire_time_changed, mock_device_registry
|
||||
|
@ -184,85 +176,6 @@ def _mocked_ismartgate_closed_door_response():
|
|||
)
|
||||
|
||||
|
||||
@patch("homeassistant.components.gogogate2.common.GogoGate2Api")
|
||||
async def test_import_fail(gogogate2api_mock, hass: HomeAssistant) -> None:
|
||||
"""Test the failure to import."""
|
||||
api = MagicMock(spec=GogoGate2Api)
|
||||
api.async_info.side_effect = ApiError(22, "Error")
|
||||
gogogate2api_mock.return_value = api
|
||||
|
||||
hass_config = {
|
||||
HA_DOMAIN: {CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_METRIC},
|
||||
COVER_DOMAIN: [
|
||||
{
|
||||
CONF_PLATFORM: "gogogate2",
|
||||
CONF_NAME: "cover0",
|
||||
CONF_DEVICE: DEVICE_TYPE_GOGOGATE2,
|
||||
CONF_IP_ADDRESS: "127.0.1.0",
|
||||
CONF_USERNAME: "user0",
|
||||
CONF_PASSWORD: "password0",
|
||||
}
|
||||
],
|
||||
}
|
||||
|
||||
await async_process_ha_core_config(hass, hass_config[HA_DOMAIN])
|
||||
assert await async_setup_component(hass, HA_DOMAIN, {})
|
||||
assert await async_setup_component(hass, COVER_DOMAIN, hass_config)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entity_ids = hass.states.async_entity_ids(COVER_DOMAIN)
|
||||
assert not entity_ids
|
||||
|
||||
|
||||
@patch("homeassistant.components.gogogate2.common.GogoGate2Api")
|
||||
@patch("homeassistant.components.gogogate2.common.ISmartGateApi")
|
||||
async def test_import(
|
||||
ismartgateapi_mock, gogogate2api_mock, hass: HomeAssistant
|
||||
) -> None:
|
||||
"""Test importing of file based config."""
|
||||
api0 = MagicMock(spec=GogoGate2Api)
|
||||
api0.async_info.return_value = _mocked_gogogate_open_door_response()
|
||||
gogogate2api_mock.return_value = api0
|
||||
|
||||
api1 = MagicMock(spec=ISmartGateApi)
|
||||
api1.async_info.return_value = _mocked_ismartgate_closed_door_response()
|
||||
ismartgateapi_mock.return_value = api1
|
||||
|
||||
hass_config = {
|
||||
HA_DOMAIN: {CONF_UNIT_SYSTEM: CONF_UNIT_SYSTEM_METRIC},
|
||||
COVER_DOMAIN: [
|
||||
{
|
||||
CONF_PLATFORM: "gogogate2",
|
||||
CONF_NAME: "cover0",
|
||||
CONF_DEVICE: DEVICE_TYPE_GOGOGATE2,
|
||||
CONF_IP_ADDRESS: "127.0.1.0",
|
||||
CONF_USERNAME: "user0",
|
||||
CONF_PASSWORD: "password0",
|
||||
},
|
||||
{
|
||||
CONF_PLATFORM: "gogogate2",
|
||||
CONF_NAME: "cover1",
|
||||
CONF_DEVICE: DEVICE_TYPE_ISMARTGATE,
|
||||
CONF_IP_ADDRESS: "127.0.1.1",
|
||||
CONF_USERNAME: "user1",
|
||||
CONF_PASSWORD: "password1",
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
await async_process_ha_core_config(hass, hass_config[HA_DOMAIN])
|
||||
assert await async_setup_component(hass, HA_DOMAIN, {})
|
||||
assert await async_setup_component(hass, COVER_DOMAIN, hass_config)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
entity_ids = hass.states.async_entity_ids(COVER_DOMAIN)
|
||||
assert entity_ids is not None
|
||||
assert len(entity_ids) == 3
|
||||
assert "cover.door1" in entity_ids
|
||||
assert "cover.door1_2" in entity_ids
|
||||
assert "cover.door2" in entity_ids
|
||||
|
||||
|
||||
@patch("homeassistant.components.gogogate2.common.GogoGate2Api")
|
||||
async def test_open_close_update(gogogate2api_mock, hass: HomeAssistant) -> None:
|
||||
"""Test open and close and data update."""
|
||||
|
|
Loading…
Reference in New Issue