Library of Functions


Description


Retrieves the ‘value’ and ‘time last modified’ of a global variable registered in the Variables Panel.
 
This is one of a group of functions:
  • fibaro:getGlobal
  • fibaro:getGlobalValue
  • fibaro:getGlobalModificationTime
 
These functions differ only in their return value.

Usage and Arguments


fibaro:getGlobal(varName)

  • varName: the name of the global variable

Returned Values


This function returns two values:

  1. A string containing the current value of the global variable, and
  2. A timestamp of when the global variable was last modified

Please note that these return values are of type string.  When comparing them with a variable of type number, use tonumber to convert them first.

Examples


-- Get the value and last modification time
-- of the 'isNight' global variable
local value, modificationTime = fibaro:getGlobal('isNight')
 
-- In Lua the second return value can be omitted
-- so this also works:
local value2 = fibaro:getGlobal('isNight')
 
-- The obtained value can be used to do other things in the scene
if (value == '1') then
  fibaro:debug("It's night!")
end

See Also


fibaro:getGlobalValue

fibaro:getGlobalModificationTime