99from homeassistant .config_entries import ConfigFlow , FlowResult , OptionsFlow
1010from homeassistant .const import CONF_HOST , CONF_NAME , CONF_PORT
1111from homeassistant .core import callback
12+ from homeassistant .helpers import selector
1213
1314from .api import NovastarClient
1415from .const import (
@@ -350,6 +351,14 @@ async def async_step_init(
350351 DEFAULT_LAYER_SELECT_PREPOPULATE_COUNT ,
351352 ),
352353 )
354+ if isinstance (current_layer_count , bool ):
355+ current_layer_count = DEFAULT_LAYER_SELECT_PREPOPULATE_COUNT
356+ else :
357+ try :
358+ current_layer_count = int (current_layer_count )
359+ except (TypeError , ValueError ):
360+ current_layer_count = DEFAULT_LAYER_SELECT_PREPOPULATE_COUNT
361+ current_layer_count = max (1 , min (16 , current_layer_count ))
353362
354363 return self .async_show_form (
355364 step_id = "init" ,
@@ -361,7 +370,14 @@ async def async_step_init(
361370 vol .Optional (
362371 _OPT_LAYER_COUNT_UI ,
363372 default = current_layer_count ,
364- ): vol .All (vol .Coerce (int ), vol .Range (min = 1 , max = 16 )),
373+ ): selector .NumberSelector (
374+ selector .NumberSelectorConfig (
375+ min = 1 ,
376+ max = 16 ,
377+ step = 1 ,
378+ mode = selector .NumberSelectorMode .BOX ,
379+ )
380+ ),
365381 }
366382 ),
367383 )
0 commit comments