Is there an issue with the documentation there? https://www.domoticz.com/wiki/User_variables#Lua
I ran a LUA time script, default one and added in the user var loop:When using user variables in Lua, keep in mind the following: variables are always stored as a string in the Domoticz database, regardless of their type. The variables are passed in arrays to Lua, at that point they will always be strings also.
Code: Select all
for variableName,variableValue in pairs(uservariables) do
print( 'Variable: '.. variableName .. ' = "' .. variableValue .. '" (' .. type(variableValue) .. ')')
end
TestVar is integer, TempMax is float. None of them are passed in LUA as string as indicated in the Wiki.2019-09-16 10:15:00.496 Status: LUA: Time based event fired
2019-09-16 10:15:00.497 Status: LUA: Variable: TestVar = "0" (number)
2019-09-16 10:15:00.497 Status: LUA: Variable: TempMax = "25.5" (number)
Is it a bug? Has the behavior changed recently and the documentation was not updated?
I tried with latest stable 4.10717 on Pi and on 4.11300 on Win.
This question comes from a topic on the french speaking domoticz forum, where an user tried to compare his integer user variable to '0', without tostring or tonumber anywhere. I quickly looked around and found nothing about it here and around.
I wanted to know the official stand on this. Thanks