Announcement

Collapse
No announcement yet.

Print a Device Inventory Report?

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

    #16
    I've translated my script for use with HS3. It saves a file named 'DeviceProp.csv' in the HS3 'Data' folder.

    Caveat: I am an amateur programmer, and create scripts for my own use. I'm happy to share them, but if you want to try it, please proceed with caution. Save the file with a 'vb' extension.
    Code:
    Sub Main(ByVal Params As Object)
    
            Dim strFileName As String
            Dim objEnum As Scheduler.Classes.clsDeviceEnumeration
            Dim objDevice As Scheduler.Classes.DeviceClass
            Dim strDevName As String
            Dim strApPath As String
            Dim strDevString As String
            Dim strListItem As String
            Dim intDevRef As Integer
            Dim dblDevValue As Double
    
    
            ' Find the current path and define a file name
            strApPath = hs.GetAppPath() & "\Data\"
            strFileName = strApPath & "DeviceProp.csv"
    
            ' Create an output ASCII text file.  If it already exists, overwrite current contents.
            Dim FS As New System.IO.FileStream(strFileName, System.IO.FileMode.Create, System.IO.FileAccess.Write)
    
            Dim sWriter As New System.IO.StreamWriter(FS)
    
            ' Time stamp the file
            sWriter.WriteLine("HomeSeer Devices - " & Now)
    
            ' Create a header row
            sWriter.WriteLine("Ref #" & "," & "Location1" & "," & "Location2" & "," & "Name" & "," & "Value" & "," & "String")
    
            ' Get a list of all HS devices
            objEnum = hs.GetDeviceEnumerator
    
            ' Retrieve data for each HS device and write it to the file
            Do While Not objEnum.Finished
    
                objDevice = objEnum.GetNext
    
                If objDevice Is Nothing Then Continue Do
    
                strDevName = ObjDevice.Name(hs)
                intDevRef = ObjDevice.Ref(hs)
                dblDevValue = hs.DeviceValueEx(intDevRef)
                strDevString = hs.DeviceString(intDevRef)
    
                strListItem = CStr(intDevRef) & "," & objDevice.Location(hs) & "," & objDevice.Location2(hs) & "," & objDevice.Name(hs) & "," & CStr(dblDevValue) & "," & strDevString
    
                sWriter.WriteLine(strListItem)
    
            Loop
    
            ' Close the file
            sWriter.Close()
    
        objDevice = Nothing
        objEnum = 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


      #17
      Currently trying this script, but no output. Do I read this correctly that it's going into the \HS3\data\ folder? And it's a .csv? Don't see it.


      Jim Speiser
      38-year veteran of Home Automation
      Still don't know squat

      Comment


        #18
        Originally posted by JimSpy View Post
        Do I read this correctly that it's going into the \HS3\data\ folder? And it's a .csv? Don't see it.
        Hmm. The first thing I'd check is the log. Are there any error messages? In Settings.ini in the Config folder, what does it list for 'app_path'? The program assumes that the path to the HS3 folder is correctly reported by the GetAppPath function. In my HS3 directory it appears just before the backup copies of the database.
        Attached Files
        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


          #19
          Interestingly, there is no app_path in the settings.ini file. Is this something I need to stick in myself?


          Jim Speiser
          38-year veteran of Home Automation
          Still don't know squat

          Comment


            #20
            Originally posted by JimSpy View Post
            Interestingly, there is no app_path in the settings.ini file.
            In that case you could try looking for the csv file in the C:\ (root) directory.

            I think I had to add the app_path entry to my ini file too, but it's been a while so I may be mistaken. Here are the first few lines of my current Settings.ini file:

            [Settings]
            app_path=C:\Program Files\HomeSeer HS3
            gLastShutdownOK=False
            gFirstTimeRun=False
            gConfigFilename=HomeSeerData.hsd
            ScriptingReferences=System.Drawing;System.Drawing.dll,System .XML;System.XML.Dll,System.Data;System.Data.Dll,System.Web;S ystem.Web.Dll
            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


              #21
              Originally posted by Uncle Michael View Post
              In that case you could try looking for the csv file in the C:\ (root) directory.
              Well, sonofagun, guess what?

              It's not there either.

              But I'll go ahead and make that change to the .ini and let you know what happens. Thanks!


              Jim Speiser
              38-year veteran of Home Automation
              Still don't know squat

              Comment


                #22
                OK, I get a strange error in the log:

                Running script, script run or compile error in file: C:/Program Files (x86)/HomeSeer HS3/scripts/DeviceList.txt1006:Expected ')' in line 1 More info: Expected ')'

                Do I have to pass any parameters to the script?


                Jim Speiser
                38-year veteran of Home Automation
                Still don't know squat

                Comment


                  #23
                  The file should have a .vb extension, not .txt.
                  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


                    #24
                    Success! Thanks.

                    Now, an enhancement request...is there a way to include the Insteon address triplet as a field? My real purpose here is that I always seem to get stuck re-discovering and re-entering all 140 or so devices, no matter how many ways I've backed up the system. I just want it as a last resort.


                    Jim Speiser
                    38-year veteran of Home Automation
                    Still don't know squat

                    Comment


                      #25
                      Originally posted by JimSpy View Post
                      Success! Thanks.

                      Now, an enhancement request...is there a way to include the Insteon address triplet as a field?
                      Glad it's working.
                      I also noticed the address field was missing. (In HS2 it was the first field. I replaced it with Ref#, but forgot to add it back as its own field.)

                      See if this version does what you want:
                      Code:
                      Sub Main(ByVal Params As Object)
                      
                              Dim strFileName As String
                              Dim objEnum As Scheduler.Classes.clsDeviceEnumeration
                              Dim objDevice As Scheduler.Classes.DeviceClass
                              Dim strDevName As String
                              Dim strApPath As String
                              Dim strDevString As String
                              Dim strListItem As String
                              Dim intDevRef As Integer
                              Dim dblDevValue As Double
                      
                      
                              ' Find the current path and define a file name
                              strApPath = hs.GetAppPath() & "\Data\"
                              strFileName = strApPath & "DeviceProp.csv"
                      
                              ' Create an output ASCII text file.  If it already exists, overwrite current contents.
                              Dim FS As New System.IO.FileStream(strFileName, System.IO.FileMode.Create, System.IO.FileAccess.Write)
                      
                              Dim sWriter As New System.IO.StreamWriter(FS)
                      
                              ' Time stamp the file
                              sWriter.WriteLine("HomeSeer Devices - " & Now)
                      
                              ' Create a header row
                              sWriter.WriteLine("Ref #" & "," & "Location1" & "," & "Location2" & "," & "Name" & "," & "Address" & "," & "Value" & "," & "String")
                      
                              ' Get a list of all HS devices
                              objEnum = hs.GetDeviceEnumerator
                      
                              ' Retrieve data for each HS device and write it to the file
                              Do While Not objEnum.Finished
                      
                                  objDevice = objEnum.GetNext
                      
                              If objDevice Is Nothing Then Continue Do
                      
                                  'strDevName = ObjDevice.Name(hs)
                              intDevRef = ObjDevice.Ref(hs)
                                  dblDevValue = hs.DeviceValueEx(intDevRef)
                                  strDevString = hs.DeviceString(intDevRef)
                      
                                  strListItem = CStr(intDevRef) & "," & objDevice.Location(hs) & "," & objDevice.Location2(hs) & "," & objDevice.Name(hs) & "," & objDevice.Address(hs) & "," & CStr(dblDevValue) & "," & strDevString
                      
                                  sWriter.WriteLine(strListItem)
                      
                              Loop
                      
                              ' Close the file
                              sWriter.Close()
                      
                          objDevice = Nothing
                          objEnum = 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


                        #26
                        That works. Thanks. Happy Holidays!


                        Jim Speiser
                        38-year veteran of Home Automation
                        Still don't know squat

                        Comment

                        Working...
                        X