]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_thermostat/commitdiff
Misc fixes and tweaks main
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Thu, 14 Dec 2017 21:19:29 +0000 (16:19 -0500)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Thu, 14 Dec 2017 21:19:29 +0000 (16:19 -0500)
thermostat.lua

index ccc1c0e1110067f6effc4b345e25a103ea4ac6d1..17c1693ab4fc0931247884f8528b87fe00bda89e 100644 (file)
@@ -103,7 +103,7 @@ nwfnet.onmqtt["th"] = function(c,t,m)
     resetTempAcc()
     tctarget = tonumber(m) or tctarget
     -- don't stop driving now, let the poller logic handle that
     resetTempAcc()
     tctarget = tonumber(m) or tctarget
     -- don't stop driving now, let the poller logic handle that
-  elseif t == mqttModeTopic then
+  elseif t == mqttModeTopic and tcmode ~= m then
     if driving then stopFan() end
     driving = false -- stop driving now, since the mode differs!
     resetTempAcc()
     if driving then stopFan() end
     driving = false -- stop driving now, since the mode differs!
     resetTempAcc()
@@ -166,7 +166,7 @@ local function therm_res(t)
     end
 
     -- Vote to engage or stay on
     end
 
     -- Vote to engage or stay on
-    if     t == nil                            then verr  = verr  + 1
+    if     t == nil                        then verr  = verr  + 1
     elseif tcmode == "cool" and t > thresh then vnum = vnum + 1
     elseif tcmode == "heat" and t < thresh then vnum = vnum + 1
     elseif tcmode == "emht" and t < thresh then vnum = vnum + 1
     elseif tcmode == "cool" and t > thresh then vnum = vnum + 1
     elseif tcmode == "heat" and t < thresh then vnum = vnum + 1
     elseif tcmode == "emht" and t < thresh then vnum = vnum + 1
@@ -204,7 +204,8 @@ local function therm_res(t)
     mqc:publish(mqttPubRoot.."zz",
       sjson.encode({ ['m']=m, ['r']=r, ['h']=node.heap(),
                      ['f']=tempAccFan, ['ft']=(fanOffDelayTMR ~= nil),
     mqc:publish(mqttPubRoot.."zz",
       sjson.encode({ ['m']=m, ['r']=r, ['h']=node.heap(),
                      ['f']=tempAccFan, ['ft']=(fanOffDelayTMR ~= nil),
-                     ['c']=vdenom, ['v']=vnum, ['e']=verr }),
+                     ['c']=vdenom, ['v']=vnum, ['e']=verr,
+                     ['mo']=tcmode, ['ta'] = tctarget }),
       1,1)
   end
 
       1,1)
   end