checkFirst not working
Posted: Saturday 28 September 2019 16:56
Hi,
I bought a sonoff key remote with fout buttons. When i push button B, i receive the signal three times.
So i made $remote_aan which is coupled to the remote (and changes three times)
When the script receives a ok, it changes another switch remote_aan_def and only changes this by checking it first with checkFirst
The switches are working by i get two messages when pushing the B button (this is $remote_uit)...
I bought a sonoff key remote with fout buttons. When i push button B, i receive the signal three times.
So i made $remote_aan which is coupled to the remote (and changes three times)
When the script receives a ok, it changes another switch remote_aan_def and only changes this by checking it first with checkFirst
The switches are working by i get two messages when pushing the B button (this is $remote_uit)...
Code: Select all
return {
on = { devices = {'$remote_aan', '$remote_uit'},
},
logging = { level = domoticz.LOG_ERROR,
marker = "Timers"},
execute = function(dz,item,info)
if (item.name == '$remote_aan') then
dz.devices('$remote_aan_def').switchOn().checkFirst()
dz.devices('$remote_aan_def').switchOff().afterSec(10)
elseif (item.name == '$remote_uit') then
dz.devices('$remote_uit_def').switchOn().checkFirst()
dz.devices('$remote_uit_def').switchOff().afterSec(10)
end
end
}
Code: Select all
return {
on = { devices = {'$remote_aan_def','$remote_uit_def'},
},
logging = { level = domoticz.LOG_ERROR,
marker = "Timers"},
execute = function(dz,item,info)
local logcode = 3
local messageTable = {}
local add = 'add'
local del = 'del'
local chg = 'chg'
local function globalMessage(action, message, logcode)
if logcode == nil then logcode = 3 end
if action == add and logcode > 0 then
messageTable = dz.helpers.addMessage(dz, item, info, message, messageTable, logcode)
elseif action == del then
dz.globalData.mylogging = message
dz.devices('timerlog').updateText(message)
elseif action == chg then
dz.helpers.dumpMessages(dz, messageTable)
end
end
if (item.name == '$remote_aan_def') and (item.state == 'On') then -- reset
globalMessage(add, ' REMOTE_AB_1: Aan aangezet...',logcode)
elseif (item.name == '$remote_uit_def') and (item.state == 'On') then -- reset
globalMessage(add, ' REMOTE_AB_1: UIT aangezet...',logcode)
end
globalMessage(chg) -- dump
end
}