UniFi Module Overview (unifi)
The unifi package provides integration with Ubiquiti UniFi network controllers, primarily used for network telemetry and physical presence detection.
Key Features
- API Client: Connects to the UniFi OS controller to query client devices and network health.
- Presence Detection: Tracks specific MAC addresses to determine if users (Dan, Liz) are physically "Home" or "Away".
- Network Analytics: Feeds data to the
sysadminagent for network troubleshooting.
Key Files
unifi/unifi_client.go: The raw HTTP API client for authentication and data retrieval.unifi/unifi.go: High-level logic for parsing client data and determining presence.
Integration Flow
- Authentication: Logs into the UniFi controller and retrieves a session cookie.
- Polling: Periodically fetches the list of active Wi-Fi and wired clients.
- Presence State: Compares active MAC addresses against known user devices.
- Wakeup Trigger: If a known device transitions from disconnected to connected, it triggers an event via the
wakeup.goAPI in the assistant module.
Guidance for AI Agents
- Network Diagnostics: Use the Unifi tools to check if a specific device is connected to the network or to review overall Wi-Fi health scores.
- Privacy: Be discreet with MAC addresses and exact connection times when summarizing network data in public or semi-public channels.