

What is wrong with this script??????
Code: Select all
return {
on = { timer = { 'every 2 minutes' }},
execute = function(domoticz, device, timer)
local vandaagKwh = domoticz.devices('Power').counterToday
local vandaagM3Gas = domoticz.devices('Gas').counterToday
local StroomKosten = domoticz.devices('StroomKosten')
local GasKosten = domoticz.devices('GasKosten')
local TotaalKosten = domoticz.devices('EnergieKosten')
local startDateCoolBlue = '2023-10-18'
local endDateCoolBlue = '2024-10-18'
local currentDate = domoticz.time.rawDate
local currentTime = domoticz.time.rawTime
local gasM3Prijs = 0.1356156 -- Coolblue
local kwhPrijs = 0.313136 -- Normaal tarief CoolBlue
if (currentTime == 'between 20:00:00 and 07:00:00') or (domoticz.day == 'Saturday') or (domoticz.day == 'Sunday') then
local kwhPrijs = 0.294744 -- Daltarief CoolBlue
else
local kwhPrijs = 0.313136 -- Normaal tarief CoolBlue
end
-- Vaste kosten in Euro's per dag (zoals vastrecht) CoolBlue
local kwhPrijsVast = 0.949003
local gasM3PrijsVast = 0.657998
-- 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
print ("===============================================================")
print ("Dit is de kilowattuurprijs die in de berekening wordt gebruikt.")
print (kwhPrijs)
print (gasM3Prijs)
print (currentTime)
print (currentDate)
print ("===============================================================")
local KwhKosten = tonumber(domoticz.utils.round( kwhPrijs * vandaagKwh,2))
local GasM3Kosten = tonumber(domoticz.utils.round( gasM3Prijs * vandaagM3Gas,2))
local KostenTotaal = KwhKosten + GasM3Kosten
-- Kosten updaten
StroomKosten.updateCustomSensor(KwhKosten)
GasKosten.updateCustomSensor(GasM3Kosten)
TotaalKosten.updateCustomSensor(KostenTotaal)
end
}
Between 20:00 and 07:00 the kwhPrijs should be 0.294744 and not 0.3131362025-02-17 22:58:00.386 dzVents: ------ Start internal script: Test:, trigger: "every 2 minutes"
2025-02-17 22:58:00.402 dzVents: ===============================================================
2025-02-17 22:58:00.402 dzVents: Dit is de kilowattuurprijs die in de berekening wordt gebruikt.
2025-02-17 22:58:00.402 dzVents: 0.313136
2025-02-17 22:58:00.402 dzVents: 0.1356156
2025-02-17 22:58:00.402 dzVents: 22:58:00
2025-02-17 22:58:00.402 dzVents: 2025-02-17
2025-02-17 22:58:00.403 dzVents: ===============================================================
2025-02-17 22:58:00.403 dzVents: ------ Finished Test
So something is wrong in this script..... But I cann't find it. I don't see it.


Help is much appreciated
Regards, Henny