-
-
Notifications
You must be signed in to change notification settings - Fork 868
Add Unifi service #985
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add Unifi service #985
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again @igorkulman. Aside a thing on the prefix management, it looks good 👍
| - **Access Points**: Number of UniFi access points (UAP devices) | ||
| - **Network Devices**: Number of other UniFi network devices (switches, gateways, etc.) | ||
|
|
||
| The service uses UniFi's standard API endpoints and maintains session cookies automatically. For UDM/UDM Pro devices, the service will automatically use the `/proxy/network` prefix when `udm: true` is configured. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
udm option is not listed in the configuration option
| }); | ||
| this.sessionCookie = true; | ||
| return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line can be removed, there is no expected return value.
| // Check if URL indicates we need a prefix | ||
| if (this.item.apiUrl && this.item.apiUrl.includes("/manage")) { | ||
| return "/manage"; | ||
| } | ||
| if (this.item.url && this.item.url.includes("/manage")) { | ||
| return "/manage"; | ||
| } | ||
| return this.item.udm ? "/proxy/network" : ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
apiUrl does not exists, or at least is not documented, but more importantly:
You are using it like that:
this.fetch(`${this.prefix}/api/s/${this.site}/stat/device`);
Considering that this.fetch will add this.item.url to the request, if the url does include /manage, you will end up with something like https://xxxxx/manage/manage/api/default/stats/devices (double prefix)
I see 2 options here:
- You can remove the
udmoption and use the standardendpointfield to get the api url with the prefix
(with the documentation saying to put the url with /manage or /proxy/network depending on the situation), and remove the prefix computed property. - OR update your code with the following:
| // Check if URL indicates we need a prefix | |
| if (this.item.apiUrl && this.item.apiUrl.includes("/manage")) { | |
| return "/manage"; | |
| } | |
| if (this.item.url && this.item.url.includes("/manage")) { | |
| return "/manage"; | |
| } | |
| return this.item.udm ? "/proxy/network" : ""; | |
| if (this.item.url && (this.item.url.includes("/manage") || this.item.url.includes("/proxy/network")) { | |
| // the configuration already include the prefix | |
| return ""; | |
| } | |
| return this.item.udm ? "/proxy/network" : "/manage"; |
Description
This PR adds a new UniFi service integration that displays network information from UniFi Network

Controllers, including connected clients, access points, and other network devices.
The UniFi service automatically handles session-based authentication and CSRF protection,
supporting both legacy and modern UniFi API endpoints. It provides real-time monitoring of network
infrastructure with configurable refresh intervals.
Key Features:
Mock Data Included:
I only have a self-hosted Unifi controller running locally, so I did not test UDM or Cloud Key but they should work according to Unifi api docs.
Type of change
Checklist:
README.md).config.ymlfile