fix(interfaces): report the WAN speed in Mbit/s

NewLayer1DownstreamMaxBitRate is bit/s; dividing by 1000 gave kbit/s,
so a 250 Mbit/s line came out as 250000 in a field NAPALM defines as
Mbit/s.

Closes #2
This commit is contained in:
Christian Manivong committed 2026-11-01 21:51:22 +01:00
1 parent 5dbfe62271
commit 3783f74eb8
3 files changed
+10 -1

No files matched your search

+4 -1
View File
@@ -66,6 +66,9 @@ _ANY_REMOTE = "0.0.0.0" # nosec B104
# (e.g. a service not present on a given FritzOS version/model).
_OPTIONAL_SERVICE_ERRORS = (FritzServiceError, FritzActionError, FritzConnectionException)
#: TR-064 reports the WAN sync rate in bit/s; NAPALM's interface ``speed`` is Mbit/s.
_BIT_PER_MBIT = 1_000_000
def _to_float(value: Any, default: float = 0.0) -> float:
"""Convert a TR-064 field to float, returning *default* for non-numeric values like 'Auto'."""
@@ -265,7 +268,7 @@ class FritzBoxDriver(ResidentialGatewayDriver):
"description": link.get("NewWANAccessType", "WAN"),
"last_flapped": -1.0,
"mac_address": "",
"speed": _to_float(link.get("NewLayer1DownstreamMaxBitRate")) / 1000,
"speed": _to_float(link.get("NewLayer1DownstreamMaxBitRate")) / _BIT_PER_MBIT,
"mtu": 1500,
}
except _OPTIONAL_SERVICE_ERRORS: