@@ -306,22 +306,16 @@ async def async_get_screens(self, device_id: int = 0) -> list[NovastarScreen]:
306306 """Get list of screens."""
307307 data = await self ._async_request ("screen/readList" , {"deviceId" : device_id })
308308
309- def _extract_dimension (detail : dict [str , Any ], keys : tuple [str , ...]) -> int :
310- """Extract one dimension from known top-level and nested keys."""
311- for key in keys :
312- value = detail .get (key )
313- if isinstance (value , (int , float )):
314- return int (value )
315-
316- for container_key in ("resolution" , "screen" , "canvas" , "size" ):
317- container = detail .get (container_key )
318- if not isinstance (container , dict ):
319- continue
320- for key in keys :
321- value = container .get (key )
322- if isinstance (value , (int , float )):
323- return int (value )
324-
309+ def _coerce_size_value (value : Any ) -> int :
310+ """Convert size values to int with safe fallback."""
311+ if isinstance (value , bool ):
312+ return 0
313+ if isinstance (value , int ):
314+ return value
315+ if isinstance (value , float ):
316+ return int (value )
317+ if isinstance (value , str ) and value .isdigit ():
318+ return int (value )
325319 return 0
326320
327321 screens = []
@@ -339,14 +333,12 @@ def _extract_dimension(detail: dict[str, Any], keys: tuple[str, ...]) -> int:
339333 width = 0
340334 height = 0
341335 if isinstance (detail , dict ):
342- width = _extract_dimension (
343- detail ,
344- ("width" , "screenWidth" , "pixelWidth" , "canvasWidth" ),
345- )
346- height = _extract_dimension (
347- detail ,
348- ("height" , "screenHeight" , "pixelHeight" , "canvasHeight" ),
349- )
336+ output_mode = detail .get ("outputMode" )
337+ if isinstance (output_mode , dict ):
338+ size = output_mode .get ("size" )
339+ if isinstance (size , dict ):
340+ width = _coerce_size_value (size .get ("width" ))
341+ height = _coerce_size_value (size .get ("height" ))
350342
351343 screens .append (
352344 NovastarScreen (
0 commit comments