[Bug] Unifi widget does not set widget.fields if none are configured
JeffRandall opened this issue · comments
Description
The unifi widget returns different data blocks that it calculates without respecting or setting the widget.fields described in the documentation. The data blocks should always be returned as is consistent with other widgets. Blocks displayed should be filtered according to the fields configured or a default set of fields that the widget sets. Preventing configured fields from being displayed because the widget does not provide data is inconsistent with the behavior of other widgets and unexpected from an end user point of view.
Additionally, the fields described in the documentation are incomplete. Additional fields lan
, lan_devices
, wlan
, and wlan_devices
can be configured and should be added to the documentation.
With my setup, a self-hosted controller and 2 access points, using the configuration attached, I see one field instead of four:
With no fields configured, I see:
(the additional fields are configurable with "wlan_devices" and "wlan" respectively)
I have a preliminary PR prepared that I will submit to address this bug.
Steps to reproduce
- configure the documented widget.fields eg
fields: ["uptime", "wan", "lan_users", "wlan_users"]
- depending on the devices present in your unifi configuration, note that you do not see fields configured if the devices are not available (eg, the fields for wan will not appear without a gateway, lan are not available without a switch, wlan without an access point).
homepage version
v0.8.6
Installation method
Source
Configuration
- UniFi Controller:
icon: unifi.svg
href: "{{HOMEPAGE_VAR_UNIFI_CONTROLLER_URL}}"
description: Unifi Wi-fi Controller
siteMonitor: "{{HOMEPAGE_VAR_UNIFI_CONTROLLER_URL}}"
widget:
type: unifi
url: "{{HOMEPAGE_VAR_UNIFI_CONTROLLER_URL}}"
username: "{{HOMEPAGE_VAR_UNIFI_CONTROLLER_USERNAME}}"
password: "{{HOMEPAGE_VAR_UNIFI_CONTROLLER_PASSWORD}}"
site: "{{HOMEPAGE_VAR_UNIFI_CONTROLLER_SITE}}"
fields: ["uptime", "wan", "lan_users", "wlan_users"]
Container Logs
No response
Browser Logs
No response
Troubleshooting
n/a
Other
This issue was discovered while testing the PR prepared for #2764 and fixes that interaction.
Before submitting, I have made sure to
- Check the documentation
- Follow the troubleshooting guide (please include output above if applicable).
- Search existing issues and discussions.
The concern is the method of limiting the displayed fields by limiting the <Block> </>
returned and does not set a default widget.fields -- this prevents the use of widget.fields to reorder the fields that I have a Discussion at #2764 about.
We can cross that bridge if we get there...
At bare minimum, the documentation is incorrect and should be updated to properly list the supported fields.
Additionally, because I do not have a switch or gateway product in my installation, it is broken for my install and installs like mine. I cannot get the lan field to display under any circumstances without installing new hardware. This is counter-intuitive to users.
Nor does uptime display without a gateway installed (from looking at the code and JSON).
Thats a different issue. If you'd like to FR using something else for uptime that'd be fine. I dont think anyone has raised that issue (and it's been this way for a while).
And lan
should depend on lan
from the unifi API:
homepage/src/widgets/unifi/component.jsx
Lines 36 to 39 in 98499cd
{"meta":{"rc":"ok"},"data":[{"anonymous_id":"74dcedf9-7bee-4aee-b443-87e28e0629bc","name":"default","_id":"60b6ba2e8aa73f5e8e661f5c","attr_no_delete":true,"attr_hidden_id":"default","desc":"Default","health":[{"subsystem":"wlan","status":"unknown","num_ap":0,"num_adopted":0,"num_disabled":0,"num_disconnected":0,"num_pending":0},{"subsystem":"wan","num_gw":0,"num_adopted":0,"num_disconnected":0,"num_pending":0,"status":"unknown"},{"subsystem":"www","status":"unknown"},{"subsystem":"lan","status":"unknown","num_sw":0,"num_adopted":0,"num_disconnected":0,"num_pending":0},{"subsystem":"vpn","status":"unknown"}],"num_new_alarms":0},{"anonymous_id":"83bec07f-1f28-49cc-a7fe-a40d3d661630","name":"ozey8xnz","_id":"60b6c98d8aa73f5e8e661f8a","desc":"Home","health":[{"subsystem":"wlan","num_user":15,"num_guest":0,"num_iot":0,"tx_bytes-r":95629,"rx_bytes-r":6321,"status":"ok","num_ap":2,"num_adopted":3,"num_disabled":1,"num_disconnected":0,"num_pending":0},{"subsystem":"wan","num_gw":0,"num_adopted":0,"num_disconnected":0,"num_pending":0,"status":"unknown"},{"subsystem":"www","status":"unknown"},{"subsystem":"lan","status":"unknown","num_sw":0,"num_adopted":0,"num_disconnected":0,"num_pending":0},{"subsystem":"vpn","status":"unknown"}],"num_new_alarms":0},{"anonymous_id":"4675a41d-5053-4e9d-bcbf-d6f8afdb38d3","name":"o7urfc85","_id":"641be96c8aa73f02f25f3e38","desc":"Disabled","health":[{"subsystem":"wlan","status":"unknown","num_ap":0,"num_adopted":0,"num_disabled":0,"num_disconnected":0,"num_pending":0},{"subsystem":"wan","num_gw":0,"num_adopted":1,"num_disconnected":1,"num_pending":0,"status":"error","gw_mac":"b4:fb:e4:d3:fe:d3","gw_name":null,"gw_system-stats":null,"gw_version":"4.4.56.5449062"},{"subsystem":"www","status":"error","gw_mac":"b4:fb:e4:d3:fe:d3"},{"subsystem":"lan","lan_ip":null,"status":"error","num_user":0,"num_guest":0,"num_iot":0,"tx_bytes-r":0,"rx_bytes-r":0,"num_sw":0,"num_adopted":0,"num_disconnected":0,"num_pending":0},{"subsystem":"vpn","status":"unknown"}],"num_new_alarms":0}]}
With my local setup, I have no lan devices -- but as a user, if I try and configure lan
I would expect to see an empty field, not have it refuse to display at all.
Yea I can see how that’s not obvious but I already added a commit adding the fields you correctly noted are missing and a note about this. I added you as author of that commit so you get ‘credit’ eg from the PR that you opened
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion for related concerns. See our contributing guidelines for more details.