Initial commit: HA Voice Control MCP server
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
"""Gerichte database check: dashboard data + Neo4j"""
|
||||
import os, sys, json
|
||||
os.environ["PG_HOST"] = "192.168.1.211"
|
||||
os.environ["PG_PORT"] = "5433"
|
||||
os.environ["PG_USER"] = "mo"
|
||||
os.environ["PG_PASSWORD"] = "WaQTUw2t"
|
||||
os.environ["PG_DATABASE"] = "homelab"
|
||||
os.environ["NEO4J_URI"] = "neo4j://192.168.1.211:49153"
|
||||
os.environ["NEO4J_USER"] = "neo4j"
|
||||
os.environ["NEO4J_PASSWORD"] = "WaQTUw2t"
|
||||
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
# Fix encoding
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
print("=" * 70)
|
||||
print("DASHBOARD DATA (PostgreSQL)")
|
||||
print("=" * 70)
|
||||
|
||||
from src.pg_client import query
|
||||
|
||||
# Favorites
|
||||
print("\n--- FAVORITES (20 rows) ---")
|
||||
rows = query("SELECT id, title, url, icon, category, sort_order, is_pinned FROM dashboard.favorites ORDER BY is_pinned DESC, sort_order")
|
||||
for r in rows:
|
||||
pinned = "📌" if r['is_pinned'] else " "
|
||||
print(f" {pinned} [{r['id']}] {r['title']:<30} | {r['url']:<45} | {r['category']}")
|
||||
|
||||
# Settings
|
||||
print("\n--- SETTINGS (5 rows) ---")
|
||||
rows = query("SELECT * FROM dashboard.settings ORDER BY key")
|
||||
for r in rows:
|
||||
print(f" {r['key']:<25} = {r['value']}")
|
||||
|
||||
# Passwords
|
||||
print("\n--- PASSWORDS ---")
|
||||
rows = query("SELECT count(*) as c FROM dashboard.passwords", fetch="one")
|
||||
print(f" Count: {rows['c']}")
|
||||
|
||||
# Calendar
|
||||
print("\n--- CALENDAR ---")
|
||||
rows = query("SELECT count(*) as c FROM dashboard.calendar_events", fetch="one")
|
||||
print(f" Count: {rows['c']}")
|
||||
|
||||
# Files
|
||||
print("\n--- FILE INDEX ---")
|
||||
rows = query("SELECT count(*) as c FROM dashboard.file_index", fetch="one")
|
||||
print(f" Count: {rows['c']}")
|
||||
|
||||
# Photos
|
||||
print("\n--- PHOTOS ---")
|
||||
rows = query("SELECT count(*) as c FROM dashboard.photos", fetch="one")
|
||||
print(f" Count: {rows['c']}")
|
||||
|
||||
# Widgets
|
||||
print("\n--- WIDGETS ---")
|
||||
rows = query("SELECT count(*) as c FROM dashboard.dashboard_widgets", fetch="one")
|
||||
print(f" Count: {rows['c']}")
|
||||
|
||||
# ── NEO4J ──────────────────────────────────────────────────────
|
||||
print("\n" + "=" * 70)
|
||||
print("NEO4J NETWERK DATA")
|
||||
print("=" * 70)
|
||||
|
||||
from src.neo4j_client import get_driver, get_all_devices, get_scan_history, get_network_summary, close
|
||||
|
||||
try:
|
||||
devices = get_all_devices()
|
||||
print(f"\nDevices: {len(devices)}")
|
||||
for d in devices:
|
||||
ports = sorted([p.get('port') for p in (d.get('ports') or []) if p and p.get('port')])
|
||||
print(f" {d['ip']:<16} {d.get('hostname','')[:35]:<35} {d.get('os_guess','')[:28]:<28} ports={ports}")
|
||||
|
||||
print("\n--- Scan History ---")
|
||||
for s in get_scan_history():
|
||||
print(f" {s['id']} @ {s.get('timestamp','?')} — {s.get('hosts_active','?')} hosts")
|
||||
|
||||
print("\n--- Summary ---")
|
||||
s = get_network_summary()
|
||||
print(f" Total devices: {s.get('total_devices','?')}")
|
||||
print(f" Unique ports: {s.get('total_ports','?')}")
|
||||
os_types = s.get('os_types', [])
|
||||
from collections import Counter
|
||||
for os_t, cnt in Counter(os_types).most_common():
|
||||
print(f" {os_t}: {cnt}")
|
||||
|
||||
close()
|
||||
except Exception as e:
|
||||
print(f"Neo4j ERROR: {e}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
print("\nDONE.")
|
||||
Reference in New Issue
Block a user