–Purpose : Sets aircon zone 1 (Master Bed) to cool on–
–Inputs : N/A–
–Outputs : N/A–
–Notes : Control bridge IP xx.x.x.xxx call twice to change to auto and setpoint, global function–
–Version : 0–
–Revision : 4–
–Zones 1(Master Bed) on–
function zone1coolOn()
local http = require(“socket.http”)
local ltn12 = require(“ltn12”)
local status = http.request
{
url = path,
method = “POST”,
headers =
{
[“Content-Type”] = “application/json”,
[“Content-Length”] = payload:len()
},
source = ltn12.source.string(payload)
}
end
local output = pcall(zone1coolOn)
–call twice–
local output = pcall(zone1coolOn)
I want to pass the zone and temp parameters through the function when I called it (as per below local payload) but cant get it to work. Any help would be much appreciated.
–Zones 1(Master Bed) on–
function zonecoolOn(ax, bx)
local http = require(“socket.http”)
local ltn12 = require(“ltn12”)
Thanks akbooer, I had tried a few iterations with brackets etc and was getting frustrated… will definitely need to read up some more but thanks heaps for your pointers, much appreciated. Will post how I go, just putting the final touches on an IZone435 aircon integration. Will post once “perfected”
I currently have code that works perfect when tested in the “Test Luup code (Lua)” of my vera, but I get
LuaInterface::CallFunction_Timer-5 function coolcheck failed attempt to call a nil value <0x750c0520>
in the LuaLog… I have tried placing all functions in the start up file but to no avail: code is as follows:
–Purpose : Sets aircon Mode to Cool & checks status–
–Inputs : N/A–
–Outputs : N/A–
–Notes : Control bridge IP 10.1.1.159 –
–Version : 1–
–Revision : 0–
function coolcheck()
local currentmode = luup.variable_get(“urn:toggledbits-com:serviceId:SiteSensor1”, “Value2”, 107)
if currentmode == "cool" then
luup.log("Aircon COOL is set")
else
luup.log("Aircon COOL is NOT set")
pcall(coolmodeOn)
end
return true
end
function coolmodeOn()
local http = require(“socket.http”)
local ltn12 = require(“ltn12”)
local path = “http://10.1.1.159/SystemMODE?”
local payload = [[ {“SystemMODE”:“cool”} ]]
It should be noted that the function being called must be in the global space. [glow=red,2,300]Depending on where that function is in your program this might not be automatic[/glow]. If you are getting an error that says the function is nil this is likely the case. A quick fix is to add the line:
_G.functionname = functionname
No more errors
Best Home Automation shopping experience. Shop at Ezlo!