I would like to use the average value instead of the absolute because Bosch Cooktop uses PWM and occasionally the current is zero!
Does anyone have an idea? How to make that with dzVents?
And maybe it would be useful , but am not so at home with wifi (Shelly) relays, to ask if the valve is already closed.
return {
on = {
timer = {'every 10 minutes'},
},
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
-- Kijken of de stroom nul is
if kpmt1.actualWatt < 50 and kpmt2.actualWatt < 50 then
domoticz.openURL('http://192.168.2.172/relay/0?turn=off')
domoticz.log('klep closed', domoticz.LOG_INFO)
end
end
}
return
{
on = {
devices = {'Test Total solar radiation'}
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'SEM228T',
},
data =
{
SEM228THistory = { history = true, maxMinutes = 10},
},
execute = function(domoticz, sensor)
-- add new data
domoticz.data.SEM228THistory.add(sensor.radiation)
-- average
local RadAverage = domoticz.data.SEM228THistory.avg()
domoticz.log('average radiation ' .. RadAverage, domoticz.LOG_INFO)
end
}
The solved code from your Link. That's a start.
Now I should actually add those values together from Phase 1 and Phase 2 , another hint , how to add the 2 together ?
Well thanks in advance. For me, English as a beta is quite complicated and I am getting rusty.
return {
on = {
timer = {'every 1 minutes'},
devices = {'Kookplaat_F1_(Rechts)', 'Kookplaat_F3_(Links_Flexzone)'}
},
logging =
{
level = domoticz.LOG_DEBUG,
marker = 'OffdoorGemKookstroom',
},
data =
{
kpmt1_History = { history = true, maxMinutes = 2},
kpmt2_History = { history = true, maxMinutes = 2},
},
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
-- 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
end
}
waltervl wrote: ↑Friday 03 January 2025 18:25
For avarage calculation over x measurements see for example topic viewtopic.php?t=38305
An arithmetic average will not work for such device that usually report (a few %) changes over time with varying samples timings. This needs some discrete integration (summing 'current sample value ' * 'time to next sample', in the end divided by summing/averaging time) to get reliable values.
waltervl wrote: ↑Friday 03 January 2025 18:25
For avarage calculation over x measurements see for example topic viewtopic.php?t=38305
An arithmetic average will not work for such device that usually report (a few %) changes over time with varying samples timings. This needs some discrete integration (summing 'current sample value ' * 'time to next sample', in the end divided by summing/averaging time) to get reliable values.
TS only wants to now if the avarage is 0 A for some time. There is no need te be exact...
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
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) .
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
}