Basically on a device change (a PIR sensor) a user variable AlarmDetected is set to 1. Blockly should handle this and perform an action.
I assume this does not work to prevent event loops, setting a user variable from a lua script will not again trigger blockly.
(Or I am clearly doing something wrong...)
My use case is that I would like to trigger blocky from lua so that some part of my function can be in lua and some part in blockly.
I use Domoticz v2.4607 (git pull of today) on linux.
My lua script:
Code: Select all
commandArray = {}
print('DEBUG: script_device_toggle')
tc=next(devicechanged)
PIR_switch=tostring(tc)
if (PIR_switch:sub(1,3) == 'PIR') then
if(uservariables['AlarmDetected'] == 1) then
commandArray['Variable:AlarmDetected'] = '0'
print('DEBUG: script_device_toggle Set AlarmDetected 0')
else
commandArray['Variable:AlarmDetected'] = '1'
print('DEBUG: script_device_toggle Set AlarmDetected 1')
end
end
return commandArray