Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 92 additions & 90 deletions aiohasupervisor/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,137 +145,139 @@
UpdateType,
)
from aiohasupervisor.models.supervisor import (
DetectBlockingIO,
SupervisorInfo,
SupervisorOptions,
SupervisorStats,
SupervisorUpdateOptions,
)

__all__ = [
"HostFeature",
"SupervisorState",
"UpdateChannel",
"LogLevel",
"UpdateType",
"RootInfo",
"AvailableUpdate",
"AddonStage",
"AddonStartup",
"LOCATION_CLOUD_BACKUP",
"LOCATION_LOCAL_STORAGE",
"AccessPoint",
"AddonBoot",
"AddonBootConfig",
"CpuArch",
"Capability",
"AppArmor",
"SupervisorRole",
"AddonSet",
"AddonStage",
"AddonStartup",
"AddonState",
"StoreAddon",
"StoreAddonComplete",
"InstalledAddon",
"InstalledAddonComplete",
"AddonsOptions",
"AddonsConfigValidate",
"AddonsOptions",
"AddonsRebuild",
"AddonsSecurityOptions",
"AddonsStats",
"AddonsUninstall",
"Repository",
"StoreInfo",
"StoreAddonUpdate",
"StoreAddRepository",
"Check",
"CheckOptions",
"CheckType",
"ContextType",
"Issue",
"IssueType",
"ResolutionInfo",
"Suggestion",
"SuggestionType",
"UnhealthyReason",
"UnsupportedReason",
"SupervisorInfo",
"SupervisorOptions",
"SupervisorStats",
"SupervisorUpdateOptions",
"HomeAssistantInfo",
"HomeAssistantOptions",
"HomeAssistantRebuildOptions",
"HomeAssistantRestartOptions",
"HomeAssistantStats",
"HomeAssistantStopOptions",
"HomeAssistantUpdateOptions",
"RaucState",
"BootSlotName",
"BootSlot",
"OSInfo",
"OSUpdate",
"MigrateDataOptions",
"DataDisk",
"SetBootSlotOptions",
"GreenInfo",
"GreenOptions",
"YellowInfo",
"YellowOptions",
"LOCATION_CLOUD_BACKUP",
"LOCATION_LOCAL_STORAGE",
"AddonSet",
"AppArmor",
"AuthMethod",
"AvailableUpdate",
"Backup",
"BackupAddon",
"BackupComplete",
"BackupContent",
"BackupJob",
"BackupLocationAttributes",
"BackupType",
"BackupsInfo",
"BackupsOptions",
"BackupType",
"BootSlot",
"BootSlotName",
"CIFSMountRequest",
"CIFSMountResponse",
"Capability",
"Check",
"CheckOptions",
"CheckType",
"ContextType",
"CpuArch",
"DataDisk",
"DetectBlockingIO",
"Discovery",
"DiscoveryConfig",
"DockerNetwork",
"DownloadBackupOptions",
"Folder",
"FreezeOptions",
"FullBackupOptions",
"FullRestoreOptions",
"NewBackup",
"PartialBackupOptions",
"PartialRestoreOptions",
"RemoveBackupOptions",
"UploadBackupOptions",
"Discovery",
"DiscoveryConfig",
"AccessPoint",
"AuthMethod",
"DockerNetwork",
"InterfaceMethod",
"InterfaceType",
"GreenInfo",
"GreenOptions",
"HomeAssistantInfo",
"HomeAssistantOptions",
"HomeAssistantRebuildOptions",
"HomeAssistantRestartOptions",
"HomeAssistantStats",
"HomeAssistantStopOptions",
"HomeAssistantUpdateOptions",
"HostFeature",
"HostInfo",
"HostOptions",
"IPv4",
"IPv4Config",
"IPv6",
"IPv6Config",
"NetworkInfo",
"NetworkInterface",
"NetworkInterfaceConfig",
"Vlan",
"VlanConfig",
"Wifi",
"WifiConfig",
"WifiMode",
"HostInfo",
"HostOptions",
"RebootOptions",
"Service",
"ServiceState",
"ShutdownOptions",
"InstalledAddon",
"InstalledAddonComplete",
"InterfaceMethod",
"InterfaceType",
"Issue",
"IssueType",
"Job",
"JobCondition",
"JobError",
"JobsInfo",
"JobsOptions",
"CIFSMountRequest",
"CIFSMountResponse",
"LogLevel",
"MigrateDataOptions",
"MountCifsVersion",
"MountsInfo",
"MountsOptions",
"MountState",
"MountType",
"MountUsage",
"MountsInfo",
"MountsOptions",
"NFSMountRequest",
"NFSMountResponse",
"NetworkInfo",
"NetworkInterface",
"NetworkInterfaceConfig",
"NewBackup",
"OSInfo",
"OSUpdate",
"PartialBackupOptions",
"PartialRestoreOptions",
"RaucState",
"RebootOptions",
"RemoveBackupOptions",
"Repository",
"ResolutionInfo",
"RootInfo",
"Service",
"ServiceState",
"SetBootSlotOptions",
"ShutdownOptions",
"StoreAddRepository",
"StoreAddon",
"StoreAddonComplete",
"StoreAddonUpdate",
"StoreInfo",
"Suggestion",
"SuggestionType",
"SupervisorInfo",
"SupervisorOptions",
"SupervisorRole",
"SupervisorState",
"SupervisorStats",
"SupervisorUpdateOptions",
"UnhealthyReason",
"UnsupportedReason",
"UpdateChannel",
"UpdateType",
"UploadBackupOptions",
"Vlan",
"VlanConfig",
"Wifi",
"WifiConfig",
"WifiMode",
"YellowInfo",
"YellowOptions",
]
16 changes: 16 additions & 0 deletions aiohasupervisor/models/supervisor.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
"""Models for supervisor component."""

from dataclasses import dataclass
from enum import StrEnum
from ipaddress import IPv4Address

from .base import ContainerStats, Options, Request, ResponseData
from .root import LogLevel, UpdateChannel

# --- ENUMS ----


class DetectBlockingIO(StrEnum):
"""DetectBlockingIO type."""

OFF = "off"
ON = "on"
ON_AT_STARTUP = "on_at_startup"


# --- OBJECTS ----


@dataclass(frozen=True, slots=True)
class SupervisorInfo(ResponseData):
Expand All @@ -26,6 +40,7 @@ class SupervisorInfo(ResponseData):
diagnostics: bool | None
auto_update: bool
country: str | None
detect_blocking_io: bool


@dataclass(frozen=True, slots=True)
Expand Down Expand Up @@ -54,3 +69,4 @@ class SupervisorOptions(Options):
force_security: bool | None = None
auto_update: bool | None = None
country: str | None = None
detect_blocking_io: DetectBlockingIO | None = None
26 changes: 21 additions & 5 deletions tests/fixtures/supervisor_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"auto_update": true,
"country": null,
"wait_boot": 5,
"detect_blocking_io": false,
"addons": [
{
"name": "Terminal & SSH",
Expand All @@ -40,11 +41,26 @@
}
],
"addons_repositories": [
{ "name": "Local add-ons", "slug": "local" },
{ "name": "Music Assistant", "slug": "d5369777" },
{ "name": "Official add-ons", "slug": "core" },
{ "name": "ESPHome", "slug": "5c53de3b" },
{ "name": "Home Assistant Community Add-ons", "slug": "a0d7b954" }
{
"name": "Local add-ons",
"slug": "local"
},
{
"name": "Music Assistant",
"slug": "d5369777"
},
{
"name": "Official add-ons",
"slug": "core"
},
{
"name": "ESPHome",
"slug": "5c53de3b"
},
{
"name": "Home Assistant Community Add-ons",
"slug": "a0d7b954"
}
]
}
}
10 changes: 9 additions & 1 deletion tests/test_supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from aiohasupervisor import SupervisorClient
from aiohasupervisor.models import SupervisorOptions, SupervisorUpdateOptions
from aiohasupervisor.models.supervisor import DetectBlockingIO

from . import load_fixture
from .const import SUPERVISOR_URL
Expand Down Expand Up @@ -43,6 +44,7 @@ async def test_supervisor_info(
assert info.logging == "info"
assert info.ip_address == IPv4Address("172.30.32.2")
assert info.country is None
assert info.detect_blocking_io is False


async def test_supervisor_stats(
Expand Down Expand Up @@ -107,7 +109,12 @@ async def test_supervisor_options(
responses.post(f"{SUPERVISOR_URL}/supervisor/options", status=200)
assert (
await supervisor_client.supervisor.set_options(
SupervisorOptions(debug=True, debug_block=True, country="NL")
SupervisorOptions(
debug=True,
debug_block=True,
country="NL",
detect_blocking_io=DetectBlockingIO.ON_AT_STARTUP,
)
)
is None
)
Expand All @@ -123,6 +130,7 @@ async def test_supervisor_options(
"debug": True,
"debug_block": True,
"country": "NL",
"detect_blocking_io": "on_at_startup",
}


Expand Down