Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team

Question
JeroenVisser 1
HC2 Beta 4.136
Getting a global var does not return a number even when it is set as a numeric.
My testvalue is no string because I want to calculate it. As a workaround I compare the tostring values or force numeric evaluation with + 1.
Please login or register to see this attachment.
SCRIPT:
-- test global var to local number comparison
local testvalue = 35
fibaro:setGlobal('globalminutes',testvalue)
fibaro:debug(fibaro:getGlobalValue('globalminutes'))
fibaro:debug(testvalue)
if fibaro:getGlobalValue('globalminutes') == testvalue
then fibaro:debug("are equal")
else fibaro:debug("are NOT equal")
end
if fibaro:getGlobalValue('globalminutes') + 1 == testvalue + 1
then fibaro:debug("are equal")
else fibaro:debug("are NOT equal")
end
if tostring(fibaro:getGlobalValue('globalminutes')) == tostring(testvalue)
then fibaro:debug("are equal")
else fibaro:debug("are NOT equal")
end
OUTPUT:
[DEBUG] 14:15:25: 35
[DEBUG] 14:15:25: 35
[DEBUG] 14:15:25: are NOT equal
[DEBUG] 14:15:25: are equal
[DEBUG] 14:15:25: are equal
1 answer to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.