Page 1 of 1

Vera VistaCam PT Control

PostPosted: Sat Apr 29, 2017 11:36 am
by NewfD90
Recent Vera refugee here. Transition went remarkably smoothly. Some things were harder; others easier. Regardless, I couldn't find a way to control the Pan and Tilt controls on my old Vera IP camera, so I fired up WireShark and figured out the controls. Below is a simple bash shell script that implements all those controls. Attached is a screen cap of a control screen that implements some of these functions.

Code: Select all
#!/bin/sh
IP_ADDR="userid:pass@192.168.1.1:PortNum"

case "$1" in
        left)
                curl http://$IP_ADDR/decoder_control.cgi?command=4
                sleep 1
                curl http://$IP_ADDR/decoder_control.cgi?command=1
                ;;
        right)
                curl http://$IP_ADDR/decoder_control.cgi?command=6
                sleep 1
                curl http://$IP_ADDR/decoder_control.cgi?command=1
                ;;
        up)
                curl http://$IP_ADDR/decoder_control.cgi?command=0
                sleep 1
                curl http://$IP_ADDR/decoder_control.cgi?command=1
                ;;
        down)
                curl http://$IP_ADDR/decoder_control.cgi?command=2
                sleep 1
                curl http://$IP_ADDR/decoder_control.cgi?command=1
                ;;
        upleft)
                curl http://$IP_ADDR/decoder_control.cgi?command=90
                sleep 1
                curl http://$IP_ADDR/decoder_control.cgi?command=1
                ;;
        upright)
                curl http://$IP_ADDR/decoder_control.cgi?command=91
                sleep 1
                curl http://$IP_ADDR/decoder_control.cgi?command=1
                ;;
        downleft)
                curl http://$IP_ADDR/decoder_control.cgi?command=92
                sleep 1
                curl http://$IP_ADDR/decoder_control.cgi?command=1
                ;;
        downright)
                curl http://$IP_ADDR/decoder_control.cgi?command=93
                sleep 1
                curl http://$IP_ADDR/decoder_control.cgi?command=1
                ;;
        vpatrol)
                curl http://$IP_ADDR/decoder_control.cgi?command=26
                ;;
        stopvpatrol)
                curl http://$IP_ADDR/decoder_control.cgi?command=27
                ;;
        hpatrol)
                curl http://$IP_ADDR/decoder_control.cgi?command=28
                ;;
        stophpatrol)
                curl http://$IP_ADDR/decoder_control.cgi?command=29
                ;;
        pos)
                curl http://$IP_ADDR/decoder_control.cgi?command=$((30 + ($2*2-1)))
                ;;
        *)
                echo "Syntax:"
                echo "    up, down, left, right"
                echo "    upleft     : up and left diagonally"
                echo "    upright    : up and right diagonally"
                echo "    downleft   : down and left diagonally"
                echo "    downright  : down and right diagonally"
                echo "    vpatrol    : vertical patrol"
                echo "    stopvpatrol: stop vertical patrol"
                echo "    hpatrol    : horizontal patrol"
                echo "    stophpatrol: stop horizontal patrol"
                echo "    pos N      : recall stored position N"
                exit 1
                ;;
esac

exit 0

Re: Vera VistaCam PT Control

PostPosted: Sat Apr 29, 2017 3:24 pm
by bkmar1192
My security camera plugin has an action to send a URL to a camera. Might be worth a try. It is completely untested function since I don't a camera to take commands. Would be happy to work with you to get it working if you are interested.


Sent from my iPhone using Tapatalk

Re: Vera VistaCam PT Control

PostPosted: Sat Apr 29, 2017 4:48 pm
by NewfD90
I saw that capability in your plugin. However, for each movement, the camera requires the requisite command, followed by a stop command. The time in between defines how far the camera moves. So to do that within Indigo seemed a bit complicated, hence the script.

Thanks though!
Chance

Re: Vera VistaCam PT Control

PostPosted: Sat Apr 29, 2017 8:53 pm
by bkmar1192
Couldn't you create an action group that would issue the first command then issue the stop with a delay. For example, a 10* clockwise action and a 10* counter clockwise action.


Sent from my iPhone using Tapatalk

Re: Vera VistaCam PT Control

PostPosted: Sun Apr 30, 2017 9:42 am
by NewfD90
OK, I was going to play with this, but the Action for sending a command via URL is no longer there! I swear I saw it yesterday, but maybe that was just from reading your manual.

Re: Vera VistaCam PT Control

PostPosted: Mon May 01, 2017 1:05 am
by bkmar1192
I'll take a look tonight.


Sent from my iPhone using Tapatalk

Re: Vera VistaCam PT Control

PostPosted: Wed May 03, 2017 11:45 pm
by bkmar1192
I just posted version 1.5.4 that fixes the issue of the Camera Command action not being displayed. Thanks.

Re: Vera VistaCam PT Control

PostPosted: Thu May 04, 2017 7:57 am
by NewfD90
Got it and updated. Unfortunately, urllib doesn't like the URL. I'm sending a fully formed URL of the type http://user@ipAddr:port/path, which best I can tell seems to be what urlretrieve expects. Does any of the special characters need to be escaped? Perhaps run it through urlencode first?

Code: Select all
Traceback (most recent call last):
  File "plugin.py", line 843, in CameraCommand
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 98, in urlretrieve
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 245, in retrieve
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 213, in open
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 364, in open_http
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 377, in http_error
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 702, in http_error_401
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 766, in retry_http_basic_auth
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 795, in get_user_passwd
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 804, in prompt_user_passwd
EOFError: EOF when reading a line

Re: Vera VistaCam PT Control

PostPosted: Thu May 04, 2017 12:47 pm
by bkmar1192
Try the urllib2 option in device setup. It has separate fields for user name and password. It is also a bit more resilient than urllib. Also, the http:// is assumed and does not need to be included.


Sent from my iPhone using Tapatalk

Re: Vera VistaCam PT Control

PostPosted: Thu May 04, 2017 1:19 pm
by NewfD90
That's how I have it setup. However, the plugin is coded to only use urllib for the CameraCommand call.

Re: Vera VistaCam PT Control

PostPosted: Fri May 05, 2017 8:51 am
by jay (support)
Just a point of interest: we highly recommend using the requests library (included with Indigo 7+) for all http communication - it handles all authentication types, it's easy to use, extremely robust and very well supported.