Via a Node Red I get my actual production on dummy device "day production". I have linked this in the script for the calculation.
I don't know exactly how I want to do it yet, but I want to finish this dzVents calculation for myself now. In the end, it may be better to use p1 to calculate yield and life for each phase.
But with this code below I get an error.
Code: Select all
return {
on = {
timer = {
'every 15 minutes'
},
},
execute = function(domoticz, device, timer)
local vandaagKwh = domoticz.devices('Power').counterToday
local vandaagM3Gas = domoticz.devices('Gas').counterToday
local vandaagKwhzon = domoticz.devices('Day Production')
local StroomKosten = domoticz.devices('Kosten Stroom')
local GasKosten = domoticz.devices('Kosten Gas')
local Kosten = domoticz.devices('Kosten Stroom + Gas')
local Opbrengsten = domoticz.devices('Levering Stroom')
-- Eenheidsprijs in Euro's / Kwh - M3
local kwhPrijs = 0.21
local kwhPrijszon = 0.18
local gasM3Prijs = 0.70
if (domoticz.time == 'Between 23:00 and 07:00') or (domoticz.day == 'Saturday') or (domoticz.day == 'Sunday') then
kwhPrijs = 0.19 -- Daltarief
else
kwhPrijs = 0.21 -- Normaal tarief
end
-- Vaste kosten in Euro's per dag (zoals vastrecht)
local kwhPrijsVast = 0.05
local gasM3PrijsVast = 0.06
-- Kosten berekenen
local kwhKosten = tonumber(domoticz.utils.round( (kwhPrijs * vandaagKwh) + kwhPrijsVast,2))
local GasM3Kosten = tonumber(domoticz.utils.round( (gasM3Prijs * vandaagM3Gas) + gasM3PrijsVast,2))
local Kostentotaal = kwhKosten + GasM3Kosten
local Teruglevering = tonumber(domoticz.utils.round( (kwhPrijszon * vandaagKwhzon),2))
-- Kosten updaten
StroomKosten.updateCustomSensor(kwhKosten)
GasKosten.updateCustomSensor(GasM3Kosten)
Kosten.updateCustomSensor(Kostentotaal)
Opbrengsten.updateCustomSensor(Teruglevering)
end
}
Code: Select all
2023-07-09 10:09:00.224 Error: dzVents: Error: (3.1.8) An error occurred when calling event handler Dagkosten dummy sensor
2023-07-09 10:09:00.224 Error: dzVents: Error: (3.1.8) ...pts/dzVents/generated_scripts/Dagkosten dummy sensor.lua:36: attempt to perform arithmetic on a nil value (local 'vandaagKwhzon')

I also wonder how the correct calculation should be for the real money my solar panels deliver, when using P1 and solar panel count.