Page 1 of 2
Daily Energy Report
Posted: Wednesday 25 May 2016 21:54
by juankar
I've a Qubino ZMNHBD2 and with the proper config file and associations Works fine. It send power report properly and so.
But I've seen that Energy Meter is not good.
I would to know how the daily Energy Power consumtion is calculated? it it's calculated by Domoticz or by OpenZwave or by the device (firmware)?
Thanks
Re: Daily Energy Report
Posted: Thursday 26 May 2016 17:51
by juankar
Add some info.
I have seen that Domoticz (or zwave or...?) calculates daily energy usage by substract last reading from actual Reading. That's if last Reading was 1,4 kwh and today it's 1,5 then daily usage is 0,1 kwh. But if today the usage is 0,08 kwh then the result is 0 kwh because the meter reports just one decimal. It cannot manage 1,48, ti is reported as 1,4.
I would like how or in what file is the code to do this calculation. I think this data (kWh usage) can be calculated using watts meter and time, so it would be more accurate.
Re: Daily Energy Report
Posted: Thursday 26 May 2016 18:06
by gizmocuz
we use the counter value of the meter, that is the only accurate way to calculate
Last counter value <minus> first counter value of the day <equals> total usage
Re: Daily Energy Report
Posted: Thursday 26 May 2016 18:56
by juankar
It's a very good solution, the code for this is in mainworker.cpp, isn't it?
But the problem appears when you consum less than precission of device. I think 0.1 is a very lo precission value. Today there is a lot of lights like LEDS or Ecologic bulbs and so, with very low values for energy usage. Philio uses 2 decimals, that's better. This would be a good suggestion for Qubino (good modules but....). Think: 20 watts lighting for 4 hours is only 80 wh, 0.080 kWh, the measurement is 0 kWh, but indeed this day the consumtion is 0.08 kWh
I'll try to create a script (lua) for reading power (watts) from domoticz.db, so I get power (watts) for last 24 hours. Then I could get a media and multiply for total time in ON status (power greater tan 0). So I'll get the energy usage for every day. For that I'll need a virtual counter. This script could run once a day (at 00:00)
Do you think this is possible?
Re: Daily Energy Report
Posted: Thursday 26 May 2016 19:11
by gizmocuz
the counter has 3 digits.. see this image:

- Capture.PNG (12.22 KiB) Viewed 6883 times
Re: Daily Energy Report
Posted: Thursday 26 May 2016 19:12
by gizmocuz
If your leds use less then 1 Watt a day... whats the point of measuring it in the first place ?
Re: Daily Energy Report
Posted: Thursday 26 May 2016 22:56
by juankar
The counter has 3 digits ... you can put 6 digits, but if the device report just 1 decimal digit the other digits are useless.
Your example, a led lamp 1 watt is too low, a led of 6-10 watts are normal in a house. And 6 watts for 8 hours means 0,048 kwh in a day, this is accumulated and after 3 days it's 0,144 kwh, and at this moment Domoticz says 0,144 kWh in a day and this is not so. Indeed it's 0,144 kWh in 3 days. Do you see the difference?
So I want to try another way to calculate the power usage more realistic. That's all. And if I get tit in lua perhaps I try in cpp to incorparate this way to Domoticz, this is the reason I want to know which file is where I have to look for the code that calculate daily usage. I think it's mainworker.cpp but I'm not sure.
Thanks for your work.
Re: Daily Energy Report
Posted: Friday 27 May 2016 10:16
by gizmocuz
The daily usage is calculated by using the counter value
Just like your electricity bill, it is based on the counter value's
A led lamp can have less then 6 watt these days, and the last digit (of the 3) is in watt
if if you have a led light of 1 watt/hour, on for a day (24 hours), you use 0.024 kWh on that day
Re: Daily Energy Report
Posted: Friday 27 May 2016 11:40
by juankar
Yes, I know. That is what I wrote in my post. I'm looking for an alternative to get a daily "real" power usage (yes, I lnow the real value is the counter of kwh of the electricity company). I have started to create my lua script, it's a way to learn more about lua
Bye.
Re: Daily Energy Report
Posted: Saturday 28 May 2016 9:22
by gizmocuz
The 'Real' usage is the subtraction of the counter values at the end of the day, minus the start of the day, or during xx days
Of course your 'idea' sounds interesting if you can do it in c++ (not lua), as we might be able to use this for 'switches' that don't report power.
If switch is on for 1 hour, using 60Watt, ....
Re: Daily Energy Report
Posted: Monday 30 May 2016 14:05
by Toulon7559
@juankar
What would you like to achieve using the data from domoticz.db ?
Reason for the question: look at the way that this database is filled!
Probably the filling is with Energy-data with a certain resolution as discussed in this thread
http://www.domoticz.com/forum/viewtopic ... 484#p87281
If subsequent calculation is required, then (quality out) = (quality in) + (errors due to algorithm)
Perhaps even added error due to processing-delays.
Don't be fooled by seeing in the result more digits than previously in the Energy-resolution:
the important aspect is how many
significant digits you get!
My suggestion: if you want more accurate reading of Energy-values, then either invest in more accurate measuring devices, or look at a different measuring setup such as a kWh-meter with high-rate S0-interface feeding to a small computer.
Plenty of examples of Raspberry/Arduino performing that job.
Re: Daily Energy Report
Posted: Monday 30 May 2016 16:48
by juankar
Table meter is full with power in watts with 1 digit precission (00.0) and time.
Well, if I read watts and multiply for time I get energy usage. Yes, it has not a very high accuracy but I would know the daily usage with more accuracy because meter power has a 1 digit precission but in watts. That's if a read 20,5 watts I'm reading 0.0205 KW and for 1 hour this is 0.0205*1 = 0.0205 kWh. So I can use this method to get the daily energy usage, right?
That's Qubino does not report a good measurement of energy usage, but by calculating we can get a more real value, ate least and aproximate daily value.
I have programmed a lua script to make this calculations and noe I'm testing is is coherente with kwh reported by module. The script runs at the end of every day.
Of course we can get a device with better algorithm but I have what I have...
Re: Daily Energy Report
Posted: Monday 30 May 2016 18:06
by Toulon7559
@juankar
With Power and Time as input for your algorithm, for a correct estimation of Daily Energy, you need to perform Numerical Integration: see e.g.
http://mathworld.wolfram.com/NumericalIntegration.html For a correct result at the end of the day you have to run that function the whole day.
The smaller the interval, the more accurate the resulting value: an interval of a few minutes is preferred.
But you are missing the essence of my last message.
What I tried to explain is that in many cases Power-values are derived/calculated from a series of received Energy-values.
If you then recalculate Energy, you are just reversing the calculation back to the original values. In the calculated result you may see more decimals behind the comma, but due to the 2 serial calculations how much error has been added relative to the original Energy-data?
Sometimes there is no choice. In my own configuration I apply an S0PulseCountingModule to read 5 S0-interfaces.
For the PV-production the 3 Power values produced by this S0PCM most of the time are reasonably close to the comparable values determined by the 3 PVLoggers, but the Energy-values from the S0PCM are way-off due to interference on cables etc.
Reason for me
as a test to also apply an algorithm to calculate Energy derived from Power: see the graphics-line for v12 in the Extended Data at
http://www.pvoutput.org/intraday.jsp?id=10324&sid=8645 ,
http://www.pvoutput.org/intraday.jsp?id=10324&sid=11237 and
http://www.pvoutput.org/intraday.jsp?id=10324&sid=38492
For WWZ_7559A0 you can see that the Energy-
approximation for v12 is
in the vicinity of the Energy-
measurement for v10
Note: Why do I apply an S0PCM parallel to the outputs of the 3 PVLoggers?
For exactly the same reason why you like to have an 'own' calculation: 2 inverters through their PVLoggers report every few minutes their accumulated energy with a resolution of 0.1 kWh resp. 0.01 kWh, which is unsatisfactory. As an intended remedy the kWh-meters-with-S0-interfaces connected to those same 2 inverters provide info with a resolution of 1000pulses/kWh, feeding the S0PCM.
However, in practise I stumbled on erroneous data coming from the S0PCM, requiring to add filtering on the data to obtain more realistic values for Power and Energy. The following link tells the story
viewtopic.php?f=23&t=5006
Re: Daily Energy Report
Posted: Tuesday 07 June 2016 0:34
by juankar
Hi,
I have made a lua script for calculating daily consumntion in kwh for my Qubino 2 Relay, and it looks like it Works fine. Now I have a virtual counter for log energy (kwh) instead of the values reported by Qubino (too low precission for modern low cost lights) . Indeed i think It Works better han straight reports

.
The script is very easy: reading usage (watts) , reading time interval (hours) between readings and multiply (wh), afterwards add the value to last energy stored in virtual counter and that's all. And it's is triggered by changes in Qubino relay usage.
But I would like to explore Cpp and try to include this way for metering kwh in the code of Domoticz, I suppose Domoticz, no OZwave, who reads and shows the measurements from modules, but I don't know how to begin. Which are the files implied? I think I will be able to read the code and understadn how it Works. Then I can try if I am able to modify it for get a caluclated kwh measurement.
Any help?
Thanks
Re: Daily Energy Report
Posted: Thursday 09 June 2016 8:20
by gizmocuz
domoticz gets the counter value from the zwave sensors
Re: Daily Energy Report
Posted: Thursday 09 June 2016 13:38
by juankar
Well I refer to your post where you wrote
gizmocuz wrote:The 'Real' usage is the subtraction of the counter values at the end of the day, minus the start of the day, or during xx days
Of course your 'idea' sounds interesting if you can do it in c++ (not lua), as we might be able to use this for 'switches' that don't report power.
If switch is on for 1 hour, using 60Watt, ....
Perhaps I misunderstood it

. Then this substraction is made in OZwave lib, isn'n it? If so I'll ask in OpenZwave forums.
Thanks
Re: Daily Energy Report
Posted: Thursday 09 June 2016 15:18
by gizmocuz
No.... imagine these counter values send by openzwave for an energy device
1000 (start of the day)
2500
3200
10000 (last counter value of the day)
Total usage for the day = 10000 - 1000 = 9000 (9Kwh)
Re: Daily Energy Report
Posted: Thursday 09 June 2016 15:20
by gizmocuz
There are some (bad....) devices that only transmit the Usage, and not the counter value...
I suggest to replace these... But that is in 0.5% of the case, and i do not expect you to have such one, best to show me the widgests, or the device nodes of the device view
Re: Daily Energy Report
Posted: Thursday 09 June 2016 16:34
by juankar
Ok, Domoticz calculates the daily energy using sensors value, and these values are read and sent to Domoticz by OZwave.
You are right: almost every device sends usage and energy values.
But sometimes counter values sent by devices has too low precisión (0,1 kwh in Qubino swcthes) and this results in false daily consumtion data, really Domoticz calculate several days as it woul be one day (as you say in one of your posts). Imagine
Monday ---- 1,0
Monday ---- 1,0 (at end of day, although the real value is 1,040 kwh, 8 w for 5 hours)
Tuesday--- 1,0 (at end of day, although the real value is 1,080 kwh, 8 w for 5 hours, add to last value)
Wednesday --- 1,2 (at end of day, although the real value is 1,160 kwh, 8 w for 5 hours, add to last value)
So the system show: Monday 0 kwh, Tuesday, 0 kwh, Wednesday = 0,2 kwh (1,2 -1) .... Indeed this 0.2 kwh are distributed among three days.
Then I would like to use the usage value (sent by sensors) and calculate the energy, without using the energy data sent by sensor. Instead of making substraction I would made a multiply ( usage*interval of time from last Reading).
And after reading your answer I know that I must do it by modifyng Domoticz software. And this is new for me, but I like to learn

I need a little clue ... Where (which file) Domoticz make the substraction? And well it could be an option for devices.
Thanks for your answers.
Re: Daily Energy Report
Posted: Thursday 09 June 2016 18:36
by gizmocuz
The subtraction is calculated on the spot, in the webserver.cpp