Page 1 of 1

How to calculate daily usage from 2 phases of the electricity meter?

Posted: Thursday 22 December 2016 14:20
by Ysbrand
Hi,

I've just started with Domoticz and trying to get a feel for it. As I do not complete understand the entire structure (yes I did read quite a bit of documentation) I might overlook something basic.

I'm using rfxcom to read the value of my electricity meters. As there are 2 distinct phases, I want to obtain the total usage. For this I've created a dummy device and used the following script:

Code: Select all

local fase1_dv = 'Electra Fase 1'
local fase2_dv = 'Electra Fase 2'
local electra_idx = 14

commandArray = {}

if devicechanged["Electra Fase 1"] then

        fase1 = otherdevices_svalues[fase1_dv]
        fase2 = otherdevices_svalues[fase2_dv]
        fase1_val = tonumber(fase1)
        fase2_val = tonumber(fase2)
commandArray['UpdateDevice'] = electra_idx .. '|0|' ..  string.format("%.0f" .. 1 .. " kWh", fase1_val + fase2_val)
print(commandArray['UpdateDevice'])
end
return commandArray
This produces the following result:
domoticz.JPG
domoticz.JPG (51.48 KiB) Viewed 1163 times
While it does display the total value of the 2 counters, it doesn't show the total usage for today (11.887).

Where are these values stored and how can I get the total assigned to the virtual sensor.

Thanks,
Ysbrand

Re: How to calculate daily usage from 2 phases of the electricity meter?

Posted: Saturday 25 February 2017 16:12
by EdwinK
Something like this is what I was looking for. But couldn't quite figure it out.

How did you do the 2 counters for the two phases?

Re: How to calculate daily usage from 2 phases of the electricity meter?

Posted: Sunday 19 March 2017 4:26
by asjmcguire
EdKo66 wrote:Something like this is what I was looking for. But couldn't quite figure it out.

How did you do the 2 counters for the two phases?
Just in case you haven't figured this out yet - (this is my understanding - someone else might need to clarify if it is correct).
The daily reading is kWh (kilowatt-hours).

If a kettle says on the label it consumes 2.8kW (or 2800W) that means it uses 2800W in 60 minutes (per hour).
This means that it uses 2800/60 = 46.6W per minute.

So now let's assume we have a cumulative reading of 6.123kWh (which will be 6123 in svalue domoticz) and we are consuming 1.25kW at the time of the reading.

cumulative = 6123 + (1250/60) = 6143.833
svalue=1250;6143.833

You don't calculate the daily reading - Domoticz does that for you when you start feeding it with the increasing cumulative total.