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