Skip to content

Instantly share code, notes, and snippets.

@acidjunk
Created February 10, 2018 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acidjunk/3e6dbc50e0faf11146b2b43287e63d75 to your computer and use it in GitHub Desktop.
Save acidjunk/3e6dbc50e0faf11146b2b43287e63d75 to your computer and use it in GitHub Desktop.
--------------------------------
------ Start of edit section ------
--------------------------------
local desired_temp = 14.0 --Desired temp
local hysteresis = 0.03 --Marge
local sensor = 'Temperatuur' --Name of sensor
local thermostat = 'cv_master' --Master switch (virtuel)
local radiateur = 'cv_switch' --Device to switch on/off
--------------------------------
-- End of edit section --
--------------------------------
commandArray = {}
if (devicechanged[sensor]) then
print('Temperatuur updated from sensor.')
local temperature = devicechanged[string.format('%s_Temperature', sensor)]
print(temperature)
if (otherdevices[thermostat]=='On') then
print('Master switch is "On"')
if (temperature < (desired_temp - hysteresis) ) then
print('Switched CV On')
commandArray[radiateur]='On'
elseif (temperature > (desired_temp + hysteresis)) then
print('Switched CV Off')
commandArray[radiateur]='Off'
else
print ('No change needed')
end
else
print('Master switch is "Off"; ignoring current and desired temperature')
end
end
return commandArray
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment