New configuration flow for ZHA integration (#35161)

* Start gateway using new zigpy init.

Update config entry data  import.
Use new zigpy startup.
Fix config entry import without zha config section.
Auto form Zigbee network.

* Migrate config entry.

* New ZHA config entry flow.

Use lightweight probe() method for ZHA config entry validation when
available. Failback to old behavior of setting up Zigpy app if radio lib
does not provide probing.

* Clean ZHA_GW_RADIO

* Don't import ZHA device settings.

* Update config flow tests.

* Filter out empty manufacturer.

* Replace port path with an by-id device name.

* Rebase cleanup

* Use correct mock.

* Make lint happy again

* Update tests/components/zha/test_config_flow.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update tests/components/zha/test_config_flow.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update tests/components/zha/test_config_flow.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Use executor pool for IO

* Address comments.

Use AsyncMock from tests.

* Use core interface to test config flow.

* Use core interface to test config_flow.

* Address comments. Use core interface.

* Update ZHA dependencies.

* Schema guard

* Use async_update_entry for migration.

* Don't allow schema extra keys.

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
Alexei ChetroiandMartin Hjelmare authored and GitHub committed 2020-05-06 12:23:53 +02:00
1 parent 2581b031d9
commit c71a7b901f
14 files changed
+527 -249

No files matched your search

+8 -5
View File
@@ -4,6 +4,7 @@ from unittest import mock
import pytest
import zigpy
from zigpy.application import ControllerApplication
import zigpy.config
import zigpy.group
import zigpy.types
@@ -49,12 +50,11 @@ def zigpy_radio():
async def config_entry_fixture(hass):
"""Fixture representing a config entry."""
entry = MockConfigEntry(
version=1,
version=2,
domain=zha_const.DOMAIN,
data={
zha_const.CONF_BAUDRATE: zha_const.DEFAULT_BAUDRATE,
zigpy.config.CONF_DEVICE: {zigpy.config.CONF_DEVICE_PATH: "/dev/ttyUSB0"},
zha_const.CONF_RADIO_TYPE: "MockRadio",
zha_const.CONF_USB_PATH: "/dev/ttyUSB0",
},
)
entry.add_to_hass(hass)
@@ -65,10 +65,13 @@ async def config_entry_fixture(hass):
def setup_zha(hass, config_entry, zigpy_app_controller, zigpy_radio):
"""Set up ZHA component."""
zha_config = {zha_const.CONF_ENABLE_QUIRKS: False}
app_ctrl = mock.MagicMock()
app_ctrl.new = tests.async_mock.AsyncMock(return_value=zigpy_app_controller)
app_ctrl.SCHEMA = zigpy.config.CONFIG_SCHEMA
app_ctrl.SCHEMA_DEVICE = zigpy.config.SCHEMA_DEVICE
radio_details = {
zha_const.ZHA_GW_RADIO: mock.MagicMock(return_value=zigpy_radio),
zha_const.CONTROLLER: mock.MagicMock(return_value=zigpy_app_controller),
zha_const.CONTROLLER: app_ctrl,
zha_const.ZHA_GW_RADIO_DESCRIPTION: "mock radio",
}