Energy Log, calculation of hourly and daily values

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
lennart49e
Posts: 5
Joined: Thursday 01 December 2016 8:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Energy Log, calculation of hourly and daily values

Post by lennart49e »

I have started to measure my energy consumption using MySensors and pulse-counters.
In Domoticz the counter values are handled as an Energy meter utility, Type: General KWh.
I can in the log for the energy meter see hourly and daily consumption, based on the counter values, as bars in the diagram.
I have also checked the values in the database where the values for the counter are stored with a value for each 5 minute in one table and a value for each 24hour, daily values, in a calender table.
However when I calculate the sum of the hourly values in the bar diagram for a day (24hour) it is less than the daily value. It seems that the counter values for the last 5-min in the hour is not included in the hourly values. I also believe that the counter values for the last 5 min of the day, is not included in the daily value.
Flopp
Posts: 279
Joined: Sunday 03 January 2016 14:55
Target OS: -
Domoticz version:
Location: Sweden
Contact:

Energy Log, calculation of hourly and daily values

Post by Flopp »

5-min graph is not an average, it is only the last value that the Domoticz have when it shall present a value in the 5-min graph. Can that be the "problem"
Graph values not in sync with real values

See more about that here
https://r.tapatalk.com/shareLink?url=ht ... are_type=t
lennart49e
Posts: 5
Joined: Thursday 01 December 2016 8:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Energy Log, calculation of hourly and daily values

Post by lennart49e »

The graph shows the power usage in watt. The issue is about the energy consumption in KWh displayed as bars in the report. The energy consumption for a period is calculated from the counter, as the difference of counter values at the end of the period and the beginning of the period.
I think the counter value that is used for the calculation is not from the end of the period but 5 min earlier.
See also:
viewtopic.php?f=28&t=12096
lennart49e
Posts: 5
Joined: Thursday 01 December 2016 8:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Energy Log, calculation of hourly and daily values

Post by lennart49e »

Have made further investigation and to better show the how consumption values are calculated I have as an example taken the meter data in the database for one day for an Energy consumption meter.
The data have been moved to excel, where I have added some columns to show the calculation. I have also added a summery at the end.
Irrelevant lines in the table have been removed.

Code: Select all


E_VP1; IDX = 420                           
         DeviceRowID   
               Value (Counter)   
                        Date   
                                           Usage               
                                                     Counter value   
                                                              Diff first value in period       
                                                                        Counter value   
                                                                              Diff first value in period
                              
175538   420   253089   2016-11-28 23:50   13170               
175549   420   253199   2016-11-28 23:55   13080      
175560   420   253308   2016-11-29 00:00   13000      253308              253308   
175571   420   253416   2016-11-29 00:05   13230               

175670   420   254315   2016-11-29 00:50   15470               
175681   420   254448   2016-11-29 00:55   16290                          254448   1140
175692   420   254586   2016-11-29 01:00   16520      254586   1278      
175703   420   254721   2016-11-29 01:05   15850               

175802   420   255787   2016-11-29 01:50   12950               
175813   420   255894   2016-11-29 01:55   12930                          255894   1308
175824   420   256007   2016-11-29 02:00   14390      256007   1421      
175835   420   256128   2016-11-29 02:05   14500               

175934   420   257050   2016-11-29 02:50   16640               
175945   420   257188   2016-11-29 02:55   16630                          257188   1181
175956   420   257326   2016-11-29 03:00   16550      257326   1319      
175967   420   257461   2016-11-29 03:05   15350               

176066   420   258551   2016-11-29 03:50   14800               
176077   420   258674   2016-11-29 03:55   14710                          258674   1348
176088   420   258792   2016-11-29 04:00   11730      258792   1466      
176099   420   258837   2016-11-29 04:05   1300               

176198   420   259859   2016-11-29 04:50   14250               
176209   420   259978   2016-11-29 04:55   14160                          259978   1186
176220   420   260095   2016-11-29 05:00   13860      260095   1303      
176231   420   260212   2016-11-29 05:05   14040               

176325   420   261156   2016-11-29 05:50   15430               
176334   420   261285   2016-11-29 05:55   15410                          261285   1190
176343   420   261413   2016-11-29 06:00   15340      261413   1318      
176352   420   261533   2016-11-29 06:05   14140               

176433   420   262446   2016-11-29 06:50   16270               
176442   420   262584   2016-11-29 06:55   16730                          262584   1171
176451   420   262722   2016-11-29 07:00   16560      262722   1309      
176460   420   262860   2016-11-29 07:05   16390               

176541   420   263921   2016-11-29 07:50   11980               
176550   420   263970   2016-11-29 07:55   1300                           263970   1248
176559   420   264009   2016-11-29 08:00   8950         264009   1287      
176568   420   264124   2016-11-29 08:05   16510               

176649   420   265108   2016-11-29 08:50   12040               
176658   420   265185   2016-11-29 08:55   7750                           265185   1176
176667   420   265216   2016-11-29 09:00   5780         265216   1207      
176676   420   265287   2016-11-29 09:05   9980               

176757   420   266245   2016-11-29 09:50   16630               
176766   420   266384   2016-11-29 09:55   16660                          266384   1168
176775   420   266523   2016-11-29 10:00   16510      266523   1307      
176784   420   266661   2016-11-29 10:05   16530               

176865   420   267649   2016-11-29 10:50   6430               
176874   420   267765   2016-11-29 10:55   16650                          267765   1242
176883   420   267903   2016-11-29 11:00   16460      267903   1380      
176892   420   268041   2016-11-29 11:05   16580               

176973   420   269255   2016-11-29 11:50   4240               
176982   420   269299   2016-11-29 11:55   1390                           269299   1396
176991   420   269350   2016-11-29 12:00   11310      269350   1447      
177000   420   269483   2016-11-29 12:05   16600               

177081   420   270726   2016-11-29 12:50   16450               
177090   420   270864   2016-11-29 12:55   16650                          270864   1514
177099   420   271001   2016-11-29 13:00   16430      271001   1651      
177108   420   271080   2016-11-29 13:05   7310               

177189   420   272183   2016-11-29 13:50   16610               
177198   420   272322   2016-11-29 13:55   16680                          272322   1321
177207   420   272460   2016-11-29 14:00   16550      272460   1459      
177216   420   272598   2016-11-29 14:05   16550               

177297   420   273639   2016-11-29 14:50   16490               
177306   420   273777   2016-11-29 14:55   16440                          273777   1317
177315   420   273914   2016-11-29 15:00   16350      273914   1454      
177324   420   274052   2016-11-29 15:05   16500               

177405   420   275105   2016-11-29 15:50   16220               
177414   420   275241   2016-11-29 15:55   16350                          275241   1327
177423   420   275378   2016-11-29 16:00   16450      275378   1464      
177432   420   275514   2016-11-29 16:05   16520               

177513   420   276537   2016-11-29 16:50   16320               
177522   420   276673   2016-11-29 16:55   16160                          276673   1295
177531   420   276811   2016-11-29 17:00   16650      276811   1433      
177540   420   276949   2016-11-29 17:05   16550               

177621   420   278118   2016-11-29 17:50   5120               
177630   420   278149   2016-11-29 17:55   6280                           278149   1338
177639   420   278263   2016-11-29 18:00   16380      278263   1452      
177648   420   278400   2016-11-29 18:05   16360               

177729   420   279638   2016-11-29 18:50   16570               
177738   420   279776   2016-11-29 18:55   16560                          279776   1513
177747   420   279914   2016-11-29 19:00   16640      279914   1651      
177756   420   280052   2016-11-29 19:05   16520               

177837   420   281084   2016-11-29 19:50   16560               
177846   420   281222   2016-11-29 19:55   16500                          281222   1308
177855   420   281360   2016-11-29 20:00   16580      281360   1446      
177864   420   281498   2016-11-29 20:05   16710               

177945   420   282526   2016-11-29 20:50   16420               
177954   420   282664   2016-11-29 20:55   16680                          282664   1304
177963   420   282802   2016-11-29 21:00   16610      282802   1442      
177972   420   282941   2016-11-29 21:05   16700               

178053   420   284112   2016-11-29 21:50   5170               
178062   420   284142   2016-11-29 21:55   5090                           284142   1340
178071   420   284235   2016-11-29 22:00   16280      284235   1433      
178080   420   284373   2016-11-29 22:05   16680               

178161   420   285624   2016-11-29 22:50   16650               
178170   420   285763   2016-11-29 22:55   16670                          285763   1528
178179   420   285857   2016-11-29 23:00   7960         285857   1622      
178188   420   285900   2016-11-29 23:05   1410               
178260   420   286921   2016-11-29 23:45   16730               

178269   420   287060   2016-11-29 23:50   16640               
178278   420   287199   2016-11-29 23:55   16530                          287199   1342
178287   420   287336   2016-11-30 00:00   16330      287336   1479      
178296   420   287471   2016-11-30 00:05   15960      
                                                      Diff last first in this column
                                                               sum hour    
                                                                          Diff last first in this column   
                                                                                   sum hour
                                                      34028   34028       33891   31201



In this example the correct consumption for the whole day is 34028.
That is what the 2 first added columns show.
The added column 3 and 4 calculates the consumption where the end time is 5 minutes to early. These data corresponds with data in the report and also the saved data for the day in Meter_Calendar table.
The daily consumption is here 33891
The sum of the hourly consumption is 31201

Corresponding data Meter_Calendar table :
.......value / Date / counter
847 420 17576 2016-11-27 224940
851 420 28155 2016-11-28 253199
856 420 33891 2016-11-29 287199

It seems that the data in the report and the daily values are not quite correct.
Flopp
Posts: 279
Joined: Sunday 03 January 2016 14:55
Target OS: -
Domoticz version:
Location: Sweden
Contact:

Re: Energy Log, calculation of hourly and daily values

Post by Flopp »

I found an old thread that I wrote, didn't remember!!

https://forum.mysensors.org/topic/4727/ ... t-expected
juankar
Posts: 221
Joined: Saturday 30 August 2014 20:20
Target OS: Linux
Domoticz version: 4.
Location: Spain
Contact:

Re: Energy Log, calculation of hourly and daily values

Post by juankar »

Energy (kWh) utilities can be configured as computed, so the values are calculated by program (wattsxtime). It's more real, I think.
lennart49e
Posts: 5
Joined: Thursday 01 December 2016 8:59
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Energy Log, calculation of hourly and daily values

Post by lennart49e »

Yes, a good idea.
I have a floor heating in my bathroom, where I control the heating from Domoticz. That means Domoticz knows when the heating is on or off. To the heating a dummy meter
is associated, type: “Electric (Instant + counter)”, controlled through LUA-scripts.
The power usage is 155Watt.
That means the theoretical consumption for the heating is:
12,9 Wh for 5 minutes
155 Wh for 1hour
3720Wh for 24hours

[img]
Graph 3Dec.png
Graph 3Dec.png (133.03 KiB) Viewed 2319 times
[/img]


I have here zoomed in 3 dec, that corresponds to the daily consumption for Saturday (Lör).
Some notes:
The power usage during the whole period is 155Watt.
The hourly consumption is about 142Wh
The daily consumption based on hourly values are
139*1 + 140*3 + 142*10 + 143*9 + 145*1 =3407Wh
The daily consumption based on the bar graph (Lör) is 3707Wh

Compare that to the theoretical values.
The theoretical consumption for 1 hour is 155Wh, the bars are about 142Wh missing 13Wh which is 5 minutes consumption.
The theoretical consumption for 24 h shall be 3720Wh
The sum of the hourly values gives 3407Wh. If you add 24*12,9 it is 3717Wh, which is almost as the theoretical value.
The graph for daily consumption is 3707Wh. If you add 12,9Wh for 5 minutes consumption it is 3720Wh, which corresponds exactly with the theoretical value.

My conclusion is that the 5 minutes values are correct in the database, but when calculating the consumption the last 5 minutes in the periode are missing. It is when calculating the hourly consumption and also the daily consumption that is stored in the database.

Could that be the case? And is it a “problem” just for me?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest