20-sep: Webhook apagar PC funcionando - callable desde cualquier sitio

This commit is contained in:
juanminsanz
2026-09-20 21:55:09 +02:00
parent 22124e0194
commit 2316b9341a
2 changed files with 205 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import requests
import os
from dotenv import load_dotenv
load_dotenv(r'C:\Users\juanm\Documents\GitHub\biblioteca_negocio_prolongo\.env')
url = os.getenv('HOMEASSISTANT_URL')
token = os.getenv('HOMEASSISTANT_TOKEN')
headers = {
'Authorization': f'Bearer {token}',
'Content-Type': 'application/json'
}
# Verificar estados
response = requests.get(f'{url}/api/states', headers=headers)
states = response.json()
# Buscar automation
automations = [s for s in states if s['entity_id'].startswith('automation.')]
print('Automations encontradas:')
for a in automations:
print(f' - {a["entity_id"]}: {a["state"]}')
# Buscar scripts
scripts = [s for s in states if s['entity_id'].startswith('script.')]
print('\nScripts encontrados:')
for s in scripts:
print(f' - {s["entity_id"]}: {s["state"]}')