Library of Functions


Description


Gets the number of currently running instances of a scene.

Usage and Arguments


fibaro:countScenes()

fibaro:countScenes(sceneID)

  • sceneID: number – (optional) the id of the scene to be counted

Returned Values


A positive integer containing the number of currently active scenes.
 
If sceneID is specified, the number of currently running instances of the scene with that ID will be returned, otherwise the current scene ID will be used.

Examples


-- Displays the number of instances of the current scene
local num = fibaro:countScenes()
 
if (num == 1) then
  fibaro:debug('I am running only once.')
else
  fibaro:debug('I am running ' .. num .. ' times.')
end
-- Only allow one instance of the current scene to run at a time
if (fibaro:countScenes() > 1) then
  fibaro:abort()
end
-- Displays number of instances of scene 12
num = fibaro:countScenes(12);
 
fibaro:debug('Number of instances of scene 12: ' .. num);
-- Check if scene 12 is running
if (fibaro:countScenes(12) >= 1) then
  fibaro:debug('Scene 12 is running');
else
  fibaro:debug('Scene 12 is not running');
end

See Also


fibaro:startScene
fibaro:killScenes