|
| 1 | +"""Ubiquiti AirOS 6.""" |
| 2 | + |
| 3 | +from __future__ import annotations |
| 4 | + |
| 5 | +import logging |
| 6 | +from typing import Any |
| 7 | + |
| 8 | +from aiohttp import ClientSession |
| 9 | + |
| 10 | +from .base import AirOS |
| 11 | +from .data import AirOS6Data, DerivedWirelessRole |
| 12 | +from .exceptions import AirOSNotSupportedError |
| 13 | + |
| 14 | +_LOGGER = logging.getLogger(__name__) |
| 15 | + |
| 16 | + |
| 17 | +class AirOS6(AirOS[AirOS6Data]): |
| 18 | + """AirOS 6 connection class.""" |
| 19 | + |
| 20 | + def __init__( |
| 21 | + self, |
| 22 | + host: str, |
| 23 | + username: str, |
| 24 | + password: str, |
| 25 | + session: ClientSession, |
| 26 | + use_ssl: bool = True, |
| 27 | + ) -> None: |
| 28 | + """Initialize AirOS8 class.""" |
| 29 | + super().__init__( |
| 30 | + data_model=AirOS6Data, |
| 31 | + host=host, |
| 32 | + username=username, |
| 33 | + password=password, |
| 34 | + session=session, |
| 35 | + use_ssl=use_ssl, |
| 36 | + ) |
| 37 | + |
| 38 | + @staticmethod |
| 39 | + def derived_wireless_data( |
| 40 | + derived: dict[str, Any], response: dict[str, Any] |
| 41 | + ) -> dict[str, Any]: |
| 42 | + """Add derived wireless data to the device response.""" |
| 43 | + # Access Point / Station - no info on ptp/ptmp |
| 44 | + # assuming ptp for station mode |
| 45 | + derived["ptp"] = True |
| 46 | + wireless_mode = response.get("wireless", {}).get("mode", "") |
| 47 | + match wireless_mode: |
| 48 | + case "ap": |
| 49 | + derived["access_point"] = True |
| 50 | + derived["role"] = DerivedWirelessRole.ACCESS_POINT |
| 51 | + case "sta": |
| 52 | + derived["station"] = True |
| 53 | + |
| 54 | + return derived |
| 55 | + |
| 56 | + async def update_check(self, force: bool = False) -> dict[str, Any]: |
| 57 | + """Check for firmware updates. Not supported on AirOS6.""" |
| 58 | + raise AirOSNotSupportedError("Firmware update check not supported on AirOS6.") |
| 59 | + |
| 60 | + async def stakick(self, mac_address: str | None = None) -> bool: |
| 61 | + """Kick a station off the AP. Not supported on AirOS6.""" |
| 62 | + raise AirOSNotSupportedError("Station kick not supported on AirOS6.") |
| 63 | + |
| 64 | + async def provmode(self, active: bool = False) -> bool: |
| 65 | + """Enable/Disable provisioning mode. Not supported on AirOS6.""" |
| 66 | + raise AirOSNotSupportedError("Provisioning mode not supported on AirOS6.") |
| 67 | + |
| 68 | + async def warnings(self) -> dict[str, Any]: |
| 69 | + """Get device warnings. Not supported on AirOS6.""" |
| 70 | + raise AirOSNotSupportedError("Device warnings not supported on AirOS6.") |
| 71 | + |
| 72 | + async def progress(self) -> dict[str, Any]: |
| 73 | + """Get firmware progress. Not supported on AirOS6.""" |
| 74 | + raise AirOSNotSupportedError("Firmware progress not supported on AirOS6.") |
| 75 | + |
| 76 | + async def download(self) -> dict[str, Any]: |
| 77 | + """Download the device firmware. Not supported on AirOS6.""" |
| 78 | + raise AirOSNotSupportedError("Firmware download not supported on AirOS6.") |
| 79 | + |
| 80 | + async def install(self) -> dict[str, Any]: |
| 81 | + """Install a firmware update. Not supported on AirOS6.""" |
| 82 | + raise AirOSNotSupportedError("Firmware install not supported on AirOS6.") |
0 commit comments