Vera VistaCam PT Control

Posted on
Sat Apr 29, 2017 11:36 am
NewfD90 offline
Posts: 40
Joined: Mar 17, 2017

Vera VistaCam PT Control

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
Attachments
IMG_1183.jpg
IMG_1183.jpg (113.4 KiB) Viewed 895 times

Posted on
Sat Apr 29, 2017 3:24 pm
bkmar1192 offline
Posts: 246
Joined: Sep 12, 2015

Re: Vera VistaCam PT Control

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

Posted on
Sat Apr 29, 2017 4:48 pm
NewfD90 offline
Posts: 40
Joined: Mar 17, 2017

Re: Vera VistaCam PT Control

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

Posted on
Sat Apr 29, 2017 8:53 pm
bkmar1192 offline
Posts: 246
Joined: Sep 12, 2015

Re: Vera VistaCam PT Control

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

Posted on
Sun Apr 30, 2017 9:42 am
NewfD90 offline
Posts: 40
Joined: Mar 17, 2017

Re: Vera VistaCam PT Control

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.
Attachments
Untitled.png
Untitled.png (139.05 KiB) Viewed 822 times

Posted on
Mon May 01, 2017 1:05 am
bkmar1192 offline
Posts: 246
Joined: Sep 12, 2015

Re: Vera VistaCam PT Control

I'll take a look tonight.


Sent from my iPhone using Tapatalk

Posted on
Wed May 03, 2017 11:45 pm
bkmar1192 offline
Posts: 246
Joined: Sep 12, 2015

Re: Vera VistaCam PT Control

I just posted version 1.5.4 that fixes the issue of the Camera Command action not being displayed. Thanks.

Posted on
Thu May 04, 2017 7:57 am
NewfD90 offline
Posts: 40
Joined: Mar 17, 2017

Re: Vera VistaCam PT Control

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

Posted on
Thu May 04, 2017 12:47 pm
bkmar1192 offline
Posts: 246
Joined: Sep 12, 2015

Re: Vera VistaCam PT Control

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

Posted on
Thu May 04, 2017 1:19 pm
NewfD90 offline
Posts: 40
Joined: Mar 17, 2017

Re: Vera VistaCam PT Control

That's how I have it setup. However, the plugin is coded to only use urllib for the CameraCommand call.

Posted on
Fri May 05, 2017 8:51 am
jay (support) offline
Site Admin
User avatar
Posts: 13048
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Vera VistaCam PT Control

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.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest