Skip to content

Commit ab562b6

Browse files
committed
Update values for v6 generic and XM specific
1 parent 1cddc84 commit ab562b6

File tree

6 files changed

+30
-8
lines changed

6 files changed

+30
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ All notable changes to this project will be documented in this file.
77
### Added
88

99
- Support for v6 firmware XM models using a different login path (XW already was successful)
10+
- Calculated cpuload on v6 if values available (to prevent reporting close to 100%)
11+
- Fix frequency on v6 firmware (if value is cast as a string ending in MHz)
1012

1113
## [0.5.6] - 2025-10-11
1214

airos/data.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,20 @@ class Host6(AirOSDataClass):
246246
totalram: int
247247
freeram: int
248248
cpuload: float | int | None
249+
cputotal: float | int | None # Reported on XM firmware
250+
cpubusy: float | int | None # Reported on XM firmware
249251

250252
@classmethod
251253
def __pre_deserialize__(cls, d: dict[str, Any]) -> dict[str, Any]:
252254
"""Pre-deserialize hook for Host."""
253255
_check_and_log_unknown_enum_value(d, "netrole", NetRole, "Host", "netrole")
256+
257+
# Calculate cpufloat from actuals instead on relying on near 100% value
258+
if (
259+
all(isinstance(d.get(k), (int, float)) for k in ("cpubusy", "cputotal"))
260+
and d["cputotal"] > 0
261+
):
262+
d["cpuload"] = round((d["cpubusy"] / d["cputotal"]) * 100, 2)
254263
return d
255264

256265

@@ -562,7 +571,7 @@ class Wireless6(AirOSDataClass):
562571
apmac: str
563572
countrycode: int
564573
channel: int
565-
frequency: str
574+
frequency: int
566575
dfs: int
567576
opmode: str
568577
antenna: str
@@ -593,6 +602,11 @@ def __pre_deserialize__(cls, d: dict[str, Any]) -> dict[str, Any]:
593602
_check_and_log_unknown_enum_value(
594603
d, "security", Security, "Wireless", "security"
595604
)
605+
606+
freq = d.get("frequency")
607+
if isinstance(freq, str) and "MHz" in freq:
608+
d["frequency"] = int(freq.split()[0])
609+
596610
return d
597611

598612

fixtures/airos_NanoStation_M5_sta_v6.3.16.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
},
2222
"genuine": "/images/genuine.png",
2323
"host": {
24-
"cpuload": 24.0,
24+
"cpubusy": 3786414,
25+
"cpuload": 25.51,
26+
"cputotal": 14845531,
2527
"devmodel": "NanoStation M5 ",
2628
"freeram": 42516480,
2729
"fwprefix": "XW",
@@ -140,7 +142,7 @@
140142
"dfs": 0,
141143
"distance": 750,
142144
"essid": "Nano",
143-
"frequency": "5180 MHz",
145+
"frequency": 5180,
144146
"hide_essid": 0,
145147
"mode": "sta",
146148
"noisef": -99,

fixtures/airos_NanoStation_loco_M5_v6.3.16_XM_ap.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
},
2222
"genuine": "/images/genuine.png",
2323
"host": {
24-
"cpuload": 100.0,
24+
"cpubusy": 11092563,
25+
"cpuload": 5.68,
26+
"cputotal": 195292633,
2527
"devmodel": "NanoStation loco M5 ",
2628
"freeram": 8429568,
2729
"fwprefix": "XM",
@@ -126,7 +128,7 @@
126128
"dfs": 1,
127129
"distance": 600,
128130
"essid": "SOMETHING",
129-
"frequency": "5700 MHz",
131+
"frequency": 5700,
130132
"hide_essid": 1,
131133
"mode": "ap",
132134
"noisef": -91,

fixtures/airos_NanoStation_loco_M5_v6.3.16_XM_sta.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
},
2222
"genuine": "/images/genuine.png",
2323
"host": {
24-
"cpuload": 100.0,
24+
"cpubusy": 11150046,
25+
"cpuload": 5.65,
26+
"cputotal": 197455604,
2527
"devmodel": "NanoStation loco M5 ",
2628
"freeram": 8753152,
2729
"fwprefix": "XM",
@@ -126,7 +128,7 @@
126128
"dfs": 0,
127129
"distance": 600,
128130
"essid": "SOMETHING",
129-
"frequency": "5700 MHz",
131+
"frequency": 5700,
130132
"hide_essid": 0,
131133
"mode": "sta",
132134
"noisef": -89,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "airos"
7-
version = "0.5.7a9"
7+
version = "0.5.7a10"
88
license = "MIT"
99
description = "Ubiquiti airOS module(s) for Python 3."
1010
readme = "README.md"

0 commit comments

Comments
 (0)