[gelöst] mal wieder unerwartete Ergebnisse bei DBrep diffvalue

Begonnen von Nighthawk, 14 Mai 2024, 20:59:36

Vorheriges Thema - Nächstes Thema

Nighthawk

Hallo zusammen,

leider bekomme ich mal wieder nach dem Durchführen von diffValue nicht das rechnerisch korrekte Ergebnis.

Die MariaDB Version ist: 10.11.7-MariaDB-2ubuntu2 Ubuntu 24.04

Der Erste Wert im April ist 19280.49578266 und der letzte ist 19646.42993674, also müsste das Ergebnis ~365.934 betragen, was auch einem realistischen Wert entspricht, ich bekomme allerdings 1550.8313 als Ergebnis, was mehr als faktor 4 zu hoch ist.

Interessanter Weise werden die Monate davor korrekt berechnet, daher habe ich in der DB geschaut ob es Ausreißer gibt die kleiner 19280.49578266 oder größer 19646.42993674 in dem Monat existieren, das ist nicht der Fall:

select * from history where device="Stromzaehler" and reading = "total_consumption" and value > 19646.42993674 and timestamp like "2024-04%";
Empty set (5.042 sec)

select * from history where device="Stromzaehler" and reading = "total_consumption" and value < 19280 and timestamp like "2024-04%";
Empty set (5.008 sec)

Hier ist das verbose5 log, natürlich stark gekürzt (original hat ~600000 Zeilen..):

2024.05.14 20:31:41 4: DbRep Rep.Monatsverbrauch.Strom - -------- New selection ---------
2024.05.14 20:31:41 4: DbRep Rep.Monatsverbrauch.Strom - Command: diffValue writeToDB
2024.05.14 20:31:41 4: DbRep Rep.Monatsverbrauch.Strom - FullDay option: 0
2024.05.14 20:31:41 5: DbRep Rep.Monatsverbrauch.Strom - Timestamp begin epocheseconds: 1711922400
2024.05.14 20:31:41 4: DbRep Rep.Monatsverbrauch.Strom - Timestamp begin human readable: 2024-04-01 00:00:00
2024.05.14 20:31:41 5: DbRep Rep.Monatsverbrauch.Strom - Timestamp end epocheseconds: 1714514399
2024.05.14 20:31:41 4: DbRep Rep.Monatsverbrauch.Strom - Timestamp end human readable: 2024-04-30 23:59:59
2024.05.14 20:31:41 5: DbRep Rep.Monatsverbrauch.Strom - act year:  2024, act month: 04, days in month: 30
2024.05.14 20:31:41 5: DbRep Rep.Monatsverbrauch.Strom - Daylight savings changed: 0 (from "Mon Apr  1 00:00:00 2024" to "Wed May  1 00:00:00 2024")
2024.05.14 20:31:41 4: DbRep Rep.Monatsverbrauch.Strom - Aggregation: month
2024.05.14 20:31:41 5: DbRep Rep.Monatsverbrauch.Strom - BlockingCall with PID "1636504" started
2024.05.14 20:31:41 4: DbRep Rep.Monatsverbrauch.Strom - Database Model: MYSQL
2024.05.14 20:31:41 4: DbRep Rep.Monatsverbrauch.Strom - Database connect - user: fhemDB, UTF-8 option set: yes
2024.05.14 20:31:41 4: DbRep Rep.Monatsverbrauch.Strom - SQL execute: SHOW VARIABLES LIKE 'collation_database'
2024.05.14 20:31:41 4: DbRep Rep.Monatsverbrauch.Strom - Database Character set is >utf8mb3_bin<
2024.05.14 20:31:41 4: DbRep Rep.Monatsverbrauch.Strom - simple do statement: set names "utf8mb3" collate "utf8mb3_bin"
2024.05.14 20:31:41 5: DbRep Rep.Monatsverbrauch.Strom - IsTimeSet: 1, IsAggrSet: 1
2024.05.14 20:31:41 5: DbRep Rep.Monatsverbrauch.Strom - Timestamp-Array:
2024.05.14 20:31:41 5: DbRep Rep.Monatsverbrauch.Strom - Devices for operation -
2024.05.14 20:31:41 5: DbRep Rep.Monatsverbrauch.Strom - Readings for operation -
2024.05.14 20:31:41 4: DbRep Rep.Monatsverbrauch.Strom - SQL execute: SELECT TIMESTAMP,VALUE FROM history where ( DEVICE = 'Stromzaehler' ) AND ( READING = 'total_consumption' ) AND TIMESTAMP >= '2024-04-01' AND TIMESTAMP <= '2024-04-30 23:59:59' ORDER BY TIMESTAMP;
2024.05.14 20:31:43 5: DbRep Rep.Monatsverbrauch.Strom - data of row_array result assigned to fields:
2024.05.14 20:31:43 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-01_00:00:04, VALUE: 19280.49578266, DIFF: 0
2024.05.14 20:31:43 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-01_00:00:09, VALUE: 19280.49666019, DIFF: 0.000877530001162086
2024.05.14 20:31:43 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-01_00:00:14, VALUE: 19280.49752623, DIFF: 0.000866039998072665
2024.05.14 20:31:43 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-01_00:00:19, VALUE: 19280.49841448, DIFF: 0.000888250000571134
2024.05.14 20:31:43 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-01_00:00:24, VALUE: 19280.49929763, DIFF: 0.000883149998117005
2024.05.14 20:31:43 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-01_00:00:29, VALUE: 19280.50019486, DIFF: 0.000897230002010474
2024.05.14 20:31:43 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-01_00:00:34, VALUE: 19280.50109536, DIFF: 0.000900499999261228
2024.05.14 20:31:43 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-01_00:00:39, VALUE: 19280.50198603, DIFF: 0.000890670002263505
.
.
.
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-30_23:58:50, VALUE: 19646.42048626, DIFF: 0.000727200000255834
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-30_23:58:55, VALUE: 19646.42121203, DIFF: 0.000725769998098258
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-30_23:59:00, VALUE: 19646.42194152, DIFF: 0.000729489998775534
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-30_23:59:05, VALUE: 19646.42266971, DIFF: 0.000728189999790629
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-30_23:59:10, VALUE: 19646.42339546, DIFF: 0.000725750000128755
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-30_23:59:15, VALUE: 19646.42412227, DIFF: 0.000726810001651756
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-30_23:59:20, VALUE: 19646.42484861, DIFF: 0.000726340000255732
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-30_23:59:25, VALUE: 19646.42557595, DIFF: 0.000727340000594268
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-30_23:59:30, VALUE: 19646.42630304, DIFF: 0.000727089998690644
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-30_23:59:35, VALUE: 19646.42703095, DIFF: 0.000727909999113763
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-30_23:59:40, VALUE: 19646.42775619, DIFF: 0.000725240002793726
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-30_23:59:45, VALUE: 19646.42848113, DIFF: 0.000724939996871399
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-30_23:59:50, VALUE: 19646.42920896, DIFF: 0.000727829999959795
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - Runtimestring: 2024-04, DEVICE: Stromzaehler, READING: total_consumption, TIMESTAMP: 2024-04-30_23:59:55, VALUE: 19646.42993674, DIFF: 0.000727780003217049
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom - print result of diffValue calculation before encoding ...
2024.05.14 20:31:48 4: DbRep Rep.Monatsverbrauch.Strom - count of values used for calc:
2024.05.14 20:31:48 4: DbRep Rep.Monatsverbrauch.Strom - Database Model: MYSQL
2024.05.14 20:31:48 4: DbRep Rep.Monatsverbrauch.Strom - Database connect - user: fhemDB, UTF-8 option set: yes
2024.05.14 20:31:48 4: DbRep Rep.Monatsverbrauch.Strom - SQL execute: SHOW VARIABLES LIKE 'collation_database'
2024.05.14 20:31:48 4: DbRep Rep.Monatsverbrauch.Strom - Database Character set is >utf8mb3_bin<
2024.05.14 20:31:48 4: DbRep Rep.Monatsverbrauch.Strom - simple do statement: set names "utf8mb3" collate "utf8mb3_bin"
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom -> Primary Key used in fhem_long.history: 1 (TIMESTAMP,DEVICE,READING)
2024.05.14 20:31:48 5: DbRep Rep.Monatsverbrauch.Strom -> Primary Key used in fhem_long.current: 0 (none)
2024.05.14 20:31:48 4: DbRep Rep.Monatsverbrauch.Strom - SQL prepare: INSERT IGNORE INTO history (TIMESTAMP, DEVICE, TYPE, EVENT, READING, VALUE, UNIT) VALUES (?,?,?,?,?,?,?)
2024.05.14 20:31:48 4: DbRep Rep.Monatsverbrauch.Strom - SQL prepare: UPDATE history SET TIMESTAMP=?, DEVICE=?, READING=?, TYPE=?, EVENT=?, VALUE=?, UNIT=? WHERE TIMESTAMP=? AND DEVICE=? AND READING=?
2024.05.14 20:31:48 4: DbRep Rep.Monatsverbrauch.Strom - SQL prepare: INSERT INTO current (TIMESTAMP, DEVICE, TYPE, EVENT, READING, VALUE, UNIT) VALUES (?,?,?,?,?,?,?)
2024.05.14 20:31:48 4: DbRep Rep.Monatsverbrauch.Strom - SQL prepare: UPDATE current SET TIMESTAMP=?, DEVICE=?, READING=?, TYPE=?, EVENT=?, VALUE=?, UNIT=? WHERE TIMESTAMP=? AND DEVICE=? AND READING=?
2024.05.14 20:31:48 4: DbRep Rep.Monatsverbrauch.Strom - begin transaction
2024.05.14 20:31:48 4: DbRep Rep.Monatsverbrauch.Strom - UPDATE history: 2024-04-30 23:59:55|Stromzaehler|OBIS|calculated|diff_month_total_consumption|1550.8313|, RESULT: 0
2024.05.14 20:31:49 4: DbRep Rep.Monatsverbrauch.Strom - INSERT history: 2024-04-30 23:59:55|Stromzaehler|OBIS|calculated|diff_month_total_consumption|1550.8313|, RESULT: 1
2024.05.14 20:31:49 4: DbRep Rep.Monatsverbrauch.Strom - transaction committed
2024.05.14 20:31:49 3: DbRep Rep.Monatsverbrauch.Strom - number of lines updated in >logdb_long<: 0
2024.05.14 20:31:49 3: DbRep Rep.Monatsverbrauch.Strom - number of lines inserted into >logdb_long<: 1
2024.05.14 20:31:49 5: DbRep Rep.Monatsverbrauch.Strom - BlockingCall PID "163650



DS_Starter

ZitatInteressanter Weise werden die Monate davor korrekt berechnet, daher habe ich in der DB geschaut ob es Ausreißer gibt ....
Da bin ich mir nicht so sicher.
DiffValue ist die Summe der Einzeldifferenzen im Aggregationszeitraum.
Da deine Einzeldifferenzen äußerst! gering sind; das kommt durch das 5-Sekunden Meßintervall; könnte es sich lohnen das Attr diffAccept zu nutzen.

Vorschlag: Setze diffAccept = 0.5

Und führe die Abfrage erneut aus. Sollte es Differenzen zwischen den Messwerten > 0.5 geben, würde DbRep dies bemerken und das Reading Reading diff_overrun_limit_<Schwellenwert> setzen bzw. mit verbose 3 im Log protokollieren.
Das wäre ein Analyseansatz.
ESXi@NUC+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

Nighthawk

Bei dem Wert 0.5 bekomme ich eine Fehlermeldung:
The Value of diffAccept is not valid. Use only figures 0-9 without decimal places !

DS_Starter

ESXi@NUC+Debian+MariaDB, PV: SMA, Victron MPII+Pylontech+CerboGX
Maintainer: SSCam, SSChatBot, SSCal, SSFile, DbLog/DbRep, Log2Syslog, SolarForecast,Watches, Dashboard, PylonLowVoltage
Kaffeekasse: https://www.paypal.me/HMaaz
Contrib: https://svn.fhem.de/trac/browser/trunk/fhem/contrib/DS_Starter

Nighthawk

Stranges Thema, diffAccept = 1 hat eine Warnung ausgegeben und hat gezeigt dass an einem Tag 2 Stundenlang die Werte nicht plausibel waren.
Ich habe mir die 2 Stunden in der DB angeschaut und dort springen die Werte rauf und runter, da hat wohl der Zähler ziemlichen Mist herausgegeben.
Nach dem bereinigen und erneutem Ausführen von DBRep bekomme ich nun das erwartete Ergebnis.
Also kein DBRep Thema, aber dennoch danke Heiko für den Hinweis der zum tatsächlichen Problem geführt hat  :) !


Gruß
Alex