Add get_migration_config to zwave websocket api (#39577)
* Add get_migration_config to zwave websocket api * Add test
This commit is contained in:
parent
7b3182fa8f
commit
5fafaa3c4f
2 changed files with 28 additions and 0 deletions
|
@ -10,6 +10,7 @@ from homeassistant.core import callback
|
||||||
from .const import (
|
from .const import (
|
||||||
CONF_AUTOHEAL,
|
CONF_AUTOHEAL,
|
||||||
CONF_DEBUG,
|
CONF_DEBUG,
|
||||||
|
CONF_NETWORK_KEY,
|
||||||
CONF_POLLING_INTERVAL,
|
CONF_POLLING_INTERVAL,
|
||||||
CONF_USB_STICK_PATH,
|
CONF_USB_STICK_PATH,
|
||||||
DATA_NETWORK,
|
DATA_NETWORK,
|
||||||
|
@ -46,8 +47,23 @@ def websocket_get_config(hass, connection, msg):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@websocket_api.require_admin
|
||||||
|
@websocket_api.websocket_command({vol.Required(TYPE): "zwave/get_migration_config"})
|
||||||
|
def websocket_get_migration_config(hass, connection, msg):
|
||||||
|
"""Get Z-Wave configuration for migration."""
|
||||||
|
config = hass.data[DATA_ZWAVE_CONFIG]
|
||||||
|
connection.send_result(
|
||||||
|
msg[ID],
|
||||||
|
{
|
||||||
|
CONF_USB_STICK_PATH: config[CONF_USB_STICK_PATH],
|
||||||
|
CONF_NETWORK_KEY: config[CONF_NETWORK_KEY],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_load_websocket_api(hass):
|
def async_load_websocket_api(hass):
|
||||||
"""Set up the web socket API."""
|
"""Set up the web socket API."""
|
||||||
websocket_api.async_register_command(hass, websocket_network_status)
|
websocket_api.async_register_command(hass, websocket_network_status)
|
||||||
websocket_api.async_register_command(hass, websocket_get_config)
|
websocket_api.async_register_command(hass, websocket_get_config)
|
||||||
|
websocket_api.async_register_command(hass, websocket_get_migration_config)
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
from homeassistant.bootstrap import async_setup_component
|
from homeassistant.bootstrap import async_setup_component
|
||||||
from homeassistant.components.zwave.const import (
|
from homeassistant.components.zwave.const import (
|
||||||
CONF_AUTOHEAL,
|
CONF_AUTOHEAL,
|
||||||
|
CONF_NETWORK_KEY,
|
||||||
CONF_POLLING_INTERVAL,
|
CONF_POLLING_INTERVAL,
|
||||||
CONF_USB_STICK_PATH,
|
CONF_USB_STICK_PATH,
|
||||||
)
|
)
|
||||||
|
@ -19,6 +20,7 @@ async def test_zwave_ws_api(hass, mock_openzwave, hass_ws_client):
|
||||||
CONF_AUTOHEAL: False,
|
CONF_AUTOHEAL: False,
|
||||||
CONF_USB_STICK_PATH: "/dev/zwave",
|
CONF_USB_STICK_PATH: "/dev/zwave",
|
||||||
CONF_POLLING_INTERVAL: 6000,
|
CONF_POLLING_INTERVAL: 6000,
|
||||||
|
CONF_NETWORK_KEY: "0xTE, 0xST, 0xTE, 0xST, 0xTE, 0xST, 0xTE, 0xST, 0xTE, 0xST, 0xTE, 0xST, 0xTE, 0xST, 0xTE, 0xST",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -35,3 +37,13 @@ async def test_zwave_ws_api(hass, mock_openzwave, hass_ws_client):
|
||||||
assert result[CONF_USB_STICK_PATH] == "/dev/zwave"
|
assert result[CONF_USB_STICK_PATH] == "/dev/zwave"
|
||||||
assert not result[CONF_AUTOHEAL]
|
assert not result[CONF_AUTOHEAL]
|
||||||
assert result[CONF_POLLING_INTERVAL] == 6000
|
assert result[CONF_POLLING_INTERVAL] == 6000
|
||||||
|
|
||||||
|
await client.send_json({ID: 6, TYPE: "zwave/get_migration_config"})
|
||||||
|
msg = await client.receive_json()
|
||||||
|
result = msg["result"]
|
||||||
|
|
||||||
|
assert result[CONF_USB_STICK_PATH] == "/dev/zwave"
|
||||||
|
assert (
|
||||||
|
result[CONF_NETWORK_KEY]
|
||||||
|
== "0xTE, 0xST, 0xTE, 0xST, 0xTE, 0xST, 0xTE, 0xST, 0xTE, 0xST, 0xTE, 0xST, 0xTE, 0xST, 0xTE, 0xST"
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue