First, this controls motion on a Foscam PTZ. . yes, there is a plugin but neither will control my cameras.
- Code: Select all
using terms from application "IndigoServer"
tell application "IndigoServer"
set actionOrdered to value of variable "Cam_Garage" as string
log actionOrdered
--Cardinal Directions. Automatically stops the directional movement via delayed command at the bottom.
set actionDirections to {"Left", "Right", "Up", "Down"}
if actionDirections contains actionOrdered is true then
set theAction to "ptzMove" & actionOrdered & ""
--log theAction
--set value of variable "Cam_Garage" to "x"
end if
--zoom in, out. Automatically stops the zoom via delayed command at the bottom.
set actionZoom to {"zoomIn", "zoomOut", "zoomStop"}
if actionZoom contains actionOrdered is true then
set theAction to actionOrdered & ""
--log theAction
--set value of variable "Cam_Garage" to "x"
end if
--Go to Preset.
set actionPreSet to {"TopMost", "RightMost", "LeftMost", "BottomMost", "Preset_1", "Preset_2", "Preset_3"} --I added WideView and Center. Modify the list to add your custom preset.
if actionPreSet contains actionOrdered is true then
set theAction to "ptzGotoPresetPoint&name=" & actionOrdered & ""
--log theAction
--set value of variable "Cam_Garage" to "x"
log actionOrdered & "the list works"
end if
--Need to place all non-IR commands in this list so they will execute with proper timing.
set actionListAll to {"Left", "Right", "Up", "Down", "zoomIn", "zoomOut", "zoomStop", "TopMost", "RightMost", "LeftMost", "BottomMost", "Preset_1", "Preset_2", "Preset_3"}
if actionListAll contains actionOrdered is true then
log actionOrdered & "the list works"
set theIP to "'http://10.0.1.25:80/cgi-bin/CGIProxy.fcgi?" --change your ip and command string here. Note the ' at the beginning. Need one at the end.
set thePW to the value of variable "Camera_Password"
set theUser to the value of variable "Camera_User"
--set theAction to the value of variable "Cam_Garage"
set theURL to theIP & "cmd=" & theAction & "&" & "usr=" & theUser & "&" & "pwd=" & thePW & "'" --rearrange the order of the username/password and command string if necessary for your camera.
--log theURL --comment this out once it is working
set curlURL to "curl -f" & " " & theURL
set shellscript to curlURL
--log shellscript -- commment this out once it is working
do shell script shellscript
set value of variable "Cam_Garage" to "x"
end if
--http://10.0.1.25:80/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=[user]&pwd=[password]
--This is a distinct URL send for IR LED open and close. Otherwise it does not work correctly when run as an external script.
set actionIRonOff to {"openInfraLed", "closeInfraLed"}
if actionIRonOff contains actionOrdered is true then
set theAction_IR_Only to actionOrdered
--log theAction
--delay 2
--set value of variable "Cam_Garage" to "x"
set theIP to "'http://10.0.1.25:80/cgi-bin/CGIProxy.fcgi?" --change your ip and command string here
set thePW to the value of variable "Camera_Password"
set theUser to the value of variable "Camera_User"
set theURL to theIP & "&cmd=" & theAction_IR_Only & "&" & "usr=" & theUser & "&" & "pwd=" & thePW & "'" --rearrange the order of the username/password and command string if necessary for your camera.
--log theURL --comment this out once it is working
set curlURL to "curl -f" & " " & theURL
set shellscript to curlURL
--log shellscript -- commment this out once it is working
do shell script shellscript
--delay 2
set value of variable "Cam_Garage" to "x"
end if
--Send "stop" URL function for directions and zoom
delay 0.3
if actionDirections contains actionOrdered is true then
set theAction to "ptz" & "StopRun"
set theIP to "'http://10.0.1.25:80/cgi-bin/CGIProxy.fcgi?" --change your ip and command string here
set thePW to the value of variable "Camera_Password"
set theUser to the value of variable "Camera_User"
set theURL to theIP & "&cmd=" & theAction & "&" & "usr=" & theUser & "&" & "pwd=" & thePW & "'" --rearrange the order of the username/password and command string if necessary for your camera.
--log theURL --comment this out once it is working
set curlURL to "curl -f" & " " & theURL
set shellscript to curlURL
set theAction to "ptzMove" & "Stop"
do shell script shellscript
set value of variable "Cam_Garage" to "x"
end if