Announcement

Collapse
No announcement yet.

FOSCAM in HSTouch Tutorial

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    FOSCAM in HSTouch Tutorial

    Hello All

    I am a beginner and found making a FOSCAM interface very difficult.

    For anyone who wants a tutorial; please read on over the next few posts. In no way is this bullet proof and if there is one thing I have learnt from this experience is that it is very difficult and settings can be considerably different.

    I use the UK:
    I have a FOSCAM FI9826P V2 (latest firmware)
    1280*960 (1.3 Megapixel)
    H.264 (960P)
    microphone, speaker, zoom, pan, tilt, ir

    NOTES
    • rtsp://[username]:[password]@[ip]:[port]/videoMain
    • rtsp://[username]:[password]@[ip]:[port]/videoSub
    • rtsp://[username]:[password]@[ip]:[port]/ audio
    • Use VLC player to do this.
    • If RTSP does not work google the cmd MJStream and apply it like the below
    (5) Test your main snaps
    • http://[username]:[port]/cgi-bin/CGIProxy.fcgi?cmd=snapPicture&usr=[username]&pwd=[password]
    • http://[username]:[port]/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=[username]&pwd=[password]
    Create a InterfaceAdding the Camera to the Screen
    1. Insert a Picture Element into the page.
    2. Select ImageFormat="Stretched"
    3. Select isVideo Property to "True"
    4. Select Image URL= "http://192.168.0.10:80/cgi-bin/CGIProxy.fcgi?cmd=snapPicture2&usr=*****&pwd=******"


    Adding a LEFT/RIGHT/UP/DOWN
    1. Insert a Button Element
    2. Select ActionsWhenPressed, press Add
    3. Select "HomeSeer: Run a HomeSeer script with values from Elements"
    4. Leave ScriptProcedure Main
    5. In script type:

    Code:
    &hs.GetUrl("http://192.168.0.10:80/cgi-bin/CGIProxy.fcgi?cmd=ptzMoveLeft&usr=*****&pwd=******","",True,80)
    Press OK

    6. Select ActionsWhenReleased, press Add
    7. Select "HomeSeer: Run a HomeSeer script with values from Elements"
    8. Leave ScriptProcedure Main
    9. In script type:
    Code:
    &hs.GetUrl("http://192.168.0.10:80/cgi-bin/CGIProxy.fcgi?cmd=ptzStopRun&usr=*****&pwd=******","",True,80)
    10. Press OK


    Adding a Preset

    1. Insert a Button Element
    2. Select ActionsWhenReleased, press Add
    3. Select "HomeSeer: Run a HomeSeer script with values from Elements"
    4. Leave ScriptProcedure Main
    5. In script type:
    Code:
    &hs.GetUrl("http://192.168.0.10:80/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Kitchen&usr=*****&pwd=******","",True,80)
    6. Press OK
    OpEx: Case Sensitive 'kitchen' will not work if Preset is 'Kitchen'


    Ok so this is the basics to get you started; in the next bit will cover making:

    - Events in HS3
    - Foscam Virtual Controls
    - Status Tracking of FOSCAMs
    Attached Files
    Last edited by smokeycoles; June 5, 2016, 08:13 AM.

    #2
    Step 2 Creating events

    Ok so I created all the events in the pictures and used some script to build it; you should be able to copy it and use it.

    Create a file: HomeSeer HS3\scripts\camera.vb

    Use notepad and paste:
    Code:
    '----------------------------------
    ' Camera Script by Smokey
    '----------------------------------
    
    Dim cruise_toggle As Boolean
    Dim record As Boolean
    Dim zooming As Boolean
    Dim switchIR_toggle As Boolean
    Dim switchIRleds_toggle As Boolean
    
    Sub Main(parm As Object)
    End Sub
    
    
    ' Presets
    '----------------------------------
    Sub Preset_FrontDoor(parm As Object)
    	hs.writelog("Camera","Hallway Camera moved to Front Door")
    	hs.GetUrl("http://192.168.1.51:80/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Home&usr=*****&pwd=*****","",True,80)
    	hs.SetDeviceValueByRef(526, 4, True)
    End Sub
    
    Sub Preset_FrontRoom(parm As Object)
    	hs.writelog("Camera","Hallway Camera moved to Front Room")
    	hs.GetUrl("http://192.168.1.51:80/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Bathroom&usr=*****&pwd=*****","",True,80)
    	hs.SetDeviceValueByRef(526, 5, True)
    End Sub
    
    Sub Preset_Kitchen(parm As Object)
    	hs.writelog("Camera","Hallway Camera moved to Kitchen")
    	hs.GetUrl("http://192.168.1.51:80/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Kitchen&usr=*****&pwd=*****","",True,80)
    	hs.SetDeviceValueByRef(526, 6, True)
    End Sub
    
    
    ' Cruises
    '----------------------------------
    Sub HorrizontalScroll(IPaddress As String)
    	hs.writelog("Camera","Horizontal Scroll Variable for camera " & IPaddress & " is: " & cruise_toggle)
    	If cruise_toggle = False Then
    		cruise_toggle = True
    		hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=ptzStartCruise&mapName=Horizontal&usr=*****&pwd=*****","",True,80)
    		If IPaddress = "192.168.1.51:80"
    			hs.SetDeviceValueByRef(526, 2, True)
    		Else
    		End If
    	Else If cruise_toggle = True Then
    		cruise_toggle = False
    		hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=ptzStopCruise&usr=*****&pwd=*****","",True,80)
    		If IPaddress = "192.168.1.51:80"
    			hs.SetDeviceValueByRef(526, 0, True)
    		Else
    		End If
    	Else
    		hs.writelog("Camera","Vertical Scroll Error")	
    	End If
    End Sub
    
    
    Sub VerticalScroll(IPaddress As String)
    	hs.writelog("Camera","Vertical Scroll Variable for camera " & IPaddress & " is: " & cruise_toggle)
    	If cruise_toggle = False Then
    		hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=ptzStartCruise&mapName=Vertical&usr=*****&pwd=*****","",True,80)
    		cruise_toggle = True
    		If IPaddress = "192.168.1.51:80"
    			hs.SetDeviceValueByRef(526, 3, True)
    		Else
    		End If
    	Else If cruise_toggle = True Then
    		hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=ptzStopCruise&usr=*****&pwd=*****","",True,80)
    		cruise_toggle = False
    		If IPaddress = "192.168.1.51:80"
    			hs.SetDeviceValueByRef(526, 0, True)
    		Else
    		End If
    	Else
    		hs.writelog("Camera","Vertical Scroll Error")	
    	End If
    End Sub
    
    Sub ScrollStop(IPaddress As String)
    	hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=ptzStopCruise&usr=*****&pwd=*****","",True,80)
    End Sub
    
    
    ' Directions
    '----------------------------------
    Sub MoveLeft(IPaddress As String)
    	hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=ptzMoveLeft&usr=*****&pwd=*****","",True,80)
    		If IPaddress = "192.168.1.51:80"
    			hs.SetDeviceValueByRef(526, 1, True)
    		Else
    		End If
    End Sub
    
    Sub MoveRight(IPaddress As String)
    	hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=ptzMoveRight&usr=*****&pwd=*****","",True,80)
    		If IPaddress = "192.168.1.51:80"
    			hs.SetDeviceValueByRef(526, 1, True)
    		Else
    		End If
    End Sub
    
    Sub MoveUp(IPaddress As String)
    	hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=ptzMoveUp&usr=*****&pwd=*****","",True,80)
    		If IPaddress = "192.168.1.51:80"
    			hs.SetDeviceValueByRef(526, 1, True)
    		Else
    		End If
    End Sub
    
    Sub MoveDown(IPaddress As String)
    	hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=ptzMoveDown&usr=*****&pwd=*****","",True,80)
    		If IPaddress = "192.168.1.51:80"
    			hs.SetDeviceValueByRef(526, 1, True)
    		Else
    		End If
    End Sub
    
    Sub MoveStop(IPaddress As String)
    	hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=ptzStopRun&usr=*****&pwd=*****","",True,80)
    End Sub
    
    
    ' Recording
    '----------------------------------
    Sub Recording(IPaddress As String)
    	hs.writelog("Camera","Recording Variable for camera " & IPaddress & " is: " & record)
    	If record = False Then
    		hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=StartRecord&usr=*****&pwd=*****","",True,80)
    		record = True
    		If IPaddress = "192.168.1.51:80"
    			hs.SetDeviceValueByRef(530, 0, True)
    		Else
    		End If
    	Else If record = True Then
    		hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=StopRecord&usr=*****&pwd=*****","",True,80)
    		record = False
    		If IPaddress = "192.168.1.51:80"
    			hs.SetDeviceValueByRef(530, 1, True)
    		Else
    		End If
    	Else
    		hs.writelog("Camera","Recording Error")	
    	End If
    End Sub
    
    
    ' Zoom
    '----------------------------------
    Sub ZoomIn(IPaddress As String)
    	hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=zoomIn&usr=*****&pwd=*****","",True,80)
    End Sub
    
    Sub ZoomOut(IPaddress As String)
    	hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=zoomOut&usr=*****&pwd=*****","",True,80)
    End Sub
    
    Sub ZoomStop(IPaddress As String)
    	hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=zoomStop&usr=*****&pwd=*****","",True,80)
    End Sub
    
    
    ' IR
    '----------------------------------
    Sub SwitchIRMode(IPaddress As String)
    	hs.writelog("Camera","Switch IR Mode Variable for camera " & IPaddress & " is: " & switchIR_toggle)
    	If switchIR_toggle = False Then
    		hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=setInfraLedConfig&mode=0&usr=*****&pwd=*****","",True,80)
    		switchIR_toggle = True
    		If IPaddress = "192.168.1.51:80"
    			hs.SetDeviceValueByRef(531, 0, True)
    		Else
    		End If
    	Else If switchIR_toggle = True Then
    		hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=setInfraLedConfig&mode=1&usr=*****&pwd=*****","",True,80)
    		switchIR_toggle = False
    		If IPaddress = "192.168.1.51:80"
    			hs.SetDeviceValueByRef(531, 1, True)
    		Else
    		End If
    	Else
    		hs.writelog("Camera","Switching IR Mode Error")	
    	End If
    End Sub
    
    Sub SwitchIRleds(IPaddress As String)
    	hs.writelog("Camera","Switch IR On/Off Variable for camera " & IPaddress & " is: " & switchIRleds_toggle)
    	If switchIRleds_toggle = False Then
    		hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=closeInfraLed&amp&usr=*****&pwd=*****","",True,80)
    		switchIRleds_toggle = True
    		If IPaddress = "192.168.1.51:80"
    			hs.SetDeviceValueByRef(532, 0, True)
    		Else
    		End If
    	Else If switchIRleds_toggle = True Then
    		hs.GetUrl("http://" & IPaddress & "/cgi-bin/CGIProxy.fcgi?cmd=openInfraLed&amp&usr=*****&pwd=*****","",True,80)
    		switchIRleds_toggle = False
    		If IPaddress = "192.168.1.51:80"
    			hs.SetDeviceValueByRef(532, 1, True)
    		Else
    		End If
    	Else
    		hs.writelog("Camera","Switching IR On/Off Error")	
    	End If
    End Sub

    Note the script uses hs.SetDevices (which we have not built yet, these are the virtual devices)...
    I recommended commenting these out until your ready to do the StatusTracking at the end.
    Attached Files
    Last edited by smokeycoles; June 5, 2016, 08:58 AM.

    Comment


      #3
      Step 3 Linking the Events in HSTouch

      It is very important to understand there are double events and single events:

      These buttons will need 2 events (Onpress & Onrelease) :
      • Zoom In
      • Zoom Out
      • Up
      • Down
      • Left
      • Right


      These buttons need 1 events - onrelease (as these are toggled by the script & virtual devices and therefore provide status tracking)
      • Preset Kitchen
      • Preset FrontRoom
      • Preset FrontDoor
      • Record
      • IR LED ON/OFF
      • IR MODE manual/auto
      • Cruise Horizontal
      • Cruise Vertical



      So in HS TOUCH

      The 4 directions buttons, you need to assign the Events:
      1. Directions Left Event
      2. Directions Right Event
      3. Directions Up Event
      4. Directions Down Event

      to onPress for the correct button

      Then for all the four above, assign the Directions Stop Event to onRelease

      Do the same for the below in HSTouch:
      ZoomIn (onPress) & zoomStop (onRelease)
      ZoomOut (onPress) & zoomStop (onRelease)


      You should be able to test and work.
      Remember you have not made the virtual devices so the script won't work without commenting out any lines which have a refID in the camera.vb script. Once commented out, it should work!


      Now assign the single events to all onRelease buttons (you should be able to guess which ones):
      • Preset Kitchen
      • Preset FrontRoom
      • Preset FrontDoor
      • Record
      • IR LED ON/OFF
      • IR MODE manual/auto
      • Cruise Horizontal
      • Cruise Vertical
      Attached Files
      Last edited by smokeycoles; June 5, 2016, 08:34 AM.

      Comment


        #4
        Step 4 Creating Virtual Devices

        Create the following devices; and set the devices status similar.

        Some of the previous events have a manual trigger and a on change event.
        Basically the manual trigger is for HSTouch; and the onchange for the HS Web Interface.

        To improve it and I have only just realised.
        Delete the manual triggers in the events and change the HSTouch onRelease event to alter the virtual devices.
        Attached Files
        Last edited by smokeycoles; June 5, 2016, 09:00 AM.

        Comment


          #5
          Step 5 Status Tracking

          In HSTouch

          Go to the button, select Status Tracking Normal. Find the virtual device and use Status Image.

          To customize the icons change the cell above and use the values for the images above.
          * Note I had a number of problems with buttons not showing, this is where you deploy, you need to restart your application.
          Especially on Android.

          Do this for each of the virtual devices which are:
          • Recording
          • Movement (Presets & Scrolls/Cruises & Manual)
          • LEDS On/Off
          • IR Mode




          Hey Presto you have a working interface with Status Tracking, telling you what the camera is doing and where it is!

          Once you have built one, you can build others much easier following the same template and just adding parts to the vb script.
          I added two other devices in an hour and made the screens, you can simply copy the devices, events and HSTouch screens and then just make edits.

          Expect to spend a day on this, and stock up on tea & biscuits.
          I promise it is worth it when you use it.



          I wanted to contribute something back to the forum, there have been a lot of people and HS pioneers who have helped me this weekend, and I would like to say a thank you.


          Enjoy
          Attached Files
          Last edited by smokeycoles; June 5, 2016, 10:32 AM.

          Comment


            #6
            Please Help

            I like your code, but I'd like to pass the IP address as a parameter from an element. Do you know if I can use a variable in the GetURL command and if yes, what the syntax would be? I've been trying:

            Sub Main(ByVal parms as Object)

            Dim page,page2 As String
            Dim arg1 As String

            arg1 = parms(0)

            page = hs.GetURL("192.168.1.231:80","/cgi_bin/CGIProxy.fcgi?cmd=setPTZSpeed&speed=3&usr=admin&pwd=*****",T RUE,80 )

            page2 = hs.GetURL(arg1,"/cgi_bin/CGIProxy.fcgi?cmd=ptzMoveLeft&usr=admin&pwd=*****",TRUE,80)

            hs.writelog ("IP Address is:",arg1)

            End Sub


            But with no luck using arg1. Any help would be greatly appreciated.
            Thanks.

            Comment


              #7
              Great setup. Thank you very much! Glad you took the time to write this up, very good detail as well.

              Do you have the url for turning on/off mic and sound? I cannot seem to find an api anywhere. I am using Foscam FI9828W.

              Thank you again!

              Comment


                #8
                What does this mean? Are you saying to delete the events I just created or change how the event is triggered?

                "To improve it and I have only just realised.
                Delete the manual triggers in the events and change the HSTouch onRelease event to alter the virtual devices."

                Comment


                  #9
                  Thank you very much, I am sure someone could do better than me as this was my first
                  tutorial and I wanted to give something back to the board for others helping me so frequently. I found a lot of different information on here so I figured I would write a step by step...

                  I do not have the mic on/off command, if you find it - do post it.
                  This would be handy to have and it can be done as it is on iPhone Apps.
                  But I can remember at the time - I couldn't find it at the time and the Foscam forums are not very helpful (the main guy just refers everyone to a php script which is no help for HSTouch users)...

                  Change the onRelease in HSTouch.
                  This way when you pan left (it moves left until you send a stop command) you would setup HSTouch:
                  onrelease = loads the event stop,
                  onpress = loads the event left



                  John, I remember I originally tried passing the IP so it can be done yes - however for some reason I remember having problems with this later on for some of the things I wanted my screen to do with multiple cameras...
                  Now better programmers would have more luck with me so it may be worth asking others.


                  If this helps you in developing your versions, please post your end results up as its always good to see.

                  Cheers Chris

                  Comment


                    #10
                    While trying to get the HS "purple" video template to work, I basically did what you did, created an image with a still-shot URL and told HST it was a video and to refresh it as fast as possible (0). Unfortunately, that was only 1 frame per second at best. Is that about all HST is capable of? It is a 800x1200 sized window, but the Foscam browser plugin refreshes at normal video speeds. So what I ended up doing was creating a text box and entering the IP address of the Foscam Plugin, so it displays in HSTouch with all the controls at normal video speed. I hate that I have to login every time, but...

                    I guess I don't understand what the config in the HST plugin config section is if it doesn't do anything?? I only bought the Foscam because I thought it would be completely effortless plug & play - lol. I have a lot of problems with my particular model of Foscam dropping off of the network. I'm afraid to try another Foscam, so I may experiment with another brand since there seems to be no advantage to Foscam automatically working in HST.

                    Comment


                      #11
                      I have the 8910W and the 9831W foscam cameras and they work great. Homeseer found them instantly and I can view them through HSTouch.

                      Comment


                        #12
                        following this thread.

                        Comment


                          #13
                          Thanks SO much Smokeycoles for your tutorial, it has made this Foscam setup a little more bearable. So just to recap we can still only get the image refreshed once a second in HSTouch and no live feed at all? Or can you actually embed a VLC player in a HSTouch window with the rtsp://[username]:[password]@[ip]:[port]/videoMain feed?

                          Once again, thank you so much this has helped tremendously...

                          Comment


                            #14
                            Foscam Passwords Trip Up HomeSeer

                            Thank you for your informative tutorial. It continues to be a big help as I sort through setting up my cameras.

                            I discovered after much effort and pain that HomeSeer cannot resolve the PTZ action commands for my Foscam R2 camera if the Foscam camera has any special characters in its user name or password! I had a devil of a time with my setup until I revised my camera password to be letters and numbers only. The Foscam app encourages the use of special characters in the password, but HomeSeer can't resolve them. I did not see this mentioned in my review of HSTouch Help files or in perusing the Message Board.

                            Thanks,
                            Sam Gibson

                            Comment


                              #15
                              Originally posted by SamGibson View Post
                              I discovered after much effort and pain that HomeSeer cannot resolve the PTZ action commands for my Foscam R2 camera if the Foscam camera has any special characters in its user name or password! I had a devil of a time with my setup until I revised my camera password to be letters and numbers only. The Foscam app encourages the use of special characters in the password, but HomeSeer can't resolve them. I did not see this mentioned in my review of HSTouch Help files or in perusing the Message Board.

                              Thanks,
                              Sam Gibson

                              Interesting... I have one special character in the password for my FOSCAM cameras. It may be the special character you are using. I am currently using a underscore and it works just fine in and out of HomeSeer. I know some special characters can provide opportunities in passwords and I try to navigate away from them... The at symbol is one that can give trouble, sometimes the ampersand.

                              Hope this helps...
                              Billy

                              Comment

                              Working...
                              X