From 983c1a8bae09b62055b08c8895bd245a909d9805 Mon Sep 17 00:00:00 2001 From: juanminsanz Date: Sun, 20 Sep 2026 16:37:53 +0200 Subject: [PATCH] =?UTF-8?q?20-sep:=20[automatizacion]=20Morning=20routine?= =?UTF-8?q?=20(Tapo=20+=20WoL=20+=20AutoLogon=20+=20Apertura=20de=20pesta?= =?UTF-8?q?=C3=B1as)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/morning_routine/arranque_apps.ps1 | 27 +++++++++++++++ scripts/morning_routine/enable_autologon.ps1 | 22 ++++++++++++ scripts/morning_routine/rpi_despierta_pc.py | 36 ++++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 scripts/morning_routine/arranque_apps.ps1 create mode 100644 scripts/morning_routine/enable_autologon.ps1 create mode 100644 scripts/morning_routine/rpi_despierta_pc.py diff --git a/scripts/morning_routine/arranque_apps.ps1 b/scripts/morning_routine/arranque_apps.ps1 new file mode 100644 index 0000000..7ff638f --- /dev/null +++ b/scripts/morning_routine/arranque_apps.ps1 @@ -0,0 +1,27 @@ +# scripts/morning_routine/arranque_apps.ps1 +# Tarea que se lanza automaticamente 1 minuto despues de iniciar sesion en Windows + +Write-Host "Iniciando Morning Routine..." + +# 1. Abrir WhatsApp (App de Windows Store) +Write-Host "Abriendo WhatsApp..." +Start-Process "whatsapp:" + +# 2. Abrir Telegram Desktop +Write-Host "Abriendo Telegram..." +$telegramPath = "$env:APPDATA\Telegram Desktop\Telegram.exe" +if (Test-Path $telegramPath) { + Start-Process $telegramPath +} + +# 3. Abrir Microsoft Edge con pestañas de Jira +Write-Host "Abriendo Jira en Edge..." +$edgeUrls = "https://prolongo.atlassian.net/jira/software/c/projects/DK/boards/2", "https://prolongo.atlassian.net/jira/software/c/projects/DS/boards/3" +Start-Process "msedge.exe" -ArgumentList $edgeUrls + +# 4. Abrir Google Chrome con Correo y Calendario +Write-Host "Abriendo Gmail y Calendar en Chrome..." +$chromeUrls = "https://mail.google.com/mail/u/0/#inbox", "https://calendar.google.com/calendar/u/0/r" +Start-Process "chrome.exe" -ArgumentList $chromeUrls + +Write-Host "Rutina completada. ¡Buenos días!" diff --git a/scripts/morning_routine/enable_autologon.ps1 b/scripts/morning_routine/enable_autologon.ps1 new file mode 100644 index 0000000..906684e --- /dev/null +++ b/scripts/morning_routine/enable_autologon.ps1 @@ -0,0 +1,22 @@ +param( + [Parameter(Mandatory=$true, HelpMessage="Introduce la contrasena/PIN de Windows")] + [string]$Password +) + +# Detectar usuario actual +$username = $env:USERNAME +$domain = $env:USERDOMAIN + +$winlogonPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" + +try { + Set-ItemProperty -Path $winlogonPath -Name "AutoAdminLogon" -Value "1" + Set-ItemProperty -Path $winlogonPath -Name "DefaultUserName" -Value $username + Set-ItemProperty -Path $winlogonPath -Name "DefaultPassword" -Value $Password + Set-ItemProperty -Path $winlogonPath -Name "DefaultDomainName" -Value $domain + + Write-Host "[OK] AutoLogon habilitado correctamente para $domain\$username." -ForegroundColor Green + Write-Host "Al encenderse, el PC entrara directo a este escritorio sin pedir clave." -ForegroundColor Cyan +} catch { + Write-Host "[ERROR] Necesitas ejecutar este script como Administrador." -ForegroundColor Red +} diff --git a/scripts/morning_routine/rpi_despierta_pc.py b/scripts/morning_routine/rpi_despierta_pc.py new file mode 100644 index 0000000..4cc6fed --- /dev/null +++ b/scripts/morning_routine/rpi_despierta_pc.py @@ -0,0 +1,36 @@ +import os +import time +import asyncio +from wakeonlan import send_magic_packet +from plugp100.api.tapo_client import TapoClient +from plugp100.api.plug_device import PlugDevice + +# Credenciales de TAPO (leer del entorno en la Raspberry) +TAPO_USER = os.getenv("TAPO_USER") +TAPO_PASS = os.getenv("TAPO_PASS") +TAPO_IP = os.getenv("TAPO_IP") # La IP local del enchufe Tapo + +# MAC detectada de la placa base del sobremesa +PC_MAC = "74-56-3C-CB-0E-CE" + +async def main(): + print("1. Encendiendo monitor via Tapo...") + try: + client = TapoClient(TAPO_USER, TAPO_PASS) + device = PlugDevice(client, TAPO_IP) + await device.login() + await device.turn_on() + print(" -> Enchufe Tapo encendido correctamente.") + except Exception as e: + print(f" -> Error al encender Tapo: {e}") + + print("2. Esperando 3 segundos para estabilidad eléctrica...") + time.sleep(3) + + print(f"3. Enviando paquete Wake-On-LAN al PC (MAC: {PC_MAC})...") + # Broadcast global para asegurar que llega de la 192.168.50.x a la 192.168.1.x + send_magic_packet(PC_MAC, ip_address='255.255.255.255') + print(" -> Comando de arranque enviado con éxito.") + +if __name__ == "__main__": + asyncio.run(main())