Library of Functions


Description


Gets information about the trigger that caused the current scene to run.

Usage and Arguments


fibaro:getSourceTrigger()

  • This function takes no arguments.

Returned Values


An array containing information about the trigger of the current scene.

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

  • deviceID
    the device number, which triggered the scene.
  • propertyName
    The name of the property of the device, which triggered the scene.
  • varName
    the name of the global variable, which triggered the scene.
  • no additional fields

Examples


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:

  • A change to the ‘value’ property of device 13,
  • A change to the ‘value’ property of device 15,
  • A change to the global variable ‘isItDarkOutside’

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

See Also


fibaro:getSourceTriggerType