From bc435b3666cba1e480ff7ac43d0fe19ff941add5 Mon Sep 17 00:00:00 2001 From: juanjo Date: Sun, 6 Sep 2026 13:53:28 +0200 Subject: [PATCH] 06-sep: [menu] seccion Domotica (aspiradora+termo), tablets Ines+Carolina en parental, fin-accion limpia chat + vuelve a /menu --- vigilancia/menu_idd.py | 54 ++++++++++++++++++++++++++++++++++++++++-- vigilancia/pi_bot.py | 17 +++++++++++++ 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/vigilancia/menu_idd.py b/vigilancia/menu_idd.py index 96ec421..d580d45 100644 --- a/vigilancia/menu_idd.py +++ b/vigilancia/menu_idd.py @@ -69,9 +69,12 @@ def teclado_principal(): [ _btn("📺 TV", PREFIJO + "cat:tv"), _btn("👪 Control parental", PREFIJO + "cat:parental"), - _btn("🛠️ Sistema", PREFIJO + "cat:sistema"), + _btn("🏠 Domótica", PREFIJO + "cat:domotica"), + ], + [ + _btn("🛠️ Sistema", PREFIJO + "cat:sistema"), + _btn("📚 Ayuda (texto)", PREFIJO + "acc:ayuda"), ], - [_btn("📚 Ayuda (texto)", PREFIJO + "acc:ayuda")], ]) @@ -103,6 +106,20 @@ def teclado_nas(): _btn("📥 Panel descargas", PREFIJO + "acc:descargas"), _btn("➕ Añadir enlace", PREFIJO + "txt:descargar"), ], + FILA_VOLVER, + ]) + + +def teclado_domotica(): + return _mk([ + [ + _btn("🤖 Aspiradora estado", PREFIJO + "acc:aspiradora:estado"), + _btn("🧹 Aspirar", PREFIJO + "acc:aspiradora:start"), + ], + [ + _btn("⏸️ Pausar", PREFIJO + "acc:aspiradora:pause"), + _btn("🏠 A la base", PREFIJO + "acc:aspiradora:home"), + ], [ _btn("🔌 Termo ON", PREFIJO + "acc:termo:on"), _btn("🔌 Termo OFF", PREFIJO + "acc:termo:off"), @@ -125,6 +142,10 @@ def teclado_tv(): def teclado_parental(): return _mk([ + [ + _btn("🔒 Bloquear tablets", PREFIJO + "acc:tablets:bloquear"), + _btn("🔓 Desbloquear tablets", PREFIJO + "acc:tablets:desbloquear"), + ], [_btn("📋 Listar estado", PREFIJO + "acc:parental_listar")], [ _btn("🔒 Desactivar…", PREFIJO + "sub:desactivar"), @@ -261,6 +282,19 @@ def _disp(chat_id, message_id, comando): _cerrar_menu(chat_id, message_id) +def _fin_accion(chat_id): + """Tras una accion: deja ver el resultado, limpia toda la pantalla + y deja el mensaje para volver al menu.""" + import time as _time + import pi_bot + _time.sleep(4) + try: + pi_bot.limpiar_pantalla(chat_id) + except Exception: + pass + _enviar_nuevo(chat_id, "✅ Hecho. Pulsa /menu para volver al menú.", None) + + # ----------------------------------------------------------------- menu ---- def enviar_menu(chat_id): @@ -277,6 +311,7 @@ def _header(categoria): "nas": "📥 NAS / Descargas", "tv": "📺 TV", "parental": "👪 Control parental", + "domotica": "🏠 Domótica", "sistema": "🛠️ Sistema", "router": "📡 Router ASUS", } @@ -289,6 +324,7 @@ def _abrir_categoria(chat_id, message_id, categoria): "nas": teclado_nas, "tv": teclado_tv, "parental": teclado_parental, + "domotica": teclado_domotica, "sistema": teclado_sistema, "router": teclado_router, } @@ -432,6 +468,20 @@ def _ejecutar_accion(chat_id, message_id, partes): if accion == "termo": _disp(chat_id, message_id, f"termo {sub}") return + if accion == "aspiradora": + if sub in ("estado", "start", "stop", "home", "pause", "locate"): + _disp(chat_id, message_id, f"aspiradora {sub}") + if sub != "estado": + _fin_accion(chat_id) + return + if accion == "tablets": + if sub in ("bloquear", "desbloquear"): + verbo = "desactivar" if sub == "bloquear" else "activar" + pi_bot.procesar(f"parental {verbo} Inés", chat_id) + pi_bot.procesar(f"parental {verbo} Carolina", chat_id) + _cerrar_menu(chat_id, message_id) + _fin_accion(chat_id) + return if accion == "router": mapeo = { "estado": "router estado", diff --git a/vigilancia/pi_bot.py b/vigilancia/pi_bot.py index 39ee162..98b19e7 100644 --- a/vigilancia/pi_bot.py +++ b/vigilancia/pi_bot.py @@ -348,6 +348,20 @@ def _ejecutar_borrado(chat_id, numero): enviar(f"🗑️ Tarea borrada: {titulo[:80]}", chat_id) else: enviar(f"❌ No se pudo borrar {titulo[:60]}: {detalle}", chat_id) + # Cierra el panel de descargas, limpia toda la pantalla y deja + # el mensaje para volver al menu. + try: + estado_panel = panel_descargas.pop(chat_id, None) + if estado_panel and estado_panel.get("message_id"): + borrar(chat_id, estado_panel["message_id"]) + except Exception: + pass + time.sleep(4) + try: + limpiar_pantalla(chat_id) + except Exception: + pass + enviar("✅ Hecho. Pulsa /menu para volver al menú.", chat_id) return True @@ -791,6 +805,9 @@ def procesar(texto, chat_id): " ✏️ Ej: /descargar magnet:?xt=urn:btih:...\n" "10. termo on|off|estado — controla el enchufe Tapo\n" " ✏️ Ej: /termo estado\n\n" + "━━━ 🏠 DOMÓTICA ━━━\n" + "10b. aspiradora estado|start|stop|home|pause|locate — Dreame D10 Plus\n" + " ✏️ Ej: /aspiradora estado\n\n" "━━━ 📺 TV ━━━\n" "11. tv <mensaje> — mensaje rápido a la tele\n" " ✏️ Ej: /tv la cena está lista\n"