Announcement

Collapse
No announcement yet.

CID flag to Device

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

    CID flag to Device

    Hi All, I hope this is the right place to ask this question.

    I'm looking for a way to recreate some functions of SnevlCID package which is no longer supported under HS3.

    Under HS2 the package could assign a device to accept a CID flag, I used this device to change the colour of a HSTouch button when ON indicating a received call while absent. Touching this button would take the user to a screen where the last ten callers were visible and the CID device was also turned off, aka reset.

    I haven't a clue where to start to do this in HS3.

    Appreciate any help.

    #2
    Should be relatively easy with a couple of virtual devices, event and a script to populate the last 10 callers. I have a script like that and will post it later today. When a new call is received, one virtual device would be turned on, the script will run and update the last 10 callers device. In HSTouch, you would use the status of the first device to control the button, and when pressed, run an immediate script statement to turn off the virtual device and take you to the page that displays the last 10 callers. I don't use HS Touch, so can't help with the details there, but I know it can be done.

    Cheers
    Al
    HS 3.0.0.548: 1990 Devices 1172 Events
    Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

    Comment


      #3
      Here's a vbscript file that I used with HS2 and then converted to work with HS3. I believe it was originally written by someone else, but I have made quite a few modifications to it over the years. Since it is vbscript, it will only work with HS3 running on Windows. It could be converted to vb.net.

      Code:
      sub main()
      
      cPath = hs.GetAppPAth & "\data\HSPhone\callers.log"
      'hs.writelog "Last 10 Calls", cPath
      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Set objTextFile = objFSO.OpenTextFile(cPath)
      
      '==== setup an array to step through backwards -
      '==== to display the latest calls first, instead of last.
      X=0
      
      Do While Not objTextFile.AtEndOfStream
      	Phone1 = ""
      	Phone1=objTextFile.ReadLine
      	result = instr(1,Phone1,"Number:")
      	Phone = trim(mid(Phone1,result + 8,12))
      	if Phone <> Block1 and Phone <> Block2 and result > 0 then
      		X=X+1
      		redim preserve CallLog(X) 
      		CallLog(X) = Phone1
      		TotCalls = X
      	end if
      loop
      
      L=0
      EOList = 10
      tclass = "tablerowodd"
      Last10Calls = "<tr><td class='tableheader' colspan='2'><a href='/hspw?page=callerid'>Last 10 Calls</a></td></tr>"
      
      For X = ubound(CallLog) to 0 step -1
      	LineString = CallLog(X)
      	LineString = Replace(LineString,"<","")
      	LineString = Replace(LineString,">","")
      
      	if instr(1,LineString,"~!~Caller ID~!~") then
      
      		Last10Calls = Last10Calls + "<tr><TD width=40% class='" & tclass & "' valign='middle' align='center'><font size=-2>" 
      		pDate = mid(LineString,1,10)
      		'hs.writelog "Last10",pDate
      		result = instr(1,pDate," ") 
      		if result <> 0  then pDate = mid(pDate,1,Result-1)
      		pDate = left(trim(pDate),len(pDate)-5)
      		If IsDate(pDate) Then 
      			If DateDiff("d",pDate,Date) = 0 Then 
      				pDate = "Today"
      			ElseIf DateDiff("d",pDate,Date) = 1 Then
      				pDate = "Yesterday"
      			End If
      		End If
      		Last10Calls = Last10Calls +  pDate
      
      		pTime = mid(LineString,5,20)
      		result = instr(1,pTime,"~") 
      		result2 = instr(1,pTime," ")
      		if result <> 0  then pTime = mid(pTime,result2,Result-result2)
      		'hs.writelog "Last10",pTime
      		colon=instrRev(pTime,":")
      		'pTime=Left(pTime,colon-1)+ "&nbsp;" + Right(pTime,2)
      		Last10Calls = Last10Calls + " " + pTime
      
      		Last10Calls = Last10Calls +  "<TD width=60% class='" & tclass & "' valign='middle' align='center'><font size=-2>" 
      		Caller=""
      		result = instr(1,LineString,"Name:")
      		Caller = trim(mid(LineString,result+5,16))
      		Phone=""
      		result = instr(1,LineString,"Number:")
      		Phone = Trim(mid(LineString,result+8,10))
      		Phone = Left(Phone,3) & "-" & Mid(Phone,4,3) & "-" & Right(Phone,4)
      		'hs.writelog "Phone Caller ID","*" & Phone & "*"
      		adr_count = hsp.ADRCount
      		For i = 1 To adr_count
      			Set contact = hsp.ADRGet(i)
      			If Phone = Trim(contact.home_phone) or Phone = Trim(contact.home_phone_2) or Phone = Trim(contact.cell_phone) or Phone = Trim(contact.cell_phone_2) or Phone = Trim(contact.business_phone) or Phone = Trim(contact.business_phone_2) Then
      				If contact.first <> "" Then
      					Caller = contact.first & " " & contact.last
      				ElseIf contact.company_name <> ""  Then
      					Caller = contact.company_name
      				Else
      					Caller = Phone
      				End If
      			End If
      		Next 
      		if UCase(Caller)="O" then Caller="Outside Call"
      		if UCase(Caller)="P" Then
      			Caller="Private" 
      			Phone = ""
      		End If
      		Caller = Caller & "<font size=-2> (" & Phone & ")"
      		Last10Calls = Last10Calls +  Caller
      
      		If tclass = "tablerowodd" Then
      			tclass = "tableroweven"
      		Else
      			tclass = "tablerowodd"
      		End If
      
      		L = L + 1
      	end if
      	if L = EOList then exit For
      	if L = TotalLimit then exit for
      Next
      Last10Calls = "<table border=0 width='100%'>" & Last10Calls +  "</table>"
      hs.SetDeviceString 1230,Last10Calls, True
      end sub
      You would need to edit the 2nd last line with the reference id of your virtual device that holds the last 10 calls and save as last10calls.txt in the scripts folder. Here's the event I use in conjunction with it:

      Click image for larger version

Name:	Capture.jpg
Views:	1
Size:	24.0 KB
ID:	1183862

      Hope that helps.

      Cheers
      Al
      HS 3.0.0.548: 1990 Devices 1172 Events
      Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

      Comment


        #4
        Thanks very much Al, your effort has got my wheels turning and although it was not perfect for my requirements in HS touch, as one device holds all 10 callers (nicely formatted). I am not cleaver enough to transfer the formatting to HSTouch.

        I hacked around today pulling sections from your and other scripts and managed to get Caller Name, Number and last changed time and date into a single device. I then copied the caller ID's to other devices leaving the newest caller id on the top (Only 3 devices for testing at the moment).

        Feeling very good at my attempt, I went for the acid test (actual calling) and found it failed. Not my script but HSPhone. The Problem is it only provides CID for the first call, on subsequent calls I can see the Ring Ring and the number passing through the log but HS just sits there quiet. it works again after restarting HS, but only once. I am using the W2C desktop box. Tried changing all sorts of relevant settings. Each time I saved the settings in HS3 Phone, I would get another CID operation when I tested. This appears to be a possible bug in HS3 Phone, but I'm not 100% sure yet as I'm no expert.

        Comment

        Working...
        X