time = os.date("*t")
mins = time.min + time.hour * 60
commandArray = {}
libs = require("libs")
cmdurl = "/cgi-bin/configManager.cgi?action=setConfig&VideoInOptions[0].NightOptions.SwitchMode="
-- Coop Temp OSD
Coop = otherdevices_temperature['Coop Temp']*9/5+32
Coop = libs.round(Coop,0)
if (Coop ~= tonumber(uservariables["Coop"])) then
table.insert(commandArray, {["Variable:Coop"] = tostring(Coop)})
table.insert(commandArray, {['OpenURL'] = uservariables['camlogin'] .. '@192.168.1.55/cgi-bin/configManager.cgi?action=setConfig&VideoWidget[0].CustomTitle[1].Text=' .. tostring(Coop) .. '°F'})
print('Updating Coop Temp OSD')
end
-- Run Temp OSD
Run = otherdevices_temperature['Coop Temp']*9/5+32
Run = libs.round(Run,0)
if (Run ~= tonumber(uservariables["Run"])) then
table.insert(commandArray, {["Variable:Run"]=tostring(Run)})
table.insert(commandArray, {['OpenURL'] = uservariables['camlogin'] .. '@192.168.1.56/cgi-bin/configManager.cgi?action=setConfig&VideoWidget[0].CustomTitle[1].Text=' .. tostring(Run) .. '°F'})
print('Updating Run Temp OSD')
end
-- Day/Night Video Profile Switching
if (mins >= timeofday['SunsetInMinutes']) and (tonumber(uservariables["ODCam-Profile"]) ~= 1) then
print("Switching Outdoor Cameras to Night Profile.")
table.insert(commandArray, {['OpenURL'] = table.concat({uservariables['camlogin'], "@192.168.1.52", cmdurl, '3' })})
table.insert(commandArray, {['OpenURL'] = table.concat({uservariables['camlogin'], "@192.168.1.53", cmdurl, '3' })})
table.insert(commandArray, {['OpenURL'] = table.concat({uservariables['camlogin'], "@192.168.1.54", cmdurl, '3' })})
table.insert(commandArray, {['OpenURL'] = table.concat({uservariables['camlogin'], "@192.168.1.55", cmdurl, '3' })})
table.insert(commandArray, {['OpenURL'] = table.concat({uservariables['camlogin'], "@192.168.1.56", cmdurl, '3' })})
table.insert(commandArray, {["Variable:ODCam-Profile"] = "1" })
elseif (mins >= timeofday['SunriseInMinutes']) and (tonumber(uservariables["ODCam-Profile"]) ~= 0) and (mins < timeofday['SunsetInMinutes']) then
print("Switching Outdoor Cameras to Day Profile.")
table.insert(commandArray, {['OpenURL'] = table.concat({uservariables['camlogin'], "@192.168.1.52", cmdurl, '0' })})
table.insert(commandArray, {['OpenURL'] = table.concat({uservariables['camlogin'], "@192.168.1.53", cmdurl, '0' })})
table.insert(commandArray, {['OpenURL'] = table.concat({uservariables['camlogin'], "@192.168.1.54", cmdurl, '0' })})
table.insert(commandArray, {['OpenURL'] = table.concat({uservariables['camlogin'], "@192.168.1.55", cmdurl, '0' })})
table.insert(commandArray, {['OpenURL'] = table.concat({uservariables['camlogin'], "@192.168.1.56", cmdurl, '0' })})
table.insert(commandArray, {["Variable:ODCam-Profile"] = "0" })
end
return commandArray