Fix display refresh rate API endpoint
Some checks failed
Validate / validate (push) Failing after 8s

- Updated get_displays() to use get_available_displays() function from screen_capture module
- Removed duplicate display detection code in routes.py
- Now properly returns refresh_rate field in display API responses
- Removed unused get_monitor_names import

This fixes the "undefinedHz" issue in the Web UI by ensuring the backend properly provides refresh rate data.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-06 17:30:29 +03:00
parent e2a6a41b93
commit 5405e81cba

View File

@@ -29,7 +29,8 @@ from wled_controller.core.calibration import (
calibration_to_dict,
)
from wled_controller.storage import DeviceStore
from wled_controller.utils import get_logger, get_monitor_names
from wled_controller.utils import get_logger
from wled_controller.core.screen_capture import get_available_displays
logger = get_logger(__name__)
@@ -100,30 +101,23 @@ async def get_displays(_: AuthRequired):
logger.info("Listing available displays")
try:
# Import here to avoid issues if mss is not installed yet
import mss
# Get available displays with all metadata (name, refresh rate, etc.)
display_dataclasses = get_available_displays()
# Get friendly monitor names (Windows only, falls back to generic names)
monitor_names = get_monitor_names()
with mss.mss() as sct:
displays = []
# Skip the first monitor (it's the combined virtual screen on multi-monitor setups)
for idx, monitor in enumerate(sct.monitors[1:], start=0):
# Use friendly name from WMI if available, otherwise generic name
friendly_name = monitor_names.get(idx, f"Display {idx}")
display_info = DisplayInfo(
index=idx,
name=friendly_name,
width=monitor["width"],
height=monitor["height"],
x=monitor["left"],
y=monitor["top"],
is_primary=(idx == 0),
# Convert dataclass DisplayInfo to Pydantic DisplayInfo
displays = [
DisplayInfo(
index=d.index,
name=d.name,
width=d.width,
height=d.height,
x=d.x,
y=d.y,
is_primary=d.is_primary,
refresh_rate=d.refresh_rate,
)
displays.append(display_info)
for d in display_dataclasses
]
logger.info(f"Found {len(displays)} displays")