iZone 435 controller interface

Just thought I would share my interface as this has taken me some time to develop. Hope it helps someone else 8)

–Purpose : Sets SystemMODE & checks status.–
–Inputs : N/A–
–Outputs : N/A–
–Notes : Control bridge IP 10.1.1.159 added _G.functionname = functionname prior to luup.delay call to avoid nil call on function –
–Version : 1—
–Revision : 1—

count3 = 0
function systemModecheck(var1)
local currentstate = luup.variable_get(“urn:toggledbits-com:serviceId:SiteSensor1”, “Value2”, 107)

      if currentstate == var1 then
          luup.log("Aircon MODE is set")
          count3 = 0
                                  
      else
          luup.log("Aircon MODE is NOT set")
          count3 = count3+1           
        if count3 <= 5 then
          pcall(systemMode,var1)
          luup.log(count3)
        end
      luup.log(var1)
      end
return true

end

function systemMode(var1)
local http = require(“socket.http”)
local ltn12 = require(“ltn12”)
local path = “http://10.1.1.159/SystemMODE?
local command = [[ {“SystemMODE”:“%s”} ]]
local payload = command: format(var1)

local status = http.request
{
url = path,
method = “POST”,
headers =
{
[“Content-Type”] = “application/json”,
[“Content-Length”] = payload:len()
},
source = ltn12.source.string(payload)
}
luup.log(“Aircon MODE command Sent”)
_G.systemModecheck = systemModecheck
luup.call_delay(“systemModecheck”,30,var1)
return true
end

–SystemOn calls–
systemMode(“cool”)
systemMode(“heat”)
systemMode(“vent”)
systemMode(“dry”)
systemMode(“auto”)