Is there any way to identify a caller that identified as "blocked" in the address book? I know there's a flag in the address book entry for this, but I can't figure out how to get it into a script so I can test it. [I'd like to not bother sending CID info to my phones if the caller is blocked.]
Announcement
Collapse
No announcement yet.
Any way to identify a "blocked caller" in a script?
Collapse
This topic is closed.
X
X
-
There probably is a better way, but here is one workaround to get it.
In the external script file (in the IVR folder) that you are using, add something like this.
IF: $ADDRBOOK_BLOC; VBSCRIPT:hs.execx10 "r50","on",0,0; VBSCRIPT:hs.execx10 "r50","off",0,0
Where r50 is a virtual device that you created for this. Now when a blocked call comes in, r50 will be on. For a non-blocked call it will be off. You can use this device's status as a blocked flag in you script.
-
FWIW, here is a script I've been using to retrieve CID info and send it to local phones and HSTouch. I also use it to control announcements of family, to answer some calls immediately, and to log all calls. Among other things, it scans the address book for a match and returns info on matching entries.
If you change 'Family' to 'Blocked' in the line:
If objContact.cid_group_category = "Family" Then
you should be able to do whatever you want
Code:Sub Main(parm as object) Dim strName As String Dim strFileName As String Dim strApPath As String Dim strLogMessage As String Dim strNumber As String = "" Dim strCaller As String = "" Dim fApnd As Object Dim oFS As Object Dim ForAppending As Integer = 8 Dim I As Integer Dim bMatch As Boolean Dim intAdrCount As Integer = hsp.ADRCount Dim objContact As Scheduler.clsContact Dim strAdrName As String Dim strAnnounce As String strName = hsp.CIDName(1) strNumber = hsp.CIDNumber(1) hs.WriteLog("Number", strNumber) 'debug If strNumber.Length > 3 Then strNumber = strNumber.Substring(0, 3) & "-" & strNumber.Substring(3, 3) & "-" & strNumber.Substring(strNumber.Length - 4) End If hs.SetDeviceString("P53", strName) hs.SetDeviceLastChange("P53", Now) hs.SetDeviceString("P54", strNumber) hs.SetDeviceLastChange("P54", Now) 'hs.WriteLog(hs.DeviceString("P53"), hs.DeviceString("P54")) 'debug hsp.HIPSendLocalCID(1, strName, strNumber) 'hs.WriteLog("Count", CStr(intAdrCount)) 'debug '**************************************************************************************************** ' * * * * * * answer TOLL FREE and PRIVATE CALLs immediately * * * * * * If strName.Length > 8 Then If strName.Substring(0, 9) = "Toll Free" Then hsp.LineAnswer(1) End If If strName = "P" AND strNumber = "P" Then hsp.LineAnswer(1) If strName = "O" AND strNumber = "O" Then hsp.LineAnswer(1) '***************************************************************************************************** For I = 1 to intAdrCount 'Search the address book for a match objContact = hsp.ADRGet(I) If objContact.cell_phone = strNumber OR objContact.home_phone = strNumber OR objContact.business_phone = strNumber Then bMatch = True hs.WriteLog("AdrMatch", CStr(I) & " - " & strNumber) ' Match found strAdrName = objContact.FIRST & " " & objContact.LAST strName = strAdrName hsp.HIPSendLocalCID(1, strName, strNumber) If objContact.cid_group_category = "Family" Then strAnnounce = objContact.announce_local_wav hs.WriteLog("AdrMatchF", strAdrName) hs.Run("StartGeneralAnnounce.vb") hsp.WaitMS(100) hs.Speak(strAnnounce, True) hs.WaitSecs(1) hs.Speak(strName, True) hsp.WaitMS(100) hs.Run("RestoreRussoundGeneral.vb") End If I = intAdrCount End If Next 'I strApPath = hs.GetAppPath() & "\Config\" strFileName = strApPath & "CallerID.txt" strLogMessage = Now & " - " & strName & " - " & strNumber 'Save last caller info for HSTouch hs.SetDeviceString("P63", strName) hs.SetDeviceLastChange("P63", Now) hs.SetDeviceString("P64", strNumber) hs.SetDeviceLastChange("P64", Now) oFS = CreateObject("Scripting.FileSystemObject") ' use the open text file method to open a file to be added to rather than overwritten. fApnd = oFS.OpenTextFile(strFileName, ForAppending) ' write data to it. The writeline method adds a carriage return and linefeed to the end. fApnd.WriteLine(strLogMessage) fApnd.close() ' Close the file fApnd = Nothing oFS = Nothing End Sub
Mike____________________________________________________________ __________________
HS3 Pro Edition 3.0.0.548, NUC i3
HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti
Comment
-
Originally posted by Uncle Michael View PostFWIW, here is a script I've been using to retrieve CID info and send it to local phones and HSTouch. I also use it to control announcements of family, to answer some calls immediately, and to log all calls. Among other things, it scans the address book for a match and returns info on matching entries.
If you change 'Family' to 'Blocked' in the line:
If objContact.cid_group_category = "Family" Then
you should be able to do whatever you want
Code:Sub Main(parm as object) Dim strName As String Dim strFileName As String Dim strApPath As String Dim strLogMessage As String Dim strNumber As String = "" Dim strCaller As String = "" Dim fApnd As Object Dim oFS As Object Dim ForAppending As Integer = 8 Dim I As Integer Dim bMatch As Boolean Dim intAdrCount As Integer = hsp.ADRCount Dim objContact As Scheduler.clsContact Dim strAdrName As String Dim strAnnounce As String strName = hsp.CIDName(1) strNumber = hsp.CIDNumber(1) hs.WriteLog("Number", strNumber) 'debug If strNumber.Length > 3 Then strNumber = strNumber.Substring(0, 3) & "-" & strNumber.Substring(3, 3) & "-" & strNumber.Substring(strNumber.Length - 4) End If hs.SetDeviceString("P53", strName) hs.SetDeviceLastChange("P53", Now) hs.SetDeviceString("P54", strNumber) hs.SetDeviceLastChange("P54", Now) 'hs.WriteLog(hs.DeviceString("P53"), hs.DeviceString("P54")) 'debug hsp.HIPSendLocalCID(1, strName, strNumber) 'hs.WriteLog("Count", CStr(intAdrCount)) 'debug '**************************************************************************************************** ' * * * * * * answer TOLL FREE and PRIVATE CALLs immediately * * * * * * If strName.Length > 8 Then If strName.Substring(0, 9) = "Toll Free" Then hsp.LineAnswer(1) End If If strName = "P" AND strNumber = "P" Then hsp.LineAnswer(1) If strName = "O" AND strNumber = "O" Then hsp.LineAnswer(1) '***************************************************************************************************** For I = 1 to intAdrCount 'Search the address book for a match objContact = hsp.ADRGet(I) If objContact.cell_phone = strNumber OR objContact.home_phone = strNumber OR objContact.business_phone = strNumber Then bMatch = True hs.WriteLog("AdrMatch", CStr(I) & " - " & strNumber) ' Match found strAdrName = objContact.FIRST & " " & objContact.LAST strName = strAdrName hsp.HIPSendLocalCID(1, strName, strNumber) If objContact.cid_group_category = "Family" Then strAnnounce = objContact.announce_local_wav hs.WriteLog("AdrMatchF", strAdrName) hs.Run("StartGeneralAnnounce.vb") hsp.WaitMS(100) hs.Speak(strAnnounce, True) hs.WaitSecs(1) hs.Speak(strName, True) hsp.WaitMS(100) hs.Run("RestoreRussoundGeneral.vb") End If I = intAdrCount End If Next 'I strApPath = hs.GetAppPath() & "\Config\" strFileName = strApPath & "CallerID.txt" strLogMessage = Now & " - " & strName & " - " & strNumber 'Save last caller info for HSTouch hs.SetDeviceString("P63", strName) hs.SetDeviceLastChange("P63", Now) hs.SetDeviceString("P64", strNumber) hs.SetDeviceLastChange("P64", Now) oFS = CreateObject("Scripting.FileSystemObject") ' use the open text file method to open a file to be added to rather than overwritten. fApnd = oFS.OpenTextFile(strFileName, ForAppending) ' write data to it. The writeline method adds a carriage return and linefeed to the end. fApnd.WriteLine(strLogMessage) fApnd.close() ' Close the file fApnd = Nothing oFS = Nothing End Sub
Comment
-
Originally posted by joegr View PostI do think that this is a better way, but it's not quite what the OP was asking for. He is wanting to read the blocked flag (one of the check boxes on the phone book screen). I think that you are suggesting he create a "blocked" category and set all blocked numbers to that category. (I actually did something similar, but I used the "telemarketer" category.)
I use the combination below in my address book entries. I also have "Mute rings until caller ID available" set to 'Yes'. When a call from a blocked caller comes in I do not even know because the phone does not ring at all. If that's the objective, the script I posted is unnecessary.
My script does log the call, however. I'm secretly hoping to get rich some day by being able to document hundreds of calls from some scum bag who has been politely asked not to call again each and every time he calls.Mike____________________________________________________________ __________________
HS3 Pro Edition 3.0.0.548, NUC i3
HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti
Comment
-
Yes, I assume that hangup on this caller = blocked. From the Homeseer help file:
Property
Description
announcement
The announcement to play when this caller calls. Either a text-to-speech string or full path to a wav file.
announce_local_wav
Text or wave file that will be played when this caller calls. The announcement is played through HomeSeer.
answer_rings
Set to TRUE to answer this call on the answer_rings_count, else FALSE to ignore
answer_rings_count
The number of rings to answer when this caller calls
business_phone
Business phone number
business_phone_2
2nd Business phone number
cell_phone
Cell phone number
cell_phone_2
2nd Cell phone number
custom1
A custom field
custom2
A custom field
email_address
email address
email_address_2
2nd email address
email_address_3
3rd email address
FIRST
First name
LAST
Last name
company_name
Company name
home_phone
Home phone number
home_phone_2
2nd Home phone number
fax_home
Home fax phone number
fax_work
Work fax phone number
pager_phone
Pager phone number
pager_pin
Pager PIN
cid_group_category
Currently not used in HomeSeer Phone, this field can be used by scripts to control answering and voicemail functions on groups of address book entries. e.g. Enter "Family" here for all family members, and then a script can control allowing the phones to ring when a family member calls.
home_address_1 through home_address_3
Three home address fields for (typically) street address information.
home_city
Home city name
home_state_province
Home state or province
home_postal_code
Home postal code for an address
home_country
Home country name for an address
business_address_1 through business_address_3
Three business address fields for (typically) street address information.
business_city
Business city name
business_state_province
Business state or province
business_postal_code
Business postal code for an address
business_country
Business country name for an address
cid_name
Name to match in the caller ID name field when a call arrives. Some phone systems may out a special string in this field like "marketing". If this field is present and matches the caller ID name field, the address entry will match the call. This field is the "Name Matching" field on the "Phone (CID Matching)" tab in the address book.
EnableRingPattern
Supported only on the Hi-Phone device. If set to TRUE, and an incoming call matches this address book entry, the phones in the home will ring with pattern as set in the RingON, RingOFF, RingDelay properties.
RingON, RingOFF, RingDelay
Hi-Phone only. These properties specify the ring pattern when the EnableRingPattern property is set to TRUE. The times are in 1/10 of a second.
cidflags
cidflags bit definitions:
CT_CIDFLAGS_BLOCKED = 1 ' callers with this CID are blocked
CT_CIDFLAGS_ANNOUNCE = 2 ' this ID is announced
CT_CIDFLAGS_SPARE1 = 4 ' spare, not used
CT_CIDFLAGS_SPEC_ANN = 8 ' play special announcement to caller
CT_CIDFLAGS_POPUP = &H10 ' pop up window with CID info
CT_CIDFLAGS_PRIVATE = &H20 ' entry matches private CID calls
CT_CIDFLAGS_OUTOFAREA = &H40 ' entry matches out of area calls
Misc1 through Misc6
Miscellaneous string fields for use by scripts to store information. These fields are saved in the address book file but do not appear in the user interface.
MiscNum1 through MiscNum4
Miscellaneous long integer fields for use by scripts to store information. These fields are saved in the address book file but do not appear in the user interface.
flags
flags bit definitions:
CT_FLAGS_VRENABLED = 1 ' address book entry is enabled as voice command
CT_FLAGS_HANGUP = 2 ' hang up after speaking announcement
Also from the help file:
IF:
YesTests a condition and executes the first action if the condition is TRUE, else executes the second action. When testing system or global variables the following operators are supported: +-<> or "<>" (not equal)
The following system variables are supported:
$ADDRBOOK_ANN_HANGUP (true/false)
$ADDRBOOK_SPEC_ANN (true/false)
$ADDRBOOK_BLOCK (true/false)
$ADDRBOOK_CUSTOM1 (string)
$ADDRBOOK_CUSTOM2 (string)
$ADDRBOOK_CELL (string)
$ADDRBOOK_BUSINESS (string)
$ADDRBOOK_PHONE (string)
$ADDRBOOK_LAST (string)
$ADDRBOOK_FIRST (string)
$ADDRBOOK_PRIVATE (true/false)
$ADDRBOOK_OUT_OF_AREA (true/false)
$CID_MATCH_ADDRBOOK (true/false)
$ADDRBOOK_CID_GROUP (string equal)
$ADDRBOOK_CID_GROUP_NUM (number)
$MAILBOX_PASSCODE (string)
$MAILBOX_NAME (string)
$MAILBOX_NUMBER(number)
$MAILBOX_DEFAULT(true/false)
$MESSAGES_TOTAL (number)
$MESSAGES_UNREAD (number)
$MESSAGES_READ (number)
$MAILBOX_NUMBER (number)
$DTMF_KEY (character like "#")
$DTMF (string)
$DTMF_COUNT (number)
$EVENT_VC_CONFIRM (true/false)
$DEVICE_VC_CONFIRM (true/false)
$VR_PHRASE (true/false)
$MESSAGE_LENGTH (number in seconds)
$INTERNAL_CALL (true/false)
$VAR1 -> $VAR32 (user variable)
Of course, it occurs to me now that the blocked flag might mean that the CID is blocked at the originating end, and not that the call has been blocked by HSPhone.
In the end, I just keyed off the category and ignored the flags.
Comment
-
Originally posted by joegr View PostIn the end, I just keyed off the category and ignored the flags.Mike____________________________________________________________ __________________
HS3 Pro Edition 3.0.0.548, NUC i3
HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti
Comment
-
Thanks to the excellent info and example code from joegr and Uncle Michael, and the VB.NET info at http://visualbasic.about.com/od/usin...bitops01_3.htm I was able to solve this.
The important piece is adding the function ExamineBit to the script, then using it to extract the blocked bit-flag from the field CIDFLAGS in the address book.
Code:Dim Byte1, Byte2 As Byte Dim MyByte, MyBit Dim CT_CIDFLAGS_BLOCKED as Boolean ' = 1 callers with this CID are blocked Function ExamineBit(ByVal MyByte, ByVal MyBit) As Boolean Dim BitMask As Int16 BitMask = 2 ^ (MyBit - 1) ExamineBit = ((MyByte And BitMask) > 0) End Function '** example useage '** StatusOfBit = ExamineBit(MyByte, MyBit) '** CT_CIDFLAGS_BLOCKED = ExamineBit(objContact.CIDFLAGS, 1)
Code:Sub Main(ByVal Parms As Object) Dim I As Integer Dim intAdrCount As Integer = hsp.ADRCount Dim objContact As Scheduler.clsContact Dim CT_CIDFLAGS_BLOCKED as Boolean ' = 1 callers with this CID are blocked Dim CT_CIDFLAGS_ANNOUNCE as Boolean ' = 2 this ID is announced Dim CT_CIDFLAGS_UNKNOWN as Boolean 'unknown useage Dim CT_CIDFLAGS_SPARE1 as Boolean ' = 4 spare, not used Dim CT_CIDFLAGS_SPEC_ANN as Boolean ' = 8' play special announcement to caller Dim CT_CIDFLAGS_POPUP as Boolean '= &H10 pop up window with CID info Dim CT_CIDFLAGS_PRIVATE as Boolean '= &H20 entry matches private CID calls Dim CT_CIDFLAGS_OUTOFAREA as Boolean '= &H40 entry matches out of area calls Dim Byte1, Byte2 As Byte Dim MyByte, MyBit For I = 1 to intAdrCount 'Read all the entries in the address book objContact = hsp.ADRGet(I) '*** Break out the individual bit flags from the CIDFLAGS field CT_CIDFLAGS_BLOCKED = FALSE CT_CIDFLAGS_ANNOUNCE = FALSE CT_CIDFLAGS_UNKNOWN = FALSE CT_CIDFLAGS_SPARE1 = FALSE CT_CIDFLAGS_SPEC_ANN = FALSE CT_CIDFLAGS_POPUP = FALSE CT_CIDFLAGS_PRIVATE = FALSE CT_CIDFLAGS_OUTOFAREA = FALSE CT_CIDFLAGS_BLOCKED = ExamineBit(objContact.CIDFLAGS, 1) CT_CIDFLAGS_ANNOUNCE = ExamineBit(objContact.CIDFLAGS, 2) CT_CIDFLAGS_UNKNOWN = ExamineBit(objContact.CIDFLAGS, 3) CT_CIDFLAGS_SPARE1 = ExamineBit(objContact.CIDFLAGS, 4) CT_CIDFLAGS_POPUP = ExamineBit(objContact.CIDFLAGS, 5) CT_CIDFLAGS_PRIVATE = ExamineBit(objContact.CIDFLAGS, 6) CT_CIDFLAGS_OUTOFAREA = ExamineBit(objContact.CIDFLAGS, 7) CT_CIDFLAGS_SPEC_ANN = ExamineBit(objContact.CIDFLAGS, 8) '*** If this is a blocked entry, write the info to the log If CT_CIDFLAGS_BLOCKED = TRUE hs.WriteLog("AdrEntry", "Index: " & CStr(I) ) hs.WriteLog("AdrEntry", "Name: " & objContact.FIRST & " " & objContact.LAST ) hs.WriteLog("AdrEntry", "Group: " & objContact.cid_group_category ) hs.writelog("AdrEntry", "Cell: " & objContact.cell_phone ) hs.writelog("AdrEntry", "Home: " & objContact.home_phone ) hs.writelog("AdrEntry", "CIDFLAGS: " & objContact.CIDFLAGS) hs.writelog("AdrEntry", "Bit 1 - CT_CIDFLAGS_BLOCKED : " & CT_CIDFLAGS_BLOCKED ) hs.writelog("AdrEntry", "Bit 2 - CT_CIDFLAGS_ANNOUNCE : " & CT_CIDFLAGS_ANNOUNCE ) hs.writelog("AdrEntry", "Bit 3 - CT_CIDFLAGS_UNKNOWN : " & CT_CIDFLAGS_UNKNOWN ) hs.writelog("AdrEntry", "Bit 4 - CT_CIDFLAGS_SPARE1 : " & CT_CIDFLAGS_SPARE1 ) hs.writelog("AdrEntry", "Bit 5 - CT_CIDFLAGS_POPUP : " & CT_CIDFLAGS_POPUP ) hs.writelog("AdrEntry", "Bit 6 - CT_CIDFLAGS_PRIVATE : " & CT_CIDFLAGS_PRIVATE ) hs.writelog("AdrEntry", "Bit 7 - CT_CIDFLAGS_OUTOFAREA : " & CT_CIDFLAGS_OUTOFAREA ) hs.writelog("AdrEntry", "Bit 8 - CT_CIDFLAGS_SPEC_ANN : " & CT_CIDFLAGS_SPEC_ANN ) hs.writelog("AdrEntry", " ") End if Next End Sub '*************************************************************************************** Function ExamineBit(ByVal MyByte, ByVal MyBit) As Boolean Dim BitMask As Int16 BitMask = 2 ^ (MyBit - 1) ExamineBit = ((MyByte And BitMask) > 0) End Function '** example useage '** StatusOfBit = ExamineBit(MyByte, MyBit)
Fred
HomeSeer Pro 3.0.0.548, HS3Touch, Zwave 3.0.1.252, Envisalink DSC 3.0.0.40, WeatherXML, Z-stick, HS phone, Way2Call
Comment
-
Amazing what you can do when you actually know what you are doing. Thanks for digging in and clarifying what is going on. Maybe I can use some of what you are doing in my scripts.Mike____________________________________________________________ __________________
HS3 Pro Edition 3.0.0.548, NUC i3
HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti
Comment
Comment