Thanks all ,
I have extended the script slightly ,
so that the fan (192.168.2.171) enters a kind of shutdown phase and
extends the average value because otherwise I will start commuting the valve (192.168.2.172) .
Fan ip end's 171
Valve ip end's 172
Greets, Peter
Code: Select all
return {
on = {
timer = {'every 1 minutes'},
devices = {'Kookplaat_F1_(Rechts)', 'Kookplaat_F3_(Links_Flexzone)', 'AF1'}
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'OffdoorGemKookstroom',
},
data =
{
kpmt1_History = { history = true, maxMinutes = 5},
kpmt2_History = { history = true, maxMinutes = 5},
},
execute = function(domoticz)
local kpmt1 = domoticz.devices('Kookplaat_F1_(Rechts)') -- Fase meting L1 Kookplaat Rechts
local kpmt2 = domoticz.devices('Kookplaat_F3_(Links_Flexzone)') -- Fase meting L3 Kookplaat Links
local AF1s = domoticz.devices('AF1') -- Voorwaarde stroom laag
-- add new data kpmt1
domoticz.data.kpmt1_History.add(kpmt1.actualWatt)
-- average for Phase 1
local CurForn1Average = domoticz.data.kpmt1_History.avg()
domoticz.log('average stroom1 ' .. CurForn1Average, domoticz.LOG_INFO)
-- add new data kpmt2
domoticz.data.kpmt2_History.add(kpmt2.actualWatt)
-- average for Phase 2
local CurForn2Average = domoticz.data.kpmt2_History.avg()
domoticz.log('average stroom2 ' .. CurForn2Average, domoticz.LOG_INFO)
-- Kijken of de stroom laag is
-- if kpmt1.actualWatt < 50 and kpmt2.actualWatt < 50 and CurForn2Average < 5 and CurForn1Average <5 then
if CurForn1Average < 5 and CurForn2Average <5 then
domoticz.openURL('http://192.168.2.172/relay/0?turn=off')
domoticz.log('klep closed', domoticz.LOG_INFO)
end
if CurForn1Average < 35 and CurForn2Average < 35 and AF1s.state == 'Off' then
domoticz.openURL('192.168.2.171/light/0?turn=on&brightness=18')
domoticz.log('shutting down', domoticz.LOG_INFO)
end
end
}