Major changes: - Implement parallel device processing using ThreadPoolExecutor (10 workers) - Add comprehensive error and warning tracking in ReportGenerator - Fix MQTT configuration verification (query Topic/FullTopic directly) - Improve console settings thread safety with locks - Fix UniFi client for UniFi OS API endpoints - Normalize FullTopic handling (strip URL-encoded spaces) - Update network exclude patterns to support wildcards - Add test_unifi_connection.py for debugging UniFi connectivity Performance improvements: - Process devices concurrently for faster execution - Reduced verbose logging during parallel processing Bug fixes: - Handle deprecated.json format correctly (list vs dict) - Fix exclude_patterns matching with partial string support - Fix UniFi API authentication and endpoint paths for UniFi OS 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
59 lines
1.7 KiB
Python
59 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Test UniFi connection and authentication."""
|
|
|
|
import requests
|
|
import urllib3
|
|
import json
|
|
|
|
urllib3.disable_warnings()
|
|
|
|
# Load your actual configuration
|
|
with open('network_configuration.json', 'r') as f:
|
|
config = json.load(f)
|
|
|
|
host = config['unifi']['host']
|
|
username = config['unifi']['username']
|
|
password = config['unifi']['password']
|
|
site = config['unifi'].get('site', 'default')
|
|
|
|
print(f'Testing connection to: {host}')
|
|
print(f'Username: {username}')
|
|
print(f'Site: {site}')
|
|
print('=' * 60)
|
|
|
|
# Test UniFi OS login (modern)
|
|
print('\n1. Attempting UniFi OS login (/api/auth/login)...')
|
|
try:
|
|
session = requests.Session()
|
|
response = session.post(
|
|
f'{host}/api/auth/login',
|
|
json={'username': username, 'password': password},
|
|
verify=False,
|
|
timeout=10
|
|
)
|
|
print(f' Status code: {response.status_code}')
|
|
print(f' Response: {response.text[:200]}')
|
|
if response.status_code == 200:
|
|
print(' ✓ UniFi OS authentication successful!')
|
|
except Exception as e:
|
|
print(f' ✗ Error: {e}')
|
|
|
|
# Test legacy UniFi Controller login (older controllers)
|
|
print('\n2. Attempting legacy UniFi Controller login (/api/login)...')
|
|
try:
|
|
session2 = requests.Session()
|
|
response2 = session2.post(
|
|
f'{host}/api/login',
|
|
json={'username': username, 'password': password},
|
|
verify=False,
|
|
timeout=10
|
|
)
|
|
print(f' Status code: {response2.status_code}')
|
|
print(f' Response: {response2.text[:200]}')
|
|
if response2.status_code == 200:
|
|
print(' ✓ Legacy UniFi authentication successful!')
|
|
except Exception as e:
|
|
print(f' ✗ Error: {e}')
|
|
|
|
print('\n' + '=' * 60)
|