Sterowanie grzałkam...
 
Powiadomienia
Wyczyść wszystko

Sterowanie grzałkami przy PV

1 Wpisów
1 Użytkownicy
1 Likes
121 Wyświetleń
kniazio
(@kniazio)
Wpisów: 209
Pomocny Donator 2K21
Autor tematu
 

Za klika tygodni w mojej miejscowości startuje program instalacji PV. Przybędzie ich ok. 670 (3.2 kW). Już teraz występują przepięcia. Na szczęście krótkotrwałe. Aż nie chcę pomyśleć co będzie się działo gdy wystartują nowe instalacje.
Postanowiłem w związku z tym zabezpieczyć się i zmontować sterowanie grzałką 3x2000W.
ChatGPT stworzył mi taki oto skrypt dzvents dla Domoticza do sterowania grzałką uwzględniając też temperaturę wody w bojlerze.
Skrypt ma monitorować napięcie na poszczególnych fazach i załączać grzałki po przekroczeniu wartości napięcia powyżej 253V przez conajmiej 3 minuty. Ma też monitorować temperaturę wody w bojlerze.
Mam prośbę, żeby ktoś znający temat obejrzał skrypt i się wypowiedział.
Może ktoś już zrobił taki skrypt na tym forum. Szukałem lecz nie znalazłem takiego skryptu.
Oto skrypt utworzony przez ChatGPT:

commandArray = {}

-- Funkcja sprawdzająca, czy napięcie na danej fazie jest większe niż 253V
function checkVoltage(phase, voltage)
    if voltage > 253 then
        return true
    else
        print("Napięcie na fazie " .. phase .. " jest poniżej 253V")
        return false
    end
end

-- Funkcja sprawdzająca temperaturę wody w bojlerze
function checkBoilerTemperature(temperature)
    if temperature < 85 then
        return true
    else
        print("Temperatura wody w bojlerze jest równa lub wyższa niż 85 stopni")
        return false
    end
end

-- Funkcja sprawdzająca, czy upłynęło wystarczająco czasu po spełnieniu warunków
function checkDelay(device, delay)
    local lastTime = otherdevices_lastupdate[device]
    local currentTime = os.time()
    if (currentTime - lastTime) >= delay then
        return true
    else
        print("Nie minął wymagany czas od ostatniego włączenia dla " .. device)
        return false
    end
end

-- Sprawdź warunki dla każdej z trzech faz
if devicechanged['VoltagePhase1'] and devicechanged['BoilerTemperature'] then
    local voltagePhase1 = tonumber(otherdevices_svalues['VoltagePhase1'])
    local boilerTemperature = tonumber(otherdevices_svalues['BoilerTemperature'])
    
    if checkVoltage("1", voltagePhase1) and checkBoilerTemperature(boilerTemperature) then
        if checkDelay('Heater1', 180) then -- 3 minuty opóźnienia (180 sekund)
            commandArray['Heater1'] = 'On'
        end
    else
        commandArray['Heater1'] = 'Off'
    end
end

if devicechanged['VoltagePhase2'] and devicechanged['BoilerTemperature'] then
    local voltagePhase2 = tonumber(otherdevices_svalues['VoltagePhase2'])
    local boilerTemperature = tonumber(otherdevices_svalues['BoilerTemperature'])
    
    if checkVoltage("2", voltagePhase2) and checkBoilerTemperature(boilerTemperature) then
        if checkDelay('Heater2', 180) then -- 3 minuty opóźnienia (180 sekund)
            commandArray['Heater2'] = 'On'
        end
    else
        commandArray['Heater2'] = 'Off'
    end
end

if devicechanged['VoltagePhase3'] and devicechanged['BoilerTemperature'] then
    local voltagePhase3 = tonumber(otherdevices_svalues['VoltagePhase3'])
    local boilerTemperature = tonumber(otherdevices_svalues['BoilerTemperature'])
    
    if checkVoltage("3", voltagePhase3) and checkBoilerTemperature(boilerTemperature) then
        if checkDelay('Heater3', 180) then -- 3 minuty opóźnienia (180 sekund)
            commandArray['Heater3'] = 'On'
        end
    else
        commandArray['Heater3'] = 'Off'
    end
end

-- Wyłącz grzałki, jeśli temperatura przekroczy 85 stopni
if tonumber(otherdevices_svalues['BoilerTemperature']) >= 85 then
    commandArray['Heater1'] = 'Off'
    commandArray['Heater2'] = 'Off'
    commandArray['Heater3'] = 'Off'
end

-- Wyłącz grzałki, jeśli napięcie spadnie poniżej 250V po upływie 3 minut
if (devicechanged['VoltagePhase1'] or devicechanged['VoltagePhase2'] or devicechanged['VoltagePhase3']) and tonumber(otherdevices_svalues['VoltagePhase1']) < 250 and tonumber(otherdevices_svalues['VoltagePhase2']) < 250 and tonumber(otherdevices_svalues['VoltagePhase3']) < 250 then
    if checkDelay('Heater1', 180) then
        commandArray['Heater1'] = 'Off'
    end
    if checkDelay('Heater2', 180) then
        commandArray['Heater2'] = 'Off'
    end
    if checkDelay('Heater3', 180) then
        commandArray['Heater3'] = 'Off'
    end
end

return commandArray
 
Dodane : 22/03/2024 7:16 am
adrian reacted
Udostępnij: