Announcement

Collapse
No announcement yet.

WAFNet Announce times.

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

  • WAFNet Announce times.

    I have been using WAFnet CallerID for quite awhile. I recently updated to HS2.1. I remember when I first set up WAF that I put in some code in the HS startup are to set the announce times to not announce calls after 10pm and before 8am. Since the update it always announces.. I cant seem to remember how to change this??

  • #2
    I put this in the actual script (the .vbs one in the scripts directory) and not in the startup.txt file.

    current_time = hour(now)

    If current_time >= 8 And current_time <= 22 Then

    hs.Speak "Call from " & s_phone_list_name
    hs.Speak "Call from " & s_phone_list_name

    End If

    BUT: I'm still using HS 1.7x .
    --------------------------------------------------
    **** Do You "Cocoon"? ****

    Comment


    • #3
      Is there a certain point in the .vbs you have to put it?
      I did have a script in there, thats where I added it not in the startup. I made a mistake..

      Comment


      • #4
        Here is a copy of my script below. Note that I'm sure there are a lot better ways to do this and this script sort of "evolved".

        I added features as I needed without "looking" at the entire script.

        For instance there is a section in there that pushes the caller id to MainLobby server for it's pop up window (when that was working before the ML3 upgrade ).

        Also, I used JWilson56's suggestion on getting the last ten caller's to HomeSeer devices (so I could display a MainLobby screen with this information) and formated the time and numbers for that display.

        Remember that I'm still using HS1.7 and I'm wondering why your script would stop working with HS2.1 when everyone has said the WAFCallerID script works with this new version.

        Hope this helps.

        Code:
        Sub main
        
        End Sub
        
        Function process_ncid_data(what_parameters)
        
          Dim s_paramaters
          Dim s_ncid_date
          Dim s_ncid_name
          Dim s_ncid_number
          Dim s_phone_list_name
          Dim s_phone_list_code
          Dim current_time
        
        ' The following variables are used for JWilson56 Caller ID storage script
        	Dim i
        	Dim xs
        	Dim s_yac_msg
        	Dim yac_time
        	Dim ancid
        	Dim x
        	Dim y
          
          ' Split incoming data into component parts of 
          ' date, name and number.
          s_paramaters = split(what_parameters,Chr(9))
          s_ncid_date = s_paramaters(0)
          s_ncid_name = s_paramaters(1)
          s_ncid_number = s_paramaters(2)
        
          
          i_ret = find_match(s_ncid_number, s_phone_list_name, s_phone_list_code)   
          
          If i_ret = -1 Then
            ' No match was found in the phone list text file.
            ' Assign NCID name to phone list variable and 
            ' assign a code of 2000 (Others) to caller.
            s_phone_list_name = s_ncid_name
            s_phone_list_code = 2000
            
            ' Add new caller to text file with a default
            ' code of 2000.
            i_ret = add_caller_to_file(s_ncid_number, s_ncid_name, 2000)     
          End If
        
          ' Create a version of time that does not include seconds. 
          ' Time is expressed in 24 hour format.
        
          
        current_time = hour(now)
        
        ' Friends -- announced 7AM - 10PM  ********** 
        
        If current_time >= 7 And current_time <= 22 Then
        
        'get caller ID to MainLobby Server (note: this broke with ML3)
        
        hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLCallerID|SendCID:" & cstr(s_ncid_name) & "~" & cstr(s_ncid_number) 
        
        'announce caller:      
        	hs.Speak "Call from " & s_phone_list_name
        	hs.Speak "Call from " & s_phone_list_name 
        End If
        
        ' Insert JWilson56 Caller ID storage Script below:
        
        'format phone number to "(xxx) xxx-xxx" format:
        
        ancid = "(" & Left(s_ncid_number,3) & ") " & Mid(s_ncid_number,4,3) & "-" & Right(s_ncid_number,4)
        
        ' Get Current Time WITHOUT Seconds:
        
        x = datepart("h", time()) 'gets military style of hours (0-23)
        
        y = time 'current time (this will be the value of "stime")
        
        	if x=0 then stime = left(y,5) & " AM"
        	if x>0 and x<10 then stime = Left(y,4) & " AM"
        	if x>9 and x<12 then stime = Left(y,5) & " AM"
        	if x=12 then stime = Left(y,5) & " PM"
        	if x>12 and x<22 then stime = Left(y,4) & " PM"
        	if x>21 then stime = Left(y,5) & " PM"
        
        	s_yac_msg = date & " " & stime & ", " & s_phone_list_name & " " & ancid
        
        'Stuff last ten callers into HomeSeer Devices Q1 through Q10
        ' The device will have the format "7/10/06 3:31PM, Name of Caller, (xxx) xxx-xxx"
        
        	for xs = 9 to 1 Step -1
        	i = hs.devicestring ("q"&(xs))
        	hs.SetDeviceString "q"& (xs+1), i
        	Next
        	hs.SetDeviceString "q1", s_yac_msg
        
        'Send emails whenever a call comes in
        
        hs.sendemail "yourname@address.com, anothername@address.com","fromname@address.com","Home Phone Call Received", s_yac_msg
        
        
          '--------------------------------------------
          ' Example 4: E-mail the CID Info. Using custom 
          '            announcement name, if the 
          '            Example 3 code above is active,
          '            and a match is found, otherwise
          '            send TelCo provided information.
          '            Customize To and From E-mail 
          '            addresses below.
          '--------------------------------------------
          'Dim s_to_email_address
          'Dim s_from_email_address
          'Dim s_email_subject
          'Dim s_email_body
          '
          's_to_email_address = "joe@schmoe.com"
          's_from_email_address = "joe@schmoe.com"
          's_email_subject = "Someone just called!"
          '
          ' Create the message body
          'If s_phone_list_name <> "" Then
          '  s_email_body = "Call from: " & s_phone_list_name
          'Else  
          '  s_email_body = "Call from: " & s_ncid_name  
          'End If
          's_email_body = s_email_body & vbcr & "Phone number: " & s_ncid_number & vbcr & "Date: " & s_ncid_date
          '
          ' Send the E-mail message
          'hs.SendEmail s_to_email_address, s_from_email_address, s_email_subject, s_email_body 
        
        End Function  
          
          
        '************************************************************
        '* Search the phone list file for a matching number. If found
        '* return the text to be announced and the code number 
        '* associated with the caller.
        '************************************************************
        Function find_match(what_number, what_name, what_phone_code)
        
          Dim fso
          Dim file
          Dim s_line
          Dim s_file_name
          Dim s_file_data
          
          find_match = -1
          
          ' Retrieve phone list file name from INI
          s_file_name = hs.GetINISetting ("Settings","s_phone_list_file","","WAF-NetCallerID.ini")
          
          Set fso = CreateObject("Scripting.FileSystemObject")
          Set file = fso.OpenTextFile(hs.GetAppPath & "\DATA\WAF-NetCallerID\" & s_file_name,1,True,0)
        
          ' Loop through phone list file
          Do While Not file.AtEndOfStream
        
            s_line = file.ReadLine
        
            ' Ignore comment lines starting with ";"
            If left(s_line,1) <> ";" Then
        
              s_file_data = split(s_line,Chr(9))
              
              ' Ensure that there are 3 data items
              If UBound(s_file_data) = 2 Then
                
                ' Look for number match
                If s_file_data(0) = what_number Then 
                  ' Match found. Assign custom name and
                  ' code values and exit function.
                  what_phone_code = s_file_data(1)
                  what_name = s_file_data(2)
                  find_match = 0 
                  Exit Do
                End If
              
              End If
            
            End If
        
          Loop
          
          ' Clean up
          file.Close
          Set file = Nothing
          Set fso = Nothing
        
        End Function
        
        
        '************************************************************
        '* Add the caller's name and number to the end of the phone
        '* list file.
        '************************************************************
        Function add_caller_to_file(what_number, what_name, what_phone_code)     
        
          Dim fso
          Dim file
          Dim s_line
          Dim s_file_name
          Dim s_file_data
          
          add_caller_to_file = -1
          
          ' Retrieve phone list file name from INI
          s_file_name = hs.GetINISetting ("Settings","s_phone_list_file","","WAF-NetCallerID.ini")
          
          Set fso = CreateObject("Scripting.FileSystemObject")
          
          ' Check to see if file exists. If not, create it.
          If Not fso.FileExists(s_file_name) Then
            Set file = fso.CreateTextFile(s_file_name)
          End If
        
          ' Open the file for writing.
          Set file = fso.OpenTextFile(hs.GetAppPath & "\DATA\WAF-NetCallerID\" & s_file_name,8,True)  
          
          ' Write the CID data to the phone list text
          ' file in the following format:
          ' Phone Number <Tab character> Phone Group Code <Tab character> Telco Provided Name
          file.WriteLine what_number & Chr(9) & what_phone_code & Chr(9) & what_name
          add_caller_to_file = 0
          
          ' Notify user that name has been added to the file.
          'hs.Speak "A new number has been added to the phone list."
          
          ' Clean up
          file.Close
          Set file = Nothing
          Set fso = Nothing
        
        End Function
        Last edited by BraveSirRobbin; July 22nd, 2006, 07:08 PM.
        --------------------------------------------------
        **** Do You "Cocoon"? ****

        Comment


        • #5
          I dont know, mine still announces fine it just announces any time of day...
          Thanks though for the script I am going to experiment.!

          Comment


          • #6
            pp,

            Take a look at your WAF-NetCallerID-Sample-CID-Processing.vbs file in the Exampe 3 section. I think this section of code might be what is causing you trouble:

            PHP Code:
                 Case (s_phone_list_code >= 1000 and s_phone_list_code <= 1999)
                   
            ' Friends -- announced 8AM - 10PM (note the space in " 8:00")
                   If current_time >= " 8:00" And current_time <="22:00" Then
                     hs.Speak "Friend call from " & s_phone_list_name 
                   End If 

            Try placing a zero before and pre-noon times to see if that resolves the issue. That is to say, make it look like the following:

            PHP Code:
                Case (s_phone_list_code >= 1000 and s_phone_list_code <= 1999)
                   
            ' Friends -- announced 8AM - 10PM (note the space in " 8:00")
                   If current_time >= "08:00" And current_time <="22:00" Then
                     hs.Speak "Friend call from " & s_phone_list_name 
                   End If 
            I remembered this coming up in the thread: http://forums.homeseer.com/showthrea...t=current_time

            Please let me know if you need more help,

            --David

            Comment

            Working...
            X