No announcement yet.

Need your help for Foscam WebCam status script

  • 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 :

    It's return me the following variables:

    var id='000DC5D507D5'; var sys_ver=''; var app_ver=''; 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.


    Nobody can help me?


      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("","/get_status.cgi",False,80)

      Instr(1,Result,"var alarm_status=1",1) > 0 then 
      .setdevicestring (DeviceCode,"Camera 1 - motion detected",True)
      hs.setdevicestatus (DeviceCode,"2")
      Instr(1,Result,"var alarm_status=0",1) > 
      .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


        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

        Case CameraNo
        Case "1"
        StrIP ""  'Include port i.e.
                    StrUser = "ptz"  '
        User Name
        "ptz"  'Password
                    StrDeviceCode = "A1"  '
        Device Code
        Case "2"
        StrIP ""
        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)

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

        End Sub 


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


            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