fibaro:getSourceTrigger()
The array will always contain a field called ‘type’, which, depending on the type of trigger will have one of the following values:
‘property’ – for triggers based on changes in device properties
‘global’ – for triggers based on changes of a global variable
‘other’ – in other cases (for example, directly starting the scene from an interface or a calling it from another scene)
Depending on the value of ‘type’, the table may have additional fields:
property |
Global |
Other |
|
|
|
This function can be used to determine which of the triggers was the direct cause of a scene being run. In the following example, the following triggers are defined – any one of these could cause the scene to run:
In addition, the scene can be launched directly from the interface or by any other scene (fibaro:startScene(sceneID)
).
At the start of the scene, it will print information about the source of the triggers to the debug console:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | --[[ %% properties 13 value 15 value %% globals isItDarkOutside –]] local trigger = fibaro:getSourceTrigger () if (trigger[ 'type' ] == 'property' ) then fibaro:debug ( 'Source device = ' .. trigger[ 'deviceID' ]) elseif (trigger[ 'type' ] == 'global' ) then fibaro:debug ( 'Global variable source = ' .. trigger[ 'varName' ]) elseif (trigger[ 'type' ] == 'other' ) then fibaro:debug ( 'Other source.' ) end |
fibaro:getSourceTriggerType