diff --git a/aiohasupervisor/models/__init__.py b/aiohasupervisor/models/__init__.py index afcfd8d..fa7b209 100644 --- a/aiohasupervisor/models/__init__.py +++ b/aiohasupervisor/models/__init__.py @@ -145,6 +145,7 @@ UpdateType, ) from aiohasupervisor.models.supervisor import ( + DetectBlockingIO, SupervisorInfo, SupervisorOptions, SupervisorStats, @@ -152,130 +153,131 @@ ) __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", ] diff --git a/aiohasupervisor/models/supervisor.py b/aiohasupervisor/models/supervisor.py index 488e999..7dd00e7 100644 --- a/aiohasupervisor/models/supervisor.py +++ b/aiohasupervisor/models/supervisor.py @@ -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): @@ -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) @@ -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 diff --git a/tests/fixtures/supervisor_info.json b/tests/fixtures/supervisor_info.json index 7bc04d6..d72077a 100644 --- a/tests/fixtures/supervisor_info.json +++ b/tests/fixtures/supervisor_info.json @@ -17,6 +17,7 @@ "auto_update": true, "country": null, "wait_boot": 5, + "detect_blocking_io": false, "addons": [ { "name": "Terminal & SSH", @@ -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" + } ] } } diff --git a/tests/test_supervisor.py b/tests/test_supervisor.py index 1af17b0..4680fd8 100644 --- a/tests/test_supervisor.py +++ b/tests/test_supervisor.py @@ -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 @@ -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( @@ -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 ) @@ -123,6 +130,7 @@ async def test_supervisor_options( "debug": True, "debug_block": True, "country": "NL", + "detect_blocking_io": "on_at_startup", }