Skip to content

Commit 6260b01

Browse files
author
Ted Roberts
committed
Fix options layer count control rendering as numeric selector (v0.2.29)
1 parent ed33788 commit 6260b01

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

custom_components/novastar_h/config_flow.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from homeassistant.config_entries import ConfigFlow, FlowResult, OptionsFlow
1010
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT
1111
from homeassistant.core import callback
12+
from homeassistant.helpers import selector
1213

1314
from .api import NovastarClient
1415
from .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
)

custom_components/novastar_h/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@
2121
}
2222
],
2323
"zeroconf": ["_novastar._tcp.local."],
24-
"version": "0.2.28"
24+
"version": "0.2.29"
2525
}

0 commit comments

Comments
 (0)