Ja swego czasu stworzyłem taki skrypt, który odpalałem zawsze gdy musiałem przełączyć jednocześnie kilka urządzeń np zamknąć wszystkie rolety czy przygasic światła:
function call(id, action) --action is any string that fibaro:call() accepts
local OK = "Transfer_was_OK"
local dev = id..' '..fibaro:getName(id)
local set = 0
local val = tonumber(fibaro:getValue(id, "value"))
if action == "turnOn" or action == "open" then set = 1
elseif action == "turnOff" or action == "close" then set = 0
else fibaro:debug('wrong action parameter'); return
end
--do the action if neccesary
if (set == 0 and val > 0) or (set == 1 and val == 0) then
fibaro:call(id, action);
fibaro:sleep(1000)
log = fibaro:getValue(id, "log")
if log == OK then
fibaro:debug('COMM OK '..dev.." is "..action); return true
else
fibaro:debug('COMM ERROR '..dev.." may not "..action);
fibaro:wakeUpDeadDevice(id);
fibaro:sleep(2000);
fibaro:call(id, action)
fibaro:sleep(1000)
log = fibaro:getValue(id, "log")
if log == OK then fibaro:debug('COMM OK '..dev.." is "..action); return true
else return false
end
end
end
return true
end
fibaro:debug('start')
--this is the code you enter where you want to execute confirmed call action
local ok = true
local list = {4} --list of devices ID's
for i = 1, #list do ok = call(list[i], "turnOn") and ok end
if ok == false
then fibaro:debug('Comm Error - repeating actions')
fibaro:sleep(10000)
ok = true
for i = 1, #list do ok = call(list[i], "turnOn") and ok end
end
fibaro:debug('END '..tostring(ok))