From 078c099d51e6e926f00ce389cb683ded50a7ca69 Mon Sep 17 00:00:00 2001 From: 5G7K <60315312+5G7K@users.noreply.github.com> Date: Fri, 21 Mar 2025 21:14:50 +0100 Subject: [PATCH] Issue 273 ignore blockTime + changesMinDelta if val === 0 See Issue https://github.com/ioBroker/ioBroker.sql/issues/273 Small quick fix to always log values if value === 0. Solves problem, that if you log electric power of a solar penal or power of an electric meter of a wallbox, the last value that is logged is often not 0 W. this is because the last value is e.g. 500 W and then 5 seconds later it is 0 W. If you have enabled a blockTime of 20 sec, the last value is alwas 500W. This is confusing in diagrams. Maybe there's a better solution or this new behavior should be activated with an extra check box? --- main.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 7797ee1..ad46b6b 100644 --- a/main.js +++ b/main.js @@ -1180,7 +1180,7 @@ function pushHistory(id, state, timerRelog) { sqlDPs[id].timeout = null; } - if (!valueUnstable && settings.blockTime && sqlDPs[id].state && (sqlDPs[id].state.ts + settings.blockTime) > state.ts) { + if (!valueUnstable && settings.blockTime && sqlDPs[id].state && (sqlDPs[id].state.ts + settings.blockTime) > state.ts && state.val !== 0) { settings.enableDebugLogs && adapter.log.debug(`value ignored blockTime ${id}, value=${state.val}, ts=${state.ts}, lastState.ts=${sqlDPs[id].state.ts}, blockTime=${settings.blockTime}`); return; } @@ -1226,7 +1226,8 @@ function pushHistory(id, state, timerRelog) { if ( sqlDPs[id].state.val !== null && settings.changesMinDelta !== 0 && - Math.abs(sqlDPs[id].state.val - state.val) < settings.changesMinDelta + Math.abs(sqlDPs[id].state.val - state.val) < settings.changesMinDelta && + state.val !== 0 ) { if (!valueUnstable && !settings.disableSkippedValueLogging) { sqlDPs[id].skipped = state;