Logic Machine Forum
Thermostat control - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Thermostat control (/showthread.php?tid=866)



Thermostat control - XSPA2474KW - 24.06.2017

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


RE: Thermostat control - admin - 24.06.2017

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



RE: Thermostat control - XSPA2474KW - 07.07.2017

Hi again!

This is the total code? Nothing else?

I can't understand key = 'lastupdate_'

BR


RE: Thermostat control - admin - 07.07.2017

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.


RE: Thermostat control - XSPA2474KW - 07.07.2017

So and all this code in an event script in the button right?


RE: Thermostat control - mlaudren - 11.07.2017

(07.07.2017, 06:19)XSPA2474KW Wrote: So and all this code in an event script in the button right?

Yes