mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Add more fine grained control over Matter server commissioning for the Companion apps (#106237)
This commit is contained in:
parent
117ff21c48
commit
13702d51b1
@ -85,6 +85,7 @@ def async_handle_failed_command(
|
|||||||
{
|
{
|
||||||
vol.Required(TYPE): "matter/commission",
|
vol.Required(TYPE): "matter/commission",
|
||||||
vol.Required("code"): str,
|
vol.Required("code"): str,
|
||||||
|
vol.Optional("network_only"): bool,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@websocket_api.async_response
|
@websocket_api.async_response
|
||||||
@ -97,7 +98,9 @@ async def websocket_commission(
|
|||||||
matter: MatterAdapter,
|
matter: MatterAdapter,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Add a device to the network and commission the device."""
|
"""Add a device to the network and commission the device."""
|
||||||
await matter.matter_client.commission_with_code(msg["code"])
|
await matter.matter_client.commission_with_code(
|
||||||
|
msg["code"], network_only=msg.get("network_only", True)
|
||||||
|
)
|
||||||
connection.send_result(msg[ID])
|
connection.send_result(msg[ID])
|
||||||
|
|
||||||
|
|
||||||
@ -106,6 +109,7 @@ async def websocket_commission(
|
|||||||
{
|
{
|
||||||
vol.Required(TYPE): "matter/commission_on_network",
|
vol.Required(TYPE): "matter/commission_on_network",
|
||||||
vol.Required("pin"): int,
|
vol.Required("pin"): int,
|
||||||
|
vol.Optional("ip_addr"): str,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@websocket_api.async_response
|
@websocket_api.async_response
|
||||||
@ -118,7 +122,9 @@ async def websocket_commission_on_network(
|
|||||||
matter: MatterAdapter,
|
matter: MatterAdapter,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Commission a device already on the network."""
|
"""Commission a device already on the network."""
|
||||||
await matter.matter_client.commission_on_network(msg["pin"])
|
await matter.matter_client.commission_on_network(
|
||||||
|
msg["pin"], ip_addr=msg.get("ip_addr", None)
|
||||||
|
)
|
||||||
connection.send_result(msg[ID])
|
connection.send_result(msg[ID])
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
"dependencies": ["websocket_api"],
|
"dependencies": ["websocket_api"],
|
||||||
"documentation": "https://www.home-assistant.io/integrations/matter",
|
"documentation": "https://www.home-assistant.io/integrations/matter",
|
||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"requirements": ["python-matter-server==5.0.0"]
|
"requirements": ["python-matter-server==5.1.1"]
|
||||||
}
|
}
|
||||||
|
@ -2201,7 +2201,7 @@ python-kasa[speedups]==0.5.4
|
|||||||
# python-lirc==1.2.3
|
# python-lirc==1.2.3
|
||||||
|
|
||||||
# homeassistant.components.matter
|
# homeassistant.components.matter
|
||||||
python-matter-server==5.0.0
|
python-matter-server==5.1.1
|
||||||
|
|
||||||
# homeassistant.components.xiaomi_miio
|
# homeassistant.components.xiaomi_miio
|
||||||
python-miio==0.5.12
|
python-miio==0.5.12
|
||||||
|
@ -1659,7 +1659,7 @@ python-juicenet==1.1.0
|
|||||||
python-kasa[speedups]==0.5.4
|
python-kasa[speedups]==0.5.4
|
||||||
|
|
||||||
# homeassistant.components.matter
|
# homeassistant.components.matter
|
||||||
python-matter-server==5.0.0
|
python-matter-server==5.1.1
|
||||||
|
|
||||||
# homeassistant.components.xiaomi_miio
|
# homeassistant.components.xiaomi_miio
|
||||||
python-miio==0.5.12
|
python-miio==0.5.12
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
"node_id": 5,
|
"node_id": 5,
|
||||||
"date_commissioned": "2023-01-16T21:07:57.508440",
|
"date_commissioned": "2023-01-16T21:07:57.508440",
|
||||||
"last_interview": "2023-01-16T21:07:57.508448",
|
"last_interview": "2023-01-16T21:07:57.508448",
|
||||||
"last_subscription_attempt": 0,
|
|
||||||
"interview_version": 2,
|
"interview_version": 2,
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"0/4/0": 128,
|
"0/4/0": 128,
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
"date_commissioned": "2023-01-16T21:07:57.508440",
|
"date_commissioned": "2023-01-16T21:07:57.508440",
|
||||||
"last_interview": "2023-01-16T21:07:57.508448",
|
"last_interview": "2023-01-16T21:07:57.508448",
|
||||||
"interview_version": 2,
|
"interview_version": 2,
|
||||||
"last_subscription_attempt": 0,
|
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"0/4/0": 128,
|
"0/4/0": 128,
|
||||||
"0/4/65532": 1,
|
"0/4/65532": 1,
|
||||||
|
@ -32,7 +32,7 @@ async def test_commission(
|
|||||||
msg = await ws_client.receive_json()
|
msg = await ws_client.receive_json()
|
||||||
|
|
||||||
assert msg["success"]
|
assert msg["success"]
|
||||||
matter_client.commission_with_code.assert_called_once_with("12345678")
|
matter_client.commission_with_code.assert_called_once_with("12345678", True)
|
||||||
|
|
||||||
matter_client.commission_with_code.reset_mock()
|
matter_client.commission_with_code.reset_mock()
|
||||||
matter_client.commission_with_code.side_effect = InvalidCommand(
|
matter_client.commission_with_code.side_effect = InvalidCommand(
|
||||||
@ -40,17 +40,13 @@ async def test_commission(
|
|||||||
)
|
)
|
||||||
|
|
||||||
await ws_client.send_json(
|
await ws_client.send_json(
|
||||||
{
|
{ID: 2, TYPE: "matter/commission", "code": "12345678", "network_only": False}
|
||||||
ID: 2,
|
|
||||||
TYPE: "matter/commission",
|
|
||||||
"code": "12345678",
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
msg = await ws_client.receive_json()
|
msg = await ws_client.receive_json()
|
||||||
|
|
||||||
assert not msg["success"]
|
assert not msg["success"]
|
||||||
assert msg["error"]["code"] == "9"
|
assert msg["error"]["code"] == "9"
|
||||||
matter_client.commission_with_code.assert_called_once_with("12345678")
|
matter_client.commission_with_code.assert_called_once_with("12345678", False)
|
||||||
|
|
||||||
|
|
||||||
# This tests needs to be adjusted to remove lingering tasks
|
# This tests needs to be adjusted to remove lingering tasks
|
||||||
@ -74,7 +70,7 @@ async def test_commission_on_network(
|
|||||||
msg = await ws_client.receive_json()
|
msg = await ws_client.receive_json()
|
||||||
|
|
||||||
assert msg["success"]
|
assert msg["success"]
|
||||||
matter_client.commission_on_network.assert_called_once_with(1234)
|
matter_client.commission_on_network.assert_called_once_with(1234, None)
|
||||||
|
|
||||||
matter_client.commission_on_network.reset_mock()
|
matter_client.commission_on_network.reset_mock()
|
||||||
matter_client.commission_on_network.side_effect = NodeCommissionFailed(
|
matter_client.commission_on_network.side_effect = NodeCommissionFailed(
|
||||||
@ -82,17 +78,13 @@ async def test_commission_on_network(
|
|||||||
)
|
)
|
||||||
|
|
||||||
await ws_client.send_json(
|
await ws_client.send_json(
|
||||||
{
|
{ID: 2, TYPE: "matter/commission_on_network", "pin": 1234, "ip_addr": "1.2.3.4"}
|
||||||
ID: 2,
|
|
||||||
TYPE: "matter/commission_on_network",
|
|
||||||
"pin": 1234,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
msg = await ws_client.receive_json()
|
msg = await ws_client.receive_json()
|
||||||
|
|
||||||
assert not msg["success"]
|
assert not msg["success"]
|
||||||
assert msg["error"]["code"] == "1"
|
assert msg["error"]["code"] == "1"
|
||||||
matter_client.commission_on_network.assert_called_once_with(1234)
|
matter_client.commission_on_network.assert_called_once_with(1234, "1.2.3.4")
|
||||||
|
|
||||||
|
|
||||||
# This tests needs to be adjusted to remove lingering tasks
|
# This tests needs to be adjusted to remove lingering tasks
|
||||||
|
Loading…
x
Reference in New Issue
Block a user