02-ago: [proyecto] vigilancia - comando tv_mensaje.py (mensaje parametrizado) + API remota tv_api.py (puerto 8600, via Tailscale) + fix espera FINISHED + AGENTS.md comando tv y Regla 23

This commit is contained in:
minguezsanzjuanjose
2026-08-02 14:45:54 +02:00
parent e31478efc6
commit c15800fb10
5 changed files with 96 additions and 8 deletions

View File

@@ -109,8 +109,8 @@ def _esperar_reproduccion(cast, timeout=15):
return False
def _esperar_fin(cast, timeout=90):
"""Espera a que termine (IDLE) despues de haber empezado a reproducir."""
def _esperar_fin(cast, timeout=120):
"""Espera a que el audio termine de verdad (IDLE + idle_reason FINISHED)."""
mc = cast.media_controller
t0 = time.time()
visto_playing = False
@@ -119,15 +119,12 @@ def _esperar_fin(cast, timeout=90):
st = mc.status
if st.player_state == "PLAYING":
visto_playing = True
if st.player_state == "IDLE":
if st.idle_reason == "FINISHED":
return True
if visto_playing:
return True
if st.player_state == "IDLE" and st.idle_reason == "FINISHED":
return True
except Exception:
pass
time.sleep(1)
return False
return visto_playing
def _generar_pitido():