-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommission.py
More file actions
35 lines (29 loc) · 1.15 KB
/
commission.py
File metadata and controls
35 lines (29 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import asyncio
import aiohttp
import sys
import logging
from matter_server.client import MatterClient
# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
MATTER_SERVER_URL = "ws://localhost:5580/ws"
async def main():
if len(sys.argv) < 2:
print("Usage: python commission.py <PAIRING_CODE> [--network-only]")
sys.exit(1)
code = sys.argv[1]
network_only = "--network-only" in sys.argv
logger.info(f"Connecting to Matter Server at {MATTER_SERVER_URL}...")
async with aiohttp.ClientSession() as session:
async with MatterClient(MATTER_SERVER_URL, session) as client:
logger.info("Connected. Starting commissioning...")
logger.info(f"Network only mode: {network_only}")
try:
node = await client.commission_with_code(code, network_only=network_only)
logger.info(f"Successfully commissioned node: {node}")
except Exception as e:
logger.error(f"Commissioning failed: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
asyncio.run(main())