feat: Implement real-time rule status updates and dashboard display via WebSockets.

This commit is contained in:
sebseb7
2026-01-18 05:52:54 -05:00
parent a381b0e121
commit e226032d0b
4 changed files with 247 additions and 6 deletions

View File

@@ -4,7 +4,7 @@ import path from 'path';
import sqlite3 from 'sqlite3';
import { fileURLToPath } from 'url';
import { initRuleEngine, loadRules, runRules, watchRules } from './rule_engine.js';
import { broadcastEvent, startStatusServer } from './status_server.js';
import { broadcastEvent, broadcastRuleUpdate, startStatusServer } from './status_server.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
@@ -174,7 +174,7 @@ const wss = new WebSocketServer({ port: 8080 });
console.log('Shelly Agent Server listening on port 8080');
// Initialize and load rules
initRuleEngine(db, sendRPCToDevice);
initRuleEngine(db, sendRPCToDevice, broadcastRuleUpdate);
loadRules().then(() => {
console.log('Rule engine ready');
watchRules(); // Auto-reload rules when files change