No announcement yet.

Page to Control the Ninja Camera [ASP] Discussion

  • Filter
  • Time
  • Show
Clear All
new posts

  • Page to Control the Ninja Camera [ASP] Discussion

    This is the discussion thread for the Page to Control the Ninja Camera [ASP]. Let me know if you encountered any problems or have any questions.
    Visit My Home Seer Site at:
    Created with LCARS

  • #2
    John, great job! I have wanted to get into ASP work. I added my streaming camera to this code and got it working - however it shows up below the buttons. I would rather it show beside the buttons (to the left of them). Any idea how to do this?

    Also, how would you have it interface with HS instead of the CM19A directly? You would have to do this to enable camera switching.


    • #3
      Jeff, Glad it worked for you! I have attached a copy of the code to this posting. It has a spot clearly labled where to put your camera code. In the code you will see where it says "PUT YOUR CAMERA CODE IN THIS TABLE". Just replace that line with the code for your camera. This will put your camera image on the left, and the buttons on the right.

      NOTE: This page will NOT work by itself, you will need the other page in the zip archive available in the script library.

      As for controlling it with HS that is no problem. If you have the plugin set in HS it will work in its present state. This page will work either with -OR- without HS involved.

      In it's present state, there is no way to have more than one camera controlled. This could easily be done however. You will need to copy the CameraControl.asp and name is say CameraControl2.asp. You would then have to do a search and replace on that file to replace the House And unit codes to the second camera's settings.

      You would also have to duplicate the first page, and do a search and replace on that as well replacing all instances of "CameraControl.asp" with "CameraControl2.asp".

      Basically having 2 pages for each camera that you have. I only have one camera that I wanted to control, so I didnt plan on using multiple camera's when I wrote this.
      Attached Files
      Visit My Home Seer Site at:
      Created with LCARS


      • #4
        Sorry guys, I THOUGH it was tested completely before posting, but somehow I reverted to an earlier version of the code before posting.

        This prevents the Memory locations and the sweep function from working properly. I have updated the ZIP archive in the scripts library.

        You can have a look at this code in use on my website at the link in my signature. You will notice that the layout is completely different that what I posted. The posted code was simple graphics just to get you going, and customize it the way you wanted. By looking at my page, you will see that you can make the interface look just about like anything you want it to. As I am working on this on & off, the cam feed may not be on when you check. If you stop by, please take just a second to sign the guest book and let me know you were there. Thanks!
        Visit My Home Seer Site at:
        Created with LCARS


        • #5

          I use Yahoo Messenger to stream my cameras. I have ALWAYS wanted to be able to use the Ninja so I could check out what was going on in all areas of the back yard while I was out of town. NOW I CAN! In fact, now friends and family can as well.

          It took about 10 minutes to set up and have as a menu item on my HS Guest page. ....and the dang thing WORKS(!) so much better than the hand held remote that I'll probably never use it again while at home!

          NICE WORK! ...and THANKS!



          • #6
            I built upon Johnwpb's easy to use control page to add buttons for camera selection and embedded a java applet for the video display. I'll provide it if anyone is interested or if any updates are desired in the Library.
            Attached Files


            • #7
              Michael, very nice addition to John's work! I have had some simple html pages working for the ninja for about a year. I struggled trying to get something nicer working and couldn't make much headway. This is great...I would love a copy of your asp if you're willing.......Tx


              • #8
                The Camera Select is very dependent upon your video switch control or if using only the X10 cams then it should be no action required if your cams are all in the same bank of 4 contiguous codes. I implemented it as an include file form the scripts folder since I also have events that run the same camera switch code. Edit the last few lines of the control asp.

                The java applet is based upon an iVista feed. You will need to update the applet in index.asp to get your streaming video source or do whatever you need to do in the table element to have the display show. If you only have snapshots rather than a stream then you will want to put an IFRAME in this table and feed it with a META REFRESH so it will pick the most current shapshot from the snapshot folder.

                I believe the files in the zip are the same names as John's with one added for the Camera Select Icon. I do not think I included a subfolder path so whereever you unzip them is where there will be. Only the 2 asp files were modified from the original.

                For sake of sharing some of the knowledge I gain from this board...

                1. A single IFRAME is used. The FRAME provides the invisible conduit between the client and server. Since only one button is pressed at a time, then only 1 channel of communiction is needed.
                2. Names and Id are only needed in form and frame elements if they are going to ge referenced. The reference is usually via javascript. The one exception here is the IFRAME needs a name since it is the target for the form submit.
                3. Global variable is used to remember the current camera setting. When the global variable has not yet been created HS returns a string like an error message. Since I'm storing a numeric value in the global variable I need only check if the return value is numeric to know if it is a real value or the variable has not bee created yet. An Ini file could be used if the camera setting needs to persist between HS restarts.
                4. Note the use of the include file at the end of the control asp. This provides a mechanism by which script code can be included in the asp code. Two other alternatives are available. One is to use the hs.RunEx method and that would work well here since only 1 parameter is involved. The other is to just embed the code in the asp such as I did as a comment about the include statuement.
                5. Just as a matter of coding style I used the Select Case construct rather than a serier of If/Elseif in the control asp. While it does not make much difference here I believe the Select Case builds a table of addresses, computes and index into that table, and then jumps via the index. The If/Elseif executes a series of compare opertions. If the Select Case values are contiguous then the table is small and the execution efficiency may be improved when more than 4 or so If/ElseIf values need to be executed. An alternate implementation would be to enumerate the values returned from the Form Request in an array and then use the array index to correlate the user selection with Ninja command. This is good if code space is scare, but may increase execution time. I found John's discrete itemizations easier to understand and maintain than an array itemization.
                6. The With construct is useful and it may improve execution efficiency. In this case I bumped it up a level from the original so that it was available to set the HC and DC. Both of these needed to be set for each command going to the Ninja.

                Thanks go to John for the lion share of this. I've had my ninja's on the shelf for months because I had no attractive way to control them.
                Attached Files
                Last edited by Michael McSharry; December 31st, 2004, 03:04 AM. Reason: Added 2nd Version of Files


                • #9
                  Thanks! I will have to do some work since my setup uses Webcam32, but I should be able to manage that. My previous html actually triggered HS events so it was fully under the control of HS rather than directly through the CM19a interface.

                  This is really nice. Thanks - I have some work to do......!


                  • #10
                    The control asp is really easy to work with. Rather than commanding the interface object you could do triggers via HS just as easily. In my situation there is nothing that HS does that is associated with the camera video so Johns original implementation works well for me. For the other X10 aspects of the CM19A I use xap schema, thus do not even have it installed as a Homeseer Plugin.


                    • #11
                      I tweak the page a little to provide visual feedback of which camera is selected by showing a lighter blue color for the selected camera and put a border around it to provide more definition. The files are at the same location above as the second attachment.
                      Attached Files


                      • #12
                        I have been able to insert my Webcam32 javascript, but I can't get the buttons to work. I have to do some more work on this......anyone have some quick ideas for me?


                        • #13
                          The buttons that I added require your own script logic to select a specific camera. The ninja control buttons that John provided are controlled out of the controlcam.asp and the ninja codes are included in an array toward the top of it. Sprinkle an hs.writelog to confirm your asp is receiving the command from the browser.


                          • #14
                            Michael, I get the vbscipt error shown in the attached file when the index file is opened. I get this with your original unmodified files or with the modified version that includes my streaming video source. Any idea of why the vbscript message appears instead of the image? Also can you provide a copy of your cameraselect script.

                            Nice addition to John's great work.

                            Attached Files


                            • #15
                              For debugging you will need to look only at the camera selection frame.


                              where nn is your HS port.

                              This will put the info full screen where you can see what the error message really is. Sometimes you will need to do view/source from browser to get to the essence of it if it is not obvious from the screen dump.

                              My camera select is based upon a camera switcher with a rotating selector in a 4 position round robin. It actually has a remote that sends RF. I hacked the remote to add a wire to the buttons contact for the "Next" and "Scan" functions. I then use the SECU16 relay output to control these two buttons which in turn sends RF to the switcher. I just did an ebay purchase based upon zoomkat's lead for the IR controlled Emerson unit which appears to have discrete control of each of the 4 cameras so I will no longer need to monkey around with trying to remember the camera position and control the number of pushes required. The IR connection will also be a lilttle cleaner as well. Cant see where this script will be of much value to you, but you are welcome to it.
                              Attached Files