| .. | ||
| controllers | ||
| doc | ||
| i18n | ||
| models | ||
| security | ||
| static | ||
| tests | ||
| utils | ||
| views | ||
| wizards | ||
| __init__.py | ||
| __manifest__.py | ||
| README.md | ||
| test_view.xml | ||
UniFi Integration for Odoo
Module d'intégration entre Odoo et les appareils UniFi Network (UDM Pro, UCG Max).
API Integration Notes
Authentication
The UniFi API requires specific endpoints and headers for authentication. Note that there are critical differences between UniFi controllers and the UDM Pro/UCG Max API:
# Python Example
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
headers = {
"Accept": "application/json",
"Content-Type": "application/json"
}
data = {
'username': 'your_username',
'password': 'your_password',
'rememberMe': True
}
session = requests.Session()
response = session.post(
'https://udmp:443/api/auth/login',
headers=headers,
json=data,
verify=False
)
API Endpoints
All API endpoints (except authentication) must be prefixed with /proxy/network. Common endpoints include:
System and Status
- System Health:
/api/system/health - System Info:
/proxy/network/api/s/{site}/stat/sysinfo - Dashboard Health:
/proxy/network/api/s/{site}/stat/health
Network Configuration
- Networks:
/proxy/network/api/s/{site}/rest/networkconf - Firewall Rules:
/proxy/network/api/s/{site}/rest/firewallrule - Port Forwards:
/proxy/network/api/s/{site}/stat/portforward - Routes:
/proxy/network/api/s/{site}/rest/routing
Devices and Clients
- All Devices:
/proxy/network/api/s/{site}/stat/device - Basic Device Info:
/proxy/network/api/s/{site}/stat/device-basic - Active Clients:
/proxy/network/api/s/{site}/stat/sta - All Clients:
/proxy/network/api/s/{site}/stat/user
Headers Required
All API requests must include these headers:
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"User-Agent": "Odoo UniFi Integration"
}
# Add CSRF token for authenticated requests
if csrf_token:
headers["X-CSRF-Token"] = csrf_token
SSL Verification
The UDM Pro uses self-signed certificates. SSL verification must be disabled:
# Disable SSL verification warnings
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
# Skip certificate validation in requests
verify=False
Module Features
Network Configuration
- Import and manage network settings
- Configure port forwarding rules
- Manage firewall rules and groups
- Handle routing configuration
Device Management
- Monitor device status and health
- Track active and configured clients
- View detailed device statistics
System Monitoring
- Dashboard with health metrics
- System performance statistics
- Network usage and throughput
Multi-Site Support
- Manage multiple UniFi sites
- Site-specific configurations
- Independent metrics per site
Installation
- Install the module in your Odoo instance
- Configure your UDM Pro credentials in the UniFi Integration settings
- Import your network configuration
Configuration
Site Setup
- Go to UniFi Integration > Sites
- Create a new site with:
- Name: Your site name
- Site ID: Usually "default" unless configured otherwise
- Description: Optional site description
- Physical Address: Optional location information
UDM Pro Configuration
- Add your UDM Pro configuration:
- Host: IP address or hostname
- Port: Usually 443 (HTTPS)
- Username: Your UDM Pro username
- Password: Your UDM Pro password
- MFA Token: If two-factor authentication is enabled
API Access
- Create a dedicated API user in UDM Pro
- Assign minimum required permissions
- Use secure network access (VPN or internal network)
Security Considerations
Authentication
- Use dedicated API credentials
- Enable two-factor authentication when possible
- Regularly rotate passwords
Network Security
- Restrict API access to specific networks
- Use VPN for remote access
- Configure appropriate firewall rules
Monitoring
- Monitor API access logs
- Track authentication failures
- Review system alerts and notifications
Data Protection
- Store credentials securely
- Encrypt sensitive configuration data
- Regular security audits