feat(config_flow): digit-delay (0.05–1.0 s, invalid input error) + optional send-enter options UI consumed by the §7 channel path; strings/README updated (P5-2.1)
This commit is contained in:
1 parent
4661e52041
commit
3d026ae60e
4 files changed
+45
-6
No files matched your search
@@ -13,6 +13,7 @@ from .adb_session import ensure_adb_key
|
||||
from .connection import ShieldConnectionManager
|
||||
from .const import (
|
||||
ATTR_MEDIA_DAG_INPUT_MAP,
|
||||
CHANNEL_DIGIT_DELAY,
|
||||
CONF_ADB_COMMAND_ENABLED,
|
||||
CONF_ADB_ENABLED,
|
||||
CONF_ADB_HOST,
|
||||
@@ -20,6 +21,8 @@ from .const import (
|
||||
CONF_ADB_STORE_APP_INFO,
|
||||
CONF_ANDROIDTV_ENTITY,
|
||||
CONF_APP_NAME_MAP,
|
||||
CONF_CHANNEL_DIGIT_DELAY,
|
||||
CONF_CHANNEL_SEND_ENTER,
|
||||
CONF_JELLYFIN_ENTITY,
|
||||
CONF_PAIRING_CODE,
|
||||
CONF_POWER_ENTITY,
|
||||
@@ -497,6 +500,16 @@ class NvidiaShieldOptionsFlow(config_entries.OptionsFlow):
|
||||
"""Single-page options."""
|
||||
errors = {}
|
||||
if user_input is not None:
|
||||
# P5-2: validate the digit delay (0.05–1.0 s, §7 window)
|
||||
delay = user_input.pop(CONF_CHANNEL_DIGIT_DELAY, None)
|
||||
if delay is not None:
|
||||
try:
|
||||
delay = float(delay)
|
||||
except (TypeError, ValueError):
|
||||
errors["base"] = "invalid_digit_delay"
|
||||
delay = None
|
||||
if delay is not None and not (0.05 <= delay <= 1.0):
|
||||
errors["base"] = "invalid_digit_delay"
|
||||
app_map_text = user_input.pop(CONF_APP_NAME_MAP, None)
|
||||
if app_map_text is None:
|
||||
app_map = self._options.get(CONF_APP_NAME_MAP, {})
|
||||
@@ -507,6 +520,8 @@ class NvidiaShieldOptionsFlow(config_entries.OptionsFlow):
|
||||
if app_map is None:
|
||||
errors["base"] = "invalid_app_map"
|
||||
if not errors:
|
||||
if delay is not None:
|
||||
self._options[CONF_CHANNEL_DIGIT_DELAY] = delay
|
||||
self._options.update(user_input)
|
||||
self._options[CONF_APP_NAME_MAP] = app_map
|
||||
return self.async_create_entry(title="", data=self._options)
|
||||
@@ -537,6 +552,12 @@ class NvidiaShieldOptionsFlow(config_entries.OptionsFlow):
|
||||
recv_key = vol.Optional(CONF_RECEIVER_ENTITY, default=recv)
|
||||
schema_dict[recv_key] = sel["receiver"]
|
||||
|
||||
# P5-2: channel digit behavior (the user-validated §7 flow)
|
||||
current_delay = self._options.get(CONF_CHANNEL_DIGIT_DELAY, CHANNEL_DIGIT_DELAY)
|
||||
schema_dict[vol.Optional(CONF_CHANNEL_DIGIT_DELAY, default=current_delay)] = str
|
||||
current_enter = self._options.get(CONF_CHANNEL_SEND_ENTER, False)
|
||||
schema_dict[vol.Optional(CONF_CHANNEL_SEND_ENTER, default=current_enter)] = bool
|
||||
|
||||
# P4-2a: the raw adb_command service is opt-in (default off)
|
||||
current_flag = self._options.get(CONF_ADB_COMMAND_ENABLED, False)
|
||||
schema_dict[vol.Optional(CONF_ADB_COMMAND_ENABLED, default=current_flag)] = bool
|
||||
|
||||
Reference in new issue
Block a user