u
This commit is contained in:
17
uiserver/debug_db.js
Normal file
17
uiserver/debug_db.js
Normal file
@@ -0,0 +1,17 @@
|
||||
const Database = require('better-sqlite3');
|
||||
const path = require('path');
|
||||
|
||||
const dbPath = path.resolve(__dirname, '../server/data/sensors.db');
|
||||
const db = new Database(dbPath, { readonly: true });
|
||||
|
||||
console.log('--- RULES ---');
|
||||
const rules = db.prepare('SELECT * FROM rules').all();
|
||||
console.log(JSON.stringify(rules, null, 2));
|
||||
|
||||
console.log('\n--- OUTPUT CHANNELS ---');
|
||||
const outputs = db.prepare("SELECT * FROM output_events WHERE channel = 'CircFanLevel' ORDER BY timestamp DESC LIMIT 10").all();
|
||||
console.table(outputs);
|
||||
|
||||
console.log('\n--- SENSOR DATA (ac:tent:temperature) ---');
|
||||
const sensors = db.prepare("SELECT * FROM sensor_events WHERE device = 'ac' AND channel = 'tent:temperature' ORDER BY timestamp DESC LIMIT 5").all();
|
||||
console.table(sensors);
|
||||
@@ -297,10 +297,15 @@ function syncOutputStates() {
|
||||
if (row.value > 0) {
|
||||
const binding = OUTPUT_BINDINGS[row.channel];
|
||||
if (binding) {
|
||||
let commandValue = row.value;
|
||||
if (binding.type === 'switch') {
|
||||
commandValue = row.value > 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
const success = sendCommandToDevicePrefix(`${binding.device}:`, {
|
||||
device: binding.channel,
|
||||
action: 'set_state',
|
||||
value: 1
|
||||
value: commandValue
|
||||
});
|
||||
|
||||
if (!success) {
|
||||
@@ -747,9 +752,7 @@ module.exports = {
|
||||
`);
|
||||
const last = lastStmt.get(channel);
|
||||
|
||||
if (channel === 'CircFanLevel') {
|
||||
console.log('[RuleRunner] Debug Bindings:', JSON.stringify(OUTPUT_BINDINGS['CircFanLevel']));
|
||||
}
|
||||
// Debug log removed
|
||||
|
||||
const valueChanged = !last || Math.abs(last.value - value) >= Number.EPSILON;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user