02-ago: [proyecto] vigilancia - bot Telegram de la Pi (estado/temp/tv/alarma) + tv_api modo simple + deploy en Raspberry Pi minipc
This commit is contained in:
@@ -320,3 +320,38 @@ def anuncio_en_teles(texto):
|
||||
|
||||
def reproducir_en_teles(texto):
|
||||
anuncio_en_teles(texto)
|
||||
|
||||
|
||||
def anuncio_simple(texto):
|
||||
"""Mensaje rapido: enciende, reproduce el mensaje una vez y apaga."""
|
||||
if not config.GOOGLE_TV_ACTIVO:
|
||||
return
|
||||
url_mensaje, tipo = _url_audio(texto)
|
||||
if url_mensaje is None:
|
||||
return
|
||||
try:
|
||||
import pychromecast
|
||||
|
||||
chromecasts, browser = pychromecast.get_chromecasts(timeout=8)
|
||||
try:
|
||||
if config.GOOGLE_TV_NOMBRES:
|
||||
objetivos = [c for c in chromecasts
|
||||
if c.cast_info.friendly_name in config.GOOGLE_TV_NOMBRES]
|
||||
else:
|
||||
objetivos = chromecasts
|
||||
for c in objetivos:
|
||||
try:
|
||||
c.wait(timeout=10)
|
||||
c.set_volume(config.GOOGLE_TV_VOLUMEN / 100.0)
|
||||
_reproducir_y_esperar(
|
||||
c, url_mensaje, tipo, texto[:80],
|
||||
f"Mensaje simple en {c.cast_info.friendly_name}")
|
||||
if config.GOOGLE_TV_APAGAR_VIA_ADB:
|
||||
from tv_adb import apagar_tv
|
||||
apagar_tv()
|
||||
except Exception as e:
|
||||
print(f"[Voz] Error en {c.cast_info.friendly_name}: {e}")
|
||||
finally:
|
||||
pychromecast.discovery.stop_discovery(browser)
|
||||
except Exception as e:
|
||||
print(f"[Voz] Error de casting: {e}")
|
||||
|
||||
Reference in New Issue
Block a user