Controlling Foscam R2

Hi,

Currently wrestling with a couple different issues:

  1. I’d like to be able to have a script in a scene that once I remotely turn the camera on waits about 3 minutes for the camera to boot up, moves the camera to a pre-set position, takes a picture, moves it to a second preset position, takes a picture.
    I have LUUP scripts in scenes that use the CGI of the camera to move to preset positions that are functioning correctly. I’ve been unable to use the CGI to snap a picture off, and I cannot figure out a way to make the entire thing wait 3 minutes before executing. I’ve read Vera times this out after 60 seconds and it takes longer than that for the camera to boot up and connect to the network.
    Any help here would be appreciated.

To delay LUUP execution you can use call_delay-function

Something like this :

function delayed
luup.call_action(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },123)
luup.log(“Delayed: Power off, Device : 123”)
return true
end – delayed

– Main()
luup.log(“Main Code starting”)

–Execute delayed action by function delayed
luup.call_delay(“delayed”,)

return true

Thanks for the answer!
I’ve since moved on to using PLEG to accomplish this and it’s working fine.
Though I AM curious as to a couple things here:

  1. How do you access the log file you’re logging to?
  2. How could you log the value of a variable? I know nothing about LUA.

http:///cgi-bin/cmh/log.sh?Device=LuaUPnP
or
SSH into vera and less, cat or tail /var/log/cmh/LuaUPnP.log

Just concat the variable name to the luup.log call, lua takes care of converting numbers to strings.

https://www.lua.org/pil/3.4.html

local sID = 197
local tID = 198
luup.log("Var sID : " … sID … "Var tID: " … tID)

log-function LUUP extension description is here :
http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_log