Announcement

Collapse
No announcement yet.

How to access the HS Phone PhoneBook from VB.Net or C#

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

  • How to access the HS Phone PhoneBook from VB.Net or C#

    Does anyone know how to access the HS Phone's PhoneBook from VB.Net or C#

    In vbscript or classic asp pages, the reference to hsp is automatically created before the script or asp page is loaded.

    In .NET you need to create the hs reference (hs = (Scheduler.hsapplication)Context.Items["Content"];)
    Then, I believe create the hsp reference (var hsp = hs.GetHSPRef();)

    I get the following error when trying to call GetHSPRef:

    Type 'Scheduler.PhoneApp' in Assembly 'Scheduler, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

  • #2
    I've never had to do that. I just use functions like <String> = hsp.CIDName(1) or <String> = hsp.LastCallerInfo(1)
    I've never tried to get info from the address book, but assume you'd need to retrieve the reference with ADRGet, then use that to read the ContactClass.
    What is it that you want to do?
    Mike____________________________________________________________ __________________
    HS3 Pro Edition 3.0.0.548

    HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF, Rain8Net+ | RFXCOM | QSE100D | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3

    Comment


    • #3
      For VB:

      Use "Dim objContact As Scheduler.clsContact" to define the addressbook class.
      Then use "objContact = hsp.ADRGet(I)" to retrieve the record for addressbook index I.

      Unfortunately, HS doesn't provide an easy way to determine the index you need, so you'll have to read through all the entries, testing each one until you find what you're looking for!

      You can find an example here:
      https://forums.homeseer.com/forum/le...cript?t=172265

      Look for the section of the script that starts with a comment of " *** Search the address book for a match".

      Fred
      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


      • #4
        The address book is an XML file, so you should be able to use vb XML commands to get the data out.
        HS 3.0.0.548: 1990 Devices 1172 Events
        Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

        Comment


        • #5
          Originally posted by sparkman View Post
          The address book is an XML file, so you should be able to use vb XML commands to get the data out.
          I have tried that, but when Homeseer is stopped and started, the XML is reverted back to what ever was loaded. I assume there is code which writes the XML out when HS is shutting down.

          Great idea though!

          Comment


          • #6
            I forgot to mention I'm trying to do this from an ASPX page in the html folder.

            I got a little further, but this seems to load a new empty address box everytime it runs instead of the actual addresses from the xml file:


            Scheduler.hsp hsp = new Scheduler.hsp();
            hsp.gPhoneApp = new PhoneApp();

            Scheduler.ClsPhoneData data = new ClsPhoneData();
            data.Init(hsp.gPhoneApp);
            data.LoadAddressBook();

            Comment


            • #7
              Are you just trying to display your address book?

              Here's a script snippet I use to find specific entries in the address book:

              Code:
                  ​​​​​​​    ​​​​​​​    ​​​​​​​    Dim pContact As Scheduler.clsContact
                              For i = 1 To hsp.ADRCount
                                  pContact = hsp.ADRGet(i)
                                  If Number = Trim(pContact.home_phone) or Number = Trim(pContact.home_phone_2) or Number = Trim(pContact.cell_phone) or Number = Trim(pContact.cell_phone_2) or Number = Trim(pContact.business_phone) or Number = Trim(pContact.business_phone_2) Then
                                      If pContact.first <> "" Then
                                          Name = pContact.first & " " & pContact.last
                                      ElseIf pContact.company_name <> "" Then
                                          Name = pContact.company_name
                                      Else
                                          Name = "Unknown"
                                      End If
                                  End If
              
                              Next
              HS 3.0.0.548: 1990 Devices 1172 Events
              Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

              Comment

              Working...
              X