• Professional advice
  • Order before 23.59 uur shipped today (choose Trunkrs)
  • Almost always available (+31 73 762 0 762)
  • Monday open late (odd weeks)

Tonumber command



Action :

Tries to convert the passed value into a number.

Usage and parameter :


  • argument: Een argument van een willekeurig type dat omgezet dient te worden naar een getal.


Returned value :

A nummeric value.


Programming example :

-- assign a string to a variable mystring
local mystring = '123'

-- Example below will result in an error message since mystring is not a number.
if (mystring > 100)  then


-- Thats why we convert a string into a nummeric value.
-- Example : Put the device off when 'Brightness" is more thant 50.

if (tonumber(mystring) >10)  then
   fibaro:debug('This works, the variable is more than 10');



See also:

LUA reference manual 5.2 : tonumber




Customer Service Phone

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


Gerstakker 16 5236 VG Empel Netherlands

Google maps