Set up scenes to have ip camera change to different pre-set positions

Is there a way to set up a scene, say based on time of day, to have an ip camera change to different pre-set positions?

For example, at 10 AM, go to preset position 1, then at 11, preset position 2 etc?

If so, what instructions would be set up in the LUUP code?

Hi Caffreyboy,

You can achieve this with luup code in scenes(Schedule scenes) and based on the time of the day, you can call the preset URL for your camera. You will need an API for it order to find the URL.

Best Regards,

  • Andrei -

[quote=“Caffreyboy, post:1, topic:188196”]Is there a way to set up a scene, say based on time of day, to have an ip camera change to different pre-set positions?

For example, at 10 AM, go to preset position 1, then at 11, preset position 2 etc?

If so, what instructions would be set up in the LUUP code?[/quote]

I’ve got this setup for my living room Foscam PTZ camera. Here’s the luup code I’ve got in place for it…

[code]-- set auto infrared lights
local status, result = luup.inet.wget(‘http://192.168.1.201:201/cgi-bin/CGIProxy.fcgi?cmd=setInfraLedConfig&mode=0&usr=USERNAMEHERE&pwd=PASSWORDHERE’)
– point at the back door
local status, result = luup.inet.wget(‘http://192.168.1.201:201/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=BackDoor&usr=USERNAMEHERE&pwd=PASSWORDHERE’)
– set the snap options to high quality, and upload them to the FTP server
local status, result = luup.inet.wget(‘http://192.168.1.201:201/cgi-bin/CGIProxy.fcgi?cmd=setSnapConfig&snapPicQuality=2&saveLocation=2&usr=USERNAMEHERE&pwd=PASSWORDHERE’)
– snap away!
local status, result = luup.inet.wget(‘http://192.168.1.201:201/cgi-bin/CGIProxy.fcgi?cmd=setScheduleSnapConfig&isEnable=1&snapInterval=1&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655&usr=USERNAMEHERE&pwd=PASSWORDHERE’)
– pause for 120 seconds while the camera does its thing and goes all snap happy
luup.call_delay(“MoveToCouch”,12,0)

function MoveToCouch()
– now, let’s reset to the living room surveillance mode, since if this scene is running, the back door sensor was armed…
local status, result = luup.inet.wget(‘http://192.168.1.201:201/cgi-bin/CGIProxy.fcgi?cmd=setScheduleSnapConfig&isEnable=1&snapInterval=10&schedule0=281474976710655&schedule1=281474976710655&schedule2=281474976710655&schedule3=281474976710655&schedule4=281474976710655&schedule5=281474976710655&schedule6=281474976710655&usr=USERNAMEHERE&pwd=PASSWORDHERE’)
– now move it back to the couch.
local status, result = luup.inet.wget(‘http://192.168.1.201:201/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Couch&usr=USERNAMEHERE&pwd=PASSWORDHERE’)
end[/code]

the schedule1/2/3/4/5/6/7 variables are telling the camera to start snapping images, regardless of when things were started, at 10s intervals.

I have presets named Couch, BackDoor, front door, etc.

This code is executed on a scene that is defined to execute when the back door is opened and the system is not in ‘home’ mode. I also tell it at the top to use IR leds automatically. I turn these off when the system is in ‘home’ mode, then I point the camera at the ceiling, so it acts as a system status indicator as well.

Thank you for the code!

If I understand it correctly, this will take a snapshot?

Can it be set to simply assume the new preset, and stay there until the next time change?

In other words, if I want this to act as a “patrol”, but only at predefined intervals, what modifications would be made to the code? (I’m certainly no coder!)

Yes, it takes snapshots and uploads them to the FTP server defined in the camera setup area. The snapConfig commands specify interval, save locations, and schedules.

The camera stays put until it’s told where to go next. For this scene, it turns and watches the back door entrance, then the assumption is that the activity doesn’t stay at the back door, so I have it turn to watch the couch, where it can see the front door and the dining room.

During this whole process, the camera normally takes snaps every 10 seconds. When tripped, the scene tells it to take one per second.

The most difficult part of all this was the calculations required to set the scheduleN variables. These values correspond to the grid schedule outlined in the foscam configuration, basically telling it that all hours of all days are to be recorded. These get turned off when the system isn’t in a state of heightened alert.

As far as making it patrol at set intervals, you’d need to setup a scene to start the patrols, then setup delays via luup.call_delay() to tell the camera to move at certain times. Using this method you’d need to define every movement, with the proper delay values set to cover the timeframe over which you want the movements to occur… e.g., one call for 15 seconds (look at door A), one at 30 seconds (switch to door B), one at 45 seconds (back to door A), 60 seconds (door B…), etc. If I recall correctly, the luup.call_delay() function starts counting from the point at which the scene is activated (not accounting for the time it takes to execute the code above the first call). So the above described situation would look something like…

-- time 0 is here
luup.call_delay("MoveToDoorA",15);
luup.call_delay("MoveToDoorB",30);
luup.call_delay("MoveToDoorA",45);
luup.call_delay("MoveToDoorB",60);
-- and that's just for the first minute


function MoveToDoorA()
	-- now move it back to the DoorA.
	local status, result = luup.inet.wget('http://192.168.1.201:201/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=DoorA&usr=USERNAMEHERE&pwd=PASSWORDHERE')
end

function MoveToDoorB()
	-- now move it back to the Door B.
	local status, result = luup.inet.wget('http://192.168.1.201:201/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=DoorB&usr=USERNAMEHERE&pwd=PASSWORDHERE')
end

Hope that helps.

Thank you again for all your help.

However, I am doing something wrong. I have a Foscam outdoor pan/tilt ip camera, and used this code to try to move to a preset point (I didn’t know how to rename the presets, so they are only numbered).

I have included my http address, but not username and pw.

luup.inet.wget(‘http://192.168.1.66:90/cgi-bin/CGIProxy.fcgi?command=1&usr=username&pwd=password’)

I tried using your functions, and modified them, but all with no luck. Could you please comment?

From what I can tell, you need to change this:

CGIProxy.fcgi?command=1

to this:

CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=1

with the proper usr & pwd informations.