Allow saving the empty default notify target

An empty target means notifications are not configured yet and is the
shipped default; only malformed strings (padded or whitespace-only)
reject.
This commit is contained in:
2026-09-19 14:20:13 -04:00
parent 3c832c1cee
commit fbde3eeaa1
2 changed files with 23 additions and 6 deletions
+8 -4
View File
@@ -98,11 +98,15 @@ def _async_validate(user_input: dict[str, Any]) -> dict[str, str]:
):
errors[time_key] = "invalid_time"
notify_target = user_input.get(CONF_NOTIFY_TARGET)
if notify_target is not None and (
not isinstance(notify_target, str)
or not notify_target.strip()
or notify_target != notify_target.strip()
if notify_target is not None and not isinstance(notify_target, str):
errors[CONF_NOTIFY_TARGET] = "invalid"
elif isinstance(notify_target, str) and notify_target != (
notify_target.strip()
):
# An EMPTY target is valid — it means "no notifications
# configured yet" and is the shipped default; a value that
# differs from its own trim (padded or whitespace-only) is
# malformed and rejected.
errors[CONF_NOTIFY_TARGET] = "invalid"
for toggle_key in (
CONF_MORNING_SUMMARY_ENABLED,