However I needed something that calculates the difference for usage and return for day and night rate.
Setup 2 dummy devices like Sum day Rate and Sum night Rate (Som Hoog en Som Laag in the script)
Code: Select all
--[[
dzVents script dzVents script time
Split P1 Smart Meter Electricity in usage1, usage 2, return 1 and return 2.
Script downloaded from huizebruin.nl
www.huizebruin.nl/domoticz/slimme-meter-(p1)-opsplitsen-naar-4-tellers-domoticz-met-lua/
1-0:1.8.1(00185.000*kWh) (Totaal usage tarief 1 (night)) - usage1
1-0:1.8.2(00084.000*kWh) (Totaal usage tarief 2 (day)) - usage2
1-0:2.8.1(00013.000*kWh) (Totaal return tarief 1 (night)) - return1
1-0:2.8.2(00019.000*kWh) (Totaal return tarief 2 (day)) - return2
--[[
Power usage 1 = Dal gebruik : 30163692
Power usage 2 = Piek gebruik : 16186108
Power return 1 = Dal terug : 11095413
Power return 2 = Piek terug : 26657672
]]--
Example start values -- 01-01-2023 -- 04-07-2023
local startUsageLow = 29885000 -- 29048762 --29885000
local startUsageHigh = 15983000 -- 15357636 --15983000
local startReturnLow = 10747000 -- 9937177 --10747000
local startReturnHigh = 25826000 -- 24233004 --25826000
local fetchIntervalMins = 20 -- 1 = every minute, 10 = every 10 minutes, etc.)
return {
on = {
timer = { 'every ' .. fetchIntervalMins .. ' minutes' }
},
logging = {
level = domoticz.LOG_DEBUG, domoticz.LOG_INFO,
marker = 'Separate meter readings '
},
execute = function(dz, item)
local P1 = dz.devices('Power') -- Electra, P1 Smart Meter device (idx or "name") (required)
local saldoHigh = dz.devices('Saldo Hoog') -- verschil teruglevering - gebruik
local saldoLow = dz.devices('Saldo Laag') -- verschil teruglevering - gebruik
local sumSaldoHigh = (P1.return2 - startReturnHigh) - (P1.usage2 - startUsageHigh)
local sumSaldoLow = (P1.return1 - startReturnLow) - (P1.usage1 - startUsageLow)
dz.log('Saldo High : ' ..sumSaldoHigh, dz.LOG_INFO)
dz.log('Saldo Low : ' ..sumSaldoLow, dz.LOG_INFO)
dz.devices('Saldo High').updateCounter(sumSaldoHoog)
dz.devices('Saldo Low').updateCounter(sumSaldoLaag)
end
}
-- einde Script
You can start measuring from january first or from the day you energy provider starts a new yearly period.
The annual account of your energy provider shows the numbers you're seaching for.
The numbers have to put into the script. The top numbers show positive when the solar power output is higher than usage and negative when usage is higher than PVOutput.
The numbers in the middle show the calculated difference between the start of the measurement (in this case 07-07-2023) and today.
You can see that I have a suplus of day energy of 648 kW and a surplus of 62 kW of nigt (weekend) energy.
My daily score is positive for day and negative for the evening and night hours.