Files
INFRAESTRUCTURA/scripts/check_ha_config.py

30 lines
811 B
Python

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"]}')