electric boiler smart switching

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
balosa
Posts: 21
Joined: Sunday 17 May 2020 12:50
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.4
Contact:

electric boiler smart switching

Post by balosa »

Hi all,

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

}
Attachments
boiler1.jpg
boiler1.jpg (170.18 KiB) Viewed 444 times
Last edited by balosa on Sunday 12 February 2023 18:33, edited 1 time in total.
willemd
Posts: 661
Joined: Saturday 21 September 2019 17:55
Target OS: Raspberry Pi / ODroid
Domoticz version: 2024.1
Location: The Netherlands
Contact:

Re: electric boiler smart switching

Post by willemd »

Looks like you are already quite far on your way. With some more development/testing you will get there. Much more rewarding ;-)
I think you can do it all in one script that includes:
1) A trigger by the P1 meter: if there is a return of electricity (so a surplus of your solar panels) then switch on the boiler, otherwise switch off.
2) if you switch off, then you could use lastUpdate() of the switch to check the number of seconds it has been on and add that to a total counter (could be a persistent variable for example). Make sure lastUpdate() is valid by not setting to on when it is already on and not switching to off when already off, so only change when needed.
3) if it has been on for more than 1 hour then set a flag that morningcharging is not necessary (the flag could be another persistent variable, or a device. Often a device is nicer because you can see the value in an icon)
4) a trigger in the morning: if the flag has not been set, then charge
5) a trigger at 06:00 for the reset
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest