Controller: move hotspot settings to controller.yaml with WiFi device dropdown.

Hotspot was reported as "not supported" on x86 machines (Ubuntu/Debian PCs)
because the Controller only watched the hardcoded default wlan0 device, while
predictable interface naming produces names like wlp2s0. The Settings page
saved hotspot_device to wrolpi.yaml, which the Controller never read.

The Controller now owns hotspot settings in controller.yaml:

* New endpoints: GET/POST /api/hotspot/settings, GET /api/hotspot/devices
  (WiFi interfaces discovered via nmcli).
* Legacy hotspot_* values in wrolpi.yaml are migrated into controller.yaml
  once on startup, unless controller.yaml already sets them.
* The Hotspot SSID/password/device fields moved from the Settings page to the
  Control page next to the Hotspot toggle; the device is now a dropdown of
  the WiFi devices found on the machine.
* The Controller fallback UI gets the same hotspot settings form for parity.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Roland 2026-07-04 08:22:24 -06:00 • committed by lrnselfreliance
parent ebbc60992c
commit 0d2c13e4e7
12 changed files with 586 additions and 89 deletions

View file

@ -8,6 +8,9 @@ from controller.api.schemas import (
BluetoothActionResponse,
BluetoothStatusResponse,
HotspotActionResponse,
HotspotDevicesResponse,
HotspotSettingsRequest,
HotspotSettingsResponse,
HotspotStatusResponse,
RestartServicesResponse,
SambaShareAddRequest,
@ -30,13 +33,18 @@ from controller.lib.admin import (
enable_hotspot,
enable_throttle,
get_bluetooth_status_dict,
get_hotspot_device,
get_hotspot_password,
get_hotspot_ssid,
get_hotspot_status_dict,
get_throttle_status_dict,
get_timezone_status_dict,
get_wifi_devices,
reboot_system,
restart_all_services,
set_timezone,
shutdown_system,
update_hotspot_settings,
)
from controller.lib.config import is_docker_mode
from controller.lib.samba import (
@ -56,6 +64,33 @@ async def hotspot_status() -> HotspotStatusResponse:
return HotspotStatusResponse(**get_hotspot_status_dict())
@router.get("/api/hotspot/devices", response_model=HotspotDevicesResponse)
async def hotspot_devices() -> HotspotDevicesResponse:
"""List WiFi devices which could host the hotspot."""
return HotspotDevicesResponse(devices=get_wifi_devices())
@router.get("/api/hotspot/settings", response_model=HotspotSettingsResponse)
async def hotspot_settings() -> HotspotSettingsResponse:
"""Get WiFi hotspot settings."""
return HotspotSettingsResponse(
device=get_hotspot_device(),
ssid=get_hotspot_ssid(),
password=get_hotspot_password(),
)
@router.post("/api/hotspot/settings", response_model=HotspotSettingsResponse)
async def hotspot_settings_update(request: HotspotSettingsRequest) -> HotspotSettingsResponse:
"""Update WiFi hotspot settings; they are saved in controller.yaml."""
result = update_hotspot_settings(device=request.device, ssid=request.ssid, password=request.password)
if not result.get("success"):
error = result.get("error", "Failed")
status_code = 500 if "Docker" in error else 400
raise HTTPException(status_code=status_code, detail=error)
return HotspotSettingsResponse(device=result["device"], ssid=result["ssid"], password=result["password"])
@router.post("/api/hotspot/enable", response_model=HotspotActionResponse)
async def hotspot_enable() -> HotspotActionResponse:
"""Enable WiFi hotspot."""