This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Thermostat control
#1
Hi

I want to press a button once and increase temperature by half a degree.
From then on, anytime I push the button nothing happens, unless 30 min pass.
After 30 min pushing the button will increase the temperature by another half degree.

So on, and so forth

Please for your feedback
Reply
#2
Code:
-- setpoint object
obj = '1/1/1'
-- storage key, unique for each object
key = 'lastupdate_' .. obj
-- current timestamp
now = os.time()
-- timestamp of last update
upd = storage.get(key, 0)

-- time is in seconds (30 minutes)
if (now - upd) >= 30 * 60 then
  -- set new last update time
  storage.set(key, now)
  -- increase setpoint by 0.5
  setpoint = grp.getvalue(obj)
  grp.write(obj, setpoint + 0.5)
end
Reply
#3
Hi again!

This is the total code? Nothing else?

I can't understand key = 'lastupdate_'

BR
Reply
#4
This is a unique storage key for each object, for 1/1/1 it will be "lastupdate_1/1/1". This allows to reuse the code for different objects just by changing the setpoint object address.
Reply
#5
So and all this code in an event script in the button right?
Reply
#6
(07.07.2017, 06:19)XSPA2474KW Wrote: So and all this code in an event script in the button right?

Yes
Reply


Forum Jump: