You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add read-only unifi wan list with link, health, traffic, and cellular modem telemetry for WAN1-WAN3.
Why
Multi-WAN and cellular failover state currently require controller UI inspection. This exposes the underlying state without flattening Ethernet and mobile-backup semantics into one misleading status flag.
Safety
The gateway response is decoded into narrow typed records. Modem identifiers and unknown vendor fields are omitted; regression fixtures inject secret-like fields and verify they never reach output.
Checks
env -u UNIFI_API_KEY -u UNIFI_HOST make check
Live read-only validation against a three-interface UniFi gateway with a ready cellular backup
This is useful and I would like to take it. Two things first.
Negative sentinels published as measurements.latency and availability are Option<f64>, so a -1 from the controller deserializes cleanly and is emitted as latency_ms: -1.0. A caller cannot distinguish that from a real reading. UniFi does use -1 as an unmeasured marker in this family of fields: in a single stat/device response from my controller it appears in icmp_avg_rtt, dns_avg_latency, satisfaction, min_rssi and uplink_table[].signal. My WAN is up so I could not capture a down-link wan1 block directly, but null rather than -1.0 is the honest value there and the mapping is cheap to add.
Numeric width, lower confidence.speed, rx_bytes, tx_bytes, rx_rate and tx_rate are Option<u64>, and a single negative value anywhere in the WAN block fails the whole deserialization rather than degrading one field:
invalid value: integer `-1`, expected u64
I want to be straight that I could not evidence the trigger. I assumed at first that speed used the same -1 marker, but on my hardware down switch ports report speed: 0, and no field with "speed" in its path holds -1 anywhere in the payload. So this may never fire in practice. It is worth hardening because the failure mode is total rather than local, but treat it as defensive rather than as a reported bug.
Gateway match.matches!(device_type, Some("ugw" | "udm")) works on my UCG-Ultra, which reports udm. My understanding is that UXG hardware reports uxg and would fall through to "UniFi gateway not found", but I do not have one to confirm and I am going on documentation rather than measurement. Worth widening if you can verify it. It fails cleanly with exit 4, so this is coverage rather than a defect.
Everything else checks out. I ran this against a live controller and the output was correct, and fmt, clippy -D warnings, the test suite and clispec 0.3 all pass.
These four PRs overlap in client.rs, types.rs, main.rs, schema.rs and mock_server.rs, so whichever lands first makes the others conflict. That is my sequencing problem more than yours: I am landing #5 first, and if you would rather not chase rebases across three branches, say so and I will resolve the conflicts on merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add read-only
unifi wan listwith link, health, traffic, and cellular modem telemetry for WAN1-WAN3.Why
Multi-WAN and cellular failover state currently require controller UI inspection. This exposes the underlying state without flattening Ethernet and mobile-backup semantics into one misleading status flag.
Safety
The gateway response is decoded into narrow typed records. Modem identifiers and unknown vendor fields are omitted; regression fixtures inject secret-like fields and verify they never reach output.
Checks
env -u UNIFI_API_KEY -u UNIFI_HOST make check