I have installed an electric kitchen boiler and I want to charge it with the current from my solar panels, if there is not enough sun (thus no power from my solar panels) then I want to charge it during the night when my electric price is cheaper. Charging minimal one time a day should be fine because the water stays heated for a longer time and it will only be used to wash hands and do some dishes.
So in short, I want to know if the boiler was charged during daytime with the power from my solar panels, if not (or too short, it takes 1hr to charge) then charge it next morning at 4:00am till 6:00am
I think I need a timer or so to count the charging time, which also needs to be reset daily at 6:00am
I hope someone can help me with this because I am stuck, I am not a good programmer but was able to get the following code working so far (without the timer)
Code: Select all
local fetchIntervalMins = 10 -- (Integer) (Minutes, Range 5-60) How often SE file is fetched
return {
on =
{
timer = { 'every ' .. fetchIntervalMins .. ' minutes' },
devices = {'Shelly_Boiler'}
},
logging = {
level = domoticz.LOG_ERROR}, -- set to error when all OK
execute = function(dz, switch)
-- Variabelen
local kWhMeter = 28 --IDX nr voor P1 meter
local Residue = 61 --IDX nr voor residue value kWh Elektra (usage, electric) Teller
-- Code
local value = dz.devices(kWhMeter).usage - dz.devices(kWhMeter).usageDelivered -- Current power consumption calculated
dz.devices(Residue).updateEnergy(value) -- Update de kWh Teller zodat deze gelijk is aan de waarde van de P1 meter
local boiler = dz.devices('Shelly_Boiler')
-- BIJ LEVERING ZONNESTROOM - (SOLAR POWER CHARGING)
if (boiler.state == 'Off') and value<-500 then
boiler.cancelQueuedCommands()
boiler.switchOn().checkFirst()
local message = ('Boiler inschakelen, huidige teruglevering = ')..value
dz.notify(subject, message, dz.PRIORITY_MEDIUM, dz.SOUND_PERSISTENT, nil, dz.NSS_TELEGRAM)
end
if (boiler.state == 'On') and value>50 then
boiler.cancelQueuedCommands()
boiler.switchOff().checkFirst().afterMin(2)
local message = ('Boiler wordt over 2min uitgeschakeld. huidig verbruik = ')..value
dz.notify(subject, message, dz.PRIORITY_MEDIUM, dz.SOUND_PERSISTENT, nil, dz.NSS_TELEGRAM)
end
end
}