Skip to content

Commit 93acae5

Browse files
authored
Merge pull request #43 from CoMPaTech/testing
Improve consume function
2 parents 4f6b159 + 869b27e commit 93acae5

File tree

7 files changed

+399
-5
lines changed

7 files changed

+399
-5
lines changed

.github/workflows/verify.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,13 @@ jobs:
151151
run: |
152152
. venv/bin/activate
153153
coverage combine coverage*/.coverage*
154-
coverage report --fail-under=80
154+
coverage report --fail-under=85
155155
coverage xml
156156
- name: Upload coverage to Codecov
157157
uses: codecov/codecov-action@v5
158158
env:
159159
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
160+
slug: CoMPaTech/python-airos
160161

161162
test-publishing:
162163
name: Build and publish Python 🐍 distributions 📦 to TestPyPI

.markdownlint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
default: true
22
MD013: false
3+
MD024: false

CHANGELOG.md

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [0.2.3] - 2025-08-02
6+
7+
### Changed
8+
9+
- Fixed callback function to async
10+
- Added changelog
11+
12+
## [0.2.2] - 2025-08-02
13+
14+
### Changed
15+
16+
- Added a method to control provisioning mode for AirOS devices.
17+
- Introduced a high-level asynchronous device discovery function for AirOS devices.
18+
- Standardized class, exception, and log naming from "Airos" to "AirOS" across the codebase.
19+
- Renamed enum members in WirelessMode for improved clarity.
20+
- Updated tests and fixtures to use new naming conventions and to cover new discovery functionality.
21+
22+
## [0.2.1] - 2025-08-02
23+
24+
### Added
25+
26+
- Added a new field to device status data showing the MAC address and interface name of the primary enabled interface.
27+
28+
### Changed
29+
30+
- Updated wireless fixture data to reflect the correct access point MAC address.
31+
32+
## [0.2.0] - 2025-07-28
33+
34+
### Added
35+
36+
- Added UDP-based discovery for Ubiquiti airOS devices, enabling automatic detection and information retrieval from devices on the network.
37+
- Introduced detailed error handling and new exception types for discovery-related issues.
38+
- Improved code consistency by standardizing logger variable naming.
39+
- Added a script to generate mock discovery packet fixtures for testing.
40+
- Introduced comprehensive tests for the new device discovery functionality.
41+
42+
## [0.1.8] - 2025-07-28
43+
44+
### Added
45+
46+
- Improved device connection status reporting with clearer distinction between connected and disconnected devices.
47+
- Enhanced status information for UNMS connectivity.
48+
- Clarified descriptions for connected and disconnected device states.
49+
50+
## [0.1.7] - 2025-07-27
51+
52+
### Changed
53+
54+
- Improved login error handling by providing a clear error message when authentication is denied.
55+
56+
## [0.1.6] - 2025-07-26
57+
58+
### Changed
59+
60+
- Renamed the AirOS data class to clarify its association with AirOS v8 devices.
61+
- Updated documentation to specify support for AirOS v8 devices.
62+
- Adjusted import statements to reflect the class renaming.
63+
64+
## [0.1.5] - 2025-07-23
65+
66+
### Changed
67+
68+
- Improved handling of unknown or invalid enum values in device data by logging and removing them during data processing, reducing the chance of errors.
69+
- Streamlined warning logging for device status, ensuring warnings are logged immediately rather than being cached.
70+
- Simplified internal data handling and validation logic for device configuration fields.
71+
72+
## [0.1.4] - 2025-07-22
73+
74+
### Changed
75+
76+
- Improved warning handling to ensure each unique warning is only logged once per session.
77+
- Added support for a new wireless mode labeled "AUTO".
78+
- Enhanced warning messages to prompt users to report unknown remote wireless modes.
79+
80+
## [0.1.3] - 2025-07-22
81+
82+
### Changed
83+
84+
- Updated device status retrieval to always return structured data instead of raw JSON.
85+
86+
### Removed
87+
88+
- Dropped JSON output
89+
- Removed a redundant test related to JSON status output.
90+
91+
## [0.1.2] - 2025-07-22
92+
93+
### Added
94+
95+
- Introduced a comprehensive and strongly typed data model for AirOS device data, enabling structured parsing and validation.
96+
- The device status method now supports returning either a structured object or raw JSON, with improved warning handling for unknown values.
97+
- Updated the README to include an example that prints the wireless mode from the device status.
98+
- Added new test to verify device status retrieval returns structured data objects alongside existing JSON-based tests.
99+
100+
### Changed
101+
102+
- Updated dependencies to include mashumaro and removed asyncio.
103+
- Bumped project version to 0.1.2.
104+
- Changed output/returns from JSON to mashumaro (tnx @joostlek)
105+
106+
## [0.1.1] - 2025-07-21
107+
108+
### Added
109+
110+
- Error/exception handling and raising
111+
112+
## [0.1.0] - 2025-07-20
113+
114+
### Changed
115+
116+
- Improve station reconnect
117+
118+
## [0.0.9] - 2025-07-19
119+
120+
### Added
121+
122+
- Add tests
123+
- Add station reconnect (`stakick`)
124+
125+
## [0.0.8] - 2025-07-16
126+
127+
### Changed
128+
129+
- Reworked exceptions
130+
131+
## [0.0.7] - 2025-07-16
132+
133+
### Changed
134+
135+
- Adjust function returns
136+
137+
## [0.0.6] - 2025-07-16
138+
139+
### Added
140+
141+
- Revert setting verify_ssl, leaving it up to the ingestor to set session
142+
143+
## [0.0.5] - 2025-07-15
144+
145+
### Add
146+
147+
- Add basic testing
148+
- Add renovate for chores
149+
150+
## [0.0.4] - 2025-07-13
151+
152+
### Added
153+
154+
- Improve session handling and ssl, bump version
155+
- Add `pre-commit`, prep `uv`
156+
- Add more actions and pypi publishing
157+
- Switch pypi publishing to Trusted Publishing
158+
- Ensure environment and permissions improving publishing
159+
- Actions and pypi
160+
161+
## [0.0.1] - 2025-07-13
162+
163+
### Added
164+
165+
- Initial commits

airos/airos8.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,10 @@ async def status(self) -> AirOSData:
240240
self._status_cgi_url,
241241
headers=authenticated_get_headers,
242242
) as response:
243+
response_text = await response.text()
244+
243245
if response.status == 200:
244246
try:
245-
response_text = await response.text()
246247
response_json = json.loads(response_text)
247248
try:
248249
adjusted_json = self.derived_data(response_json)
@@ -260,6 +261,7 @@ async def status(self) -> AirOSData:
260261
else:
261262
log = f"Authenticated status.cgi failed: {response.status}. Response: {response_text}"
262263
_LOGGER.error(log)
264+
raise AirOSDeviceConnectionError from None
263265
except (
264266
aiohttp.ClientError,
265267
aiohttp.client_exceptions.ConnectionTimeoutError,

airos/discovery.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ async def async_discover_devices(timeout: int) -> dict[str, dict[str, Any]]:
284284
_LOGGER.debug("Starting AirOS device discovery for %s seconds", timeout)
285285
discovered_devices: dict[str, dict[str, Any]] = {}
286286

287-
def _async_airos_device_found(device_info: dict[str, Any]) -> None:
287+
async def _async_airos_device_found(device_info: dict[str, Any]) -> None:
288288
"""Handle discovered device."""
289289
mac_address = device_info.get("mac_address")
290290
if mac_address:
@@ -321,5 +321,4 @@ def _async_airos_device_found(device_info: dict[str, Any]) -> None:
321321
_LOGGER.exception("An unexpected error occurred during discovery")
322322
raise AirOSListenerError("cannot_connect") from err
323323

324-
_LOGGER.debug("Discovery completed. Found %s devices.", len(discovered_devices))
325324
return discovered_devices

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.2.2"
7+
version = "0.2.3"
88
license = "MIT"
99
description = "Ubiquity airOS module(s) for Python 3."
1010
readme = "README.md"

0 commit comments

Comments
 (0)