Created
October 18, 2016 06:41
-
-
Save jsopenrb/4fe01bb0a9b123737cff71e7ff0d9e04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- extra temp offset for each mode | |
modeoffset = { [0] = 0, [1] = 2, [2] = 4 } | |
-- zone definition, each zone has 5 elements: | |
-- 1 = mode, 2 = temp sensor, 3 = setpoint, 4 = output, 5 = output status | |
zones = { | |
{ '7/4/3', '1/0/1', '1/1/1', '1/2/1', '1/3/1' }, | |
{ '7/4/3', '1/0/2', '1/1/2', '1/2/2', '1/3/2' }, | |
{ '7/4/3', '1/0/3', '1/1/3', '1/2/3', '1/3/3' }, | |
{ '7/4/3', '1/0/4', '1/1/4', '1/2/4', '1/3/4' }, | |
{ '7/4/3', '1/0/5', '1/1/5', '1/2/5', '1/3/5' }, | |
{ '7/4/3', '1/0/6', '1/1/6', '1/2/6', '1/3/6' }, | |
{ '7/4/3', '1/0/7', '1/1/7', '1/2/7', '1/3/7' }, | |
{ '7/4/3', '1/0/8', '1/1/8', '1/2/8', '1/3/8' }, | |
{ '7/4/3', '1/0/10', '1/1/10', '1/2/10', '1/3/10' }, | |
{ '7/4/3', '1/0/11', '1/1/11', '1/2/11', '1/3/11' }, | |
{ '7/4/3', '1/0/12', '1/1/12', '1/2/12', '1/3/12' }, | |
{ '7/4/3', '1/0/13', '1/1/13', '1/2/13', '1/3/13' }, | |
{ '7/4/3', '1/0/14', '1/1/14', '1/2/14', '1/3/14' }, | |
{ '7/4/3', '1/0/15', '1/1/15', '1/2/15', '1/3/15' }, | |
{ '7/4/3', '1/0/16', '1/1/16', '1/2/16', '1/3/16' }, | |
{ '7/4/3', '1/0/17', '1/1/17', '1/2/17', '1/3/17' }, | |
{ '7/4/3', '1/0/18', '1/1/18', '1/2/18', '1/3/18' }, | |
{ '7/4/3', '1/0/19', '1/1/19', '1/2/19', '1/3/19' }, | |
{ '7/4/3', '1/0/20', '1/1/20', '1/2/20', '1/3/20' }, | |
{ '7/4/3', '1/0/21', '1/1/21', '1/2/21', '1/3/21' }, | |
{ '7/4/3', '1/0/23', '1/1/23', '1/2/23', '1/3/23' }, | |
} | |
for _, zone in ipairs(zones) do | |
mode = grp.getvalue(zone[ 1 ]) | |
temp = grp.getvalue(zone[ 2 ]) | |
setpoint = grp.getvalue(zone[ 3 ]) | |
outaddr = zone[ 4 ] | |
stataddr = zone[ 5 ] | |
offset = modeoffset[ mode ] or 0 | |
tempmin = setpoint - offset - 0.5 | |
tempmax = setpoint - offset + 0.5 | |
value = nil | |
if temp > tempmax then | |
value = false | |
elseif temp < tempmin then | |
value = true | |
end | |
if value ~= nil and value ~= grp.getvalue(stataddr) then | |
grp.write(outaddr, value) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment