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.
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
Comment