20.04.2021, 12:13
You can use this script without FB only change the output grp and make sure this 'fb__New_diagram__fbe_switch_delay__id' is a unique value as this is used as storage ID.
The function itself looks like this:
The function itself looks like this:
Code:
function fbe_switch_delay(input, delayOn, delayOff, blockID)
-- Create callID
math.randomseed(os.time())
math.random()
math.random()
local callID = ""
for i=1,16 do
callID = callID .. string.format("%x", math.random(0, 0xf))
end
-- Store callID
storage.set(blockID .. "_callID", callID)
-- Wait
if input.value and input.value ~= 0 then
sleep(delayOn)
else
sleep(delayOff)
end
-- If a telegram arrives during an ongoing delay, then only the last telegram is output delayed. Ongoing delays are cancelled!
if callID == storage.get(blockID .. "_callID") then
return input.value, not input.value
else
return nil, nil
end
end
------------------------------
Ctrl+F5
Ctrl+F5