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
Iztok88 0
Hi guys,
I am trying to create a virtual thermostat in HC2 using a fibaro flood sensor for temperature sensor and an everspring wallplug for on/off switching. In practice different devices will be used this is just to see if it works. In virtual devices I create a slider(for setting the temperature) and a label. Once I input all the codes I get an error message saying: "line4: attempt to compare string with nil"
These are the codes:
For the slider:
function map_range( a1, a2, b1, b2, s )
return math.floor(b1 + (s-a1)*(b2-b1)/(a2-a1))
end
111 = map_range(0, 100, 10, 35, _sliderValue_ )
fibaro:setGlobal("111", 111)
fibaro:call(fibaro:getSelfId(), "setProperty", "ui.label1.value", 111)
For the main loop:
roomTemp = fibaro:getValue(14, "value");
roomSetTemp = fibaro:getGlobal("111");
if (roomSetTemp > roomTemp) then
fibaro:debug("on")
fibaro:call(16, "turnOn")
elseif
(roomSetTemp <= roomTemp) then
fibaro:debug("off")
fibaro:call(16, "turnOff")
end
111 - room number
14 - flood temp sensor id
16 - wallplug id
I have played around with this and from what I can gather the problem is somewhere in the roomsettemp part of the code. I'd apreciate the help if anybody has any idea whats wrong. I got this process of creating a virtual thermostat somewhere online.
5 answers 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.