Page 1 of 1

How to get Temperature Set Point working in LUA

Posted: Tuesday 15 March 2016 0:05
by Number8
Hello,
After having read a lot on the Temperature Set Point control and Lua Wiki, I decided to post this question.
I have a Temperature Set Point control named, say roomTemp. After having changed Temperature setting point and clicked on Set, I want to have a Lua script triggered and retrieve the new Set Point value in order to act accordingly. I discovered that the name of this device is suffixed with _Utility.
So I tried in LUA:

Code: Select all

if devicechanged['roomTemp_Utility'] > 0 then
print ('A')
end
But this triggers an error because most of the time there is no value
I understand that I have first to test that the device has changed and then grab the value, since there is no value returned until a change has occured

The log returns the two following lines
2016-03-14 22:59:37.710 LUA: Device based event fired on 'roomTemp', value '' (two single quotes with no space)
2016-03-14 22:59:37.710 LUA: Device based event fired on 'roomTemp_Utility', value '12.5'

So I tried

Code: Select all

if devicechanged['roomTemp'] == '' then
print ('ok')
print otherdevices['roomTemp_Utility']
end
I also tried

Code: Select all

print otherdevices_svalues['roomTemp_Utility']
with no success

Syntax error is reported near otherdevices or otherdevices_svalues instructions.

I would appreciate any guidance on this matter. I'm currently running v2.4582
Thank you

Re: How to get Temperature Set Point working in LUA

Posted: Tuesday 15 March 2016 10:55
by Number8
I ended up with this logic
if devicechanged[setPointName] == '' then
setPointValue = tonumber(otherdevices_svalues[setPointName])
print (setPointValue)