Block repeated on while auto-off is active

This commit is contained in:
2026-08-03 01:37:14 +02:00
parent 4ea737024b
commit 6b2bc3853a
8 changed files with 204 additions and 6 deletions
+22 -2
View File
@@ -110,7 +110,9 @@ def camera_group_key(action):
def camera_group_name(action, lang):
return (
action.cfg.get("camera_name")
action.cfg.get("camera_display_name")
or (action.cfg.get("snapshot") or {}).get("camera_display_name")
or action.cfg.get("camera_name")
or (action.cfg.get("snapshot") or {}).get("camera")
or action.cfg.get("device", {}).get("name")
or action.display_name(lang)
@@ -140,6 +142,7 @@ def snapshot_markup_for_group(group, lang, token_query):
actions = group["actions"]
action = next((item for item in actions if item.cfg.get("snapshot")), actions[0])
icons = group_visual_markup(actions, lang)
refresh_label = text_for(lang, "button.refresh_snapshot")
snapshot_markup = (
'<div class="media media-empty">'
f"{icons}"
@@ -157,6 +160,15 @@ def snapshot_markup_for_group(group, lang, token_query):
f'<img class="snapshot" src="{html.escape(snapshot_url)}" '
f'alt="{html.escape(group["name"])}" loading="lazy" '
'onerror="this.parentElement.classList.add(\'media-empty\');this.remove()">'
f'<button class="snapshot-refresh" type="button" title="{html.escape(refresh_label)}" '
f'aria-label="{html.escape(refresh_label)}">'
'<svg viewBox="0 0 24 24" aria-hidden="true">'
'<path d="M20 6v5h-5"></path>'
'<path d="M4 18v-5h5"></path>'
'<path d="M18.6 9A7 7 0 0 0 6.3 6.4L4 8.6"></path>'
'<path d="M5.4 15A7 7 0 0 0 17.7 17.6L20 15.4"></path>'
"</svg>"
"</button>"
f"{icons}"
"</div>"
)
@@ -296,9 +308,17 @@ def render_action_buttons(action, lang, token_query):
' data-requires-ack="true"'
f' data-ack-message="{html.escape(text_for(lang, "ack.siren_on"))}"'
)
disabled_attrs = ""
if command == "on" and getattr(action, "auto_off_at", None):
disabled_label = text_for(lang, "button.on_blocked_timer")
disabled_attrs = (
" disabled"
f' title="{html.escape(disabled_label)}"'
f' aria-label="{html.escape(disabled_label)}"'
)
buttons.append(
f'<form class="command-form" method="post" action="{html.escape(action_url)}"{ack_attrs}>'
f'<button class="cmd cmd-{html.escape(command)}" type="submit">'
f'<button class="cmd cmd-{html.escape(command)}" type="submit"{disabled_attrs}>'
f"<span>{html.escape(label)}</span>"
"</button></form>"
)