• Professional advice
  • Order before 16.30 uur shipped today
  • Almost always available (+31 73 762 0 762)
  • Monday open late

os.time command

os.time()

 

Action :

Displayes the systems date when used without arguments, or diaplays a specific part of the time (for example the minute of the month) when used with a parameter.

 

Usage and parameter :

Er zijn geen argumenten nodig tussen de haakjes.

  • %a     -   Day of the week in abbreviation (for example wed)
  • %A     -   Day of the week (i.e. wednesday)
  • %b     -   Name of the month abbreviated (i.e. sep)
  • %B     -   Name of the month (i.e. september)
  • %c     -   Date and time (e.g., 09/16/98 23:48:10)
  • %d     -   Day of the month (i.e 16) value is between 1 and 31
  • %H     -   Current hour in 24-hour format (i.e. 23)
  • %I       -   Current hour in 12-hour format (i.e. 11)
  • %M   -   Current minute in digits  (i.e. 42) value between 00-59
  • %m     -   Current month in digits (i.e. 9)  value between  1-12
  • %p       -  Am or pm
  • %s       -  Actual second 
  • %w      -  Current day (0-6)  (From saturday to sunday)
  • %x       -  Date (i.e. 09/16/98
  • %X      -  Time (ie 23:48:10)
  • %Y      -   Year (i.e. 2014)
  • %y       -  Year in numbers (i.e. 14)

 

Returned value :

Depending on the parameters

 

In the example belwo we use the os.time command in a bathroomscene that based on the time, switches on the light at a certain level (less light in the evening) and also turns on the radio when no to late or to early. When the door is closed after more than 10 seconds from opening the light and radio will switch off. When the door opens we save the actual time in a variable called BadkamerGeopend. This variable get a linux timestamp (long number representing the amount of seconds that have passed since the beginning op time)

 

Programming example :

 

--[[
%% properties
218 value
%% globals
--]]

local trigger = fibaro:getSourceTrigger()

 

local StatusDeur =fibaro:getValue(218, "value")
local HuidigUur = os.date("%H")


local LampAan =fibaro:getValue(88, "value")
local TijdBadkamerOpen = tonumber( os.time() ) - tonumber(fibaro:getGlobalValue("BadkamerGeopend"))


if ( tonumber(StatusDeur) == 1 ) then
if ( tonumber(LampAan) == 0 ) then

fibaro:setGlobal("BadkamerGeopend", tonumber(os.time() ));
if (( tonumber(HuidigUur) <= 23 ) and ( tonumber(HuidigUur) > 9 ) ) then --voor 21:00 mag de radio aan
     fibaro:call(88, "setValue", "75");
     fibaro:call(91, "turnOn");
elseif (( tonumber(HuidigUur) < 9 ) and ( tonumber(HuidigUur) > 5 ) ) then
     fibaro:call(88, "setValue", "75"); --Smorgens wel sterke verlichting maar geen radio
elseif ( tonumber(HuidigUur) < 5 ) then
    fibaro:call(88, "setValue", "10"); --als het vroeg is dan minder licht aan
end

-- fibaro:debug('lamp aan')
end
elseif ( tonumber(StatusDeur) == 0 ) then
if ( tonumber(TijdBadkamerOpen) > 20 ) then

    fibaro:call(88, "setValue", "00");
    fibaro:call(88, "turnOff");
    fibaro:call(91, "turnOff");
    fibaro:call(89, "turnOff");
end
end

 

 

See also LUA reference manual 

 

 
Customer Service Phone

+31737620762
mon-fri: 10am-5pm and sat 10am-3pm

 
Adress

Gerstakker 16 5236 VG Empel Netherlands

Google maps