Skip to content
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

[Bug] Unifi widget does not set widget.fields if none are configured #2771

Closed
3 tasks done
JeffRandall opened this issue Jan 27, 2024 · 10 comments
Closed
3 tasks done

Comments

@JeffRandall
Copy link
Contributor

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:
image

With no fields configured, I see:
image
(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

  1. configure the documented widget.fields eg fields: ["uptime", "wan", "lan_users", "wlan_users"]
  2. 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

@shamoon
Copy link
Collaborator

shamoon commented Jan 27, 2024

Im not exactly clear what youre reporting here. This does work.

               fields: ["uptime", "wan"]
Screenshot 2024-01-27 at 3 14 21 PM
fields: ["uptime", "wan", "lan_users"]
Screenshot 2024-01-27 at 3 15 12 PM

@shamoon shamoon closed this as completed Jan 27, 2024
@shamoon shamoon added cant reproduce and removed bug Something isn't working unconfirmed labels Jan 27, 2024
@JeffRandall
Copy link
Contributor Author

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.

@shamoon
Copy link
Collaborator

shamoon commented Jan 27, 2024

We can cross that bridge if we get there...

@JeffRandall
Copy link
Contributor Author

At bare minimum, the documentation is incorrect and should be updated to properly list the supported fields.

@JeffRandall
Copy link
Contributor Author

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.

@JeffRandall
Copy link
Contributor Author

Nor does uptime display without a gateway installed (from looking at the code and JSON).

@shamoon
Copy link
Collaborator

shamoon commented Jan 27, 2024

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:

[wan, lan, wlan].forEach((s) => {
s.up = s.status === "ok"; // eslint-disable-line no-param-reassign
s.show = s.status !== "unknown"; // eslint-disable-line no-param-reassign
});

@JeffRandall
Copy link
Contributor Author

JeffRandall commented Jan 27, 2024

{"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.

@shamoon
Copy link
Collaborator

shamoon commented Jan 27, 2024

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

Copy link
Contributor

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants