Announcement

Collapse
No announcement yet.

Need your help for Foscam WebCam status script

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

    Need your help for Foscam WebCam status script

    Hi everybody,

    This my first post on this forum.
    I need your help and will try to simply explain my problem with my French English :-)

    I need to create un HS Script who will get the value of the variable "Alarm_Status" of my 3 Cams FOSCAM FI8918W.

    Each Cam have have a status that I can see in a html page : http://192.168.2.6/get_status.cgi

    It's return me the following variables:

    var id='000DC5D507D5'; var sys_ver='11.22.2.38'; var app_ver='2.4.18.17'; var alias='Cam1'; var now=1329504777; var tz=0; var alarm_status=0; var ddns_status=0; var ddns_host=''; var oray_type=0; var upnp_status=0; var p2p_status=0; var p2p_local_port=22980; var msn_status=0;

    The script I want to create will run in loop, must get alarm_status value (0 when motion detection is Off and 1 when motion detection is On)
    and set another variable that I will use with a Virtual Device in HS, in order to trigger a alarm with siren.

    Is thers somebody who have a script example who can help me???

    Thanks in advance.
    Stephane

    </pre>

    #2
    Nobody can help me?

    Comment


      #3
      Perhaps something like this will work:

      PHP Code:
      Sub Main(ByVal Parm As Object)
      Dim DeviceCode As String "A1"
      Dim Result As String hs.GetURL("http://192.168.2.6","/get_status.cgi",False,80)

      If 
      Instr(1,Result,"var alarm_status=1",1) > 0 then 
          hs
      .setdevicestring (DeviceCode,"Camera 1 - motion detected",True)
          
      hs.setdevicestatus (DeviceCode,"2")
      elseif 
      Instr(1,Result,"var alarm_status=0",1) > 
          hs
      .setdevicestring(DeviceCode,"Camera 1 - no motion detected",True)
          
      hs.setdevicestatus (DeviceCode,"3")
      end if

      End sub 
      You will need to create a virtual device and set "A1" in the script to the device code chosen. The device status will be on with motion and off with no motion.

      You need to save the code to a text file with the extension .vb
      Jon

      Comment


        #4
        In addition to Jon00's code I've added the ability to run the script from a event and just pass in the Camera number, this will then update the relevant Device Code for that camera. I also added user name and password details as my camera's require it.

        You just need to configure the Case statements for each camera that you have and also create the device codes.

        PHP Code:
        Sub Main(ByVal CameraNo As String)
            
        Dim StrResponse As String
            Dim StrCommand 
        As String
            Dim StrIP 
        As String
            Dim StrUser 
        As String
            Dim StrPwd 
        As String
            Dim StrDeviceCode 
        As String

            Select 
        Case CameraNo
                
        Case "1"
                    
        StrIP "192.168.0.188:88"  'Include port i.e. 192.168.0.1:80
                    StrUser = "ptz"  '
        User Name
                    StrPwd 
        "ptz"  'Password
                    StrDeviceCode = "A1"  '
        Device Code
                
        Case "2"
                    
        StrIP "192.168.0.189:89"
                    
        StrUser "ptz"
                    
        StrPwd "ptz"
                    
        StrDeviceCode "A2"

                    'you can add more Case statements if you have more cameras

                Case Else
                    hs.WriteLog("Camera Status", "Invalid Camera Number " & CameraNo & "  passed.")
                    Exit Sub
            End Select

            StrCommand = "http://" & StrIP & "/get_status.cgi?user=" & StrUser & "&pwd=" & StrPwd
            StrResponse = hs.URLAction(StrCommand, "GET", "", "")
            ' 
        hs.WriteLog("Camera""Camera=" CameraNo "  Command=" StrCommand "  Response=" StrResponse)

            If 
        Instr(1StrResponse"var alarm_status=1"1) > 0 Then
                hs
        .setdevicestring(StrDeviceCode"Motion detected"True)
                
        hs.setdevicestatus(StrDeviceCode"2")
                
        hs.WriteLog("Camera Status""Camera " CameraNo " Motion Detected")
            ElseIf 
        Instr(1StrResponse"var alarm_status=0"1) > 0 Then
                hs
        .setdevicestring(StrDeviceCode"No motion detected"True)
                
        hs.setdevicestatus(StrDeviceCode"3")
                
        hs.WriteLog("Camera Status""Camera " CameraNo " No Motion Detected")
            
        End If

        End Sub 

        Comment


          #5
          Thanks a lot guys. I will try this ASAP and I will give you a feedback.

          Comment


            #6
            I have tried your code and it works very well, thanx.
            I m a newbie in homeseer's scripting..
            Can you tell me how to launch some events on motion detected?


            Thank you

            Comment

            Working...
            X