Lua version changed in domoticz V4.11439 from version 5.2 to 5.3
You can check what version is in use in your domoticz version with
Code: Select all
domoticz.log('Lua version in use by domoticz ' .. domoticz.settings.domoticzVersion .. ' : ' .. _G._VERSION,domoticz.LOG_FORCE) -- in dzVents scripts
print('Lua version in use by domoticz : ' .. _G._VERSION) -- in Lua scripts
math.max and math.min do no longer return a number when comparing strings. The now return the same type as the input parameters. Use tonumber to convert to a number if your script expects one.
deprecated functions: math.atan2, math.cosh, math.sinh, math.tanh, math.pow, math.frexp, and math.ldexp. You can replace math.pow(x,y) with x^y
Introduction of an integer subtype for numbers with as side effect that a conversion of a float to a string now adds a .0 suffix to
the result if it looks like an integer. (For instance, the float 2.0 will be printed as 2.0, not as 2 )
Some possible work-arounds if this change is causing problems for you are:
Easiest: use math.floor -- returns the integral part of any number
Code: Select all
print (math.floor(6/1.999999999999)) -- >> 3
print (math.floor(6/2.000000000001)) -- >> 2
Code: Select all
print (math.tointeger(5/2)) -- >> nil
print (math.tointeger(6/1.999999999999999)) -- >> nil
print (math.tointeger(6/1.9999999999999999)) -- >> 3
Code: Select all
print( ({ math.modf(5/2)})[1]) -- >> 2
print( ({ math.modf(5/2)})[2]) -- >> 0.5