Hello all,
I have been trying to figure this out for a while but I cannot get any further. After moving a working script from Windows to Linux i'm getting all sorts of errors. I read through the forum and was able to fix some of the common errors (implicit declarations etc) but i'm still stuck with these errors and I have no clue what they mean
My script reads some data from a furnace and creates a HTML email with some status information. The same code is used in another script to update HS objects but I haven't yet had the time to go and fix that script (similar errors). I believe the errors are caused by the return values from the functions (I marked the error point with **HERE** below) as even if I comment out all lines in the function Geo_Read i still get the same errors. Can anyone spot what I am missing?
------SCRIPT------
Sub Main(ByVal parm As String)
Dim x As Double
Dim Geo1 As String
Dim Geo2 As String
' Dim Geo1(100) As String
' Dim Geo2(100) As String
Dim Geo_Error(100) As String
Geo_Error(1)="E1 - Input Error"
Geo_Error(2)="E2 - High Pressure"
Geo_Error(3)="E3 - Low Pressure"
Geo_Error(4)="E4 - Frze Detect FP2"
Geo_Error(5)="E5 - Frze Detect FP1"
Geo_Error(7)="E7 - Condensate"
Geo_Error(8)="E8 - O/U Voltage"
Geo_Error(11)="E11 - FP1/2 Snr Err"
Geo_Error(13)="E13 - NCritAxbSnrErr"
Geo_Error(15)="E15 - Hot Water Limit"
Geo_Error(16)="E16 - VS Pump Error"
Geo_Error(18)="E18 - NCritComm Error"
Geo_Error(19)="E19 - Crit Comm Error"
Geo_Error(21)="E21 - Low Loop Press"
Geo_Error(23)="E23 - HAGeneralAlarm"
Geo_Error(24)="E24 - HAGeneralAlarm"
Geo_Error(41)="E41 - Hi Drive Temp"
Geo_Error(42)="E42 - Hi Dischrg Temp"
Geo_Error(43)="E43 - Lo Suct Press"
Geo_Error(44)="E44 - Lo Cond Press"
Geo_Error(45)="E45 - Hi Cond Press"
Geo_Error(46)="E46 - Output Pwr Lmt"
Geo_Error(47)="E47 - EEV ID Comm Err"
Geo_Error(48)="E48 - EEV OD Comm Err"
Geo_Error(49)="E49 - Cabinet Tmp Snr"
Geo_Error(51)="E51 - Dischrg Tmp Snr"
Geo_Error(52)="E52 - Suct Press Snr"
Geo_Error(53)="E53 - Cond Press Snr"
Geo_Error(54)="E54 - Lo Supply Volt"
Geo_Error(55)="E55 - Out of Envelope"
Geo_Error(56)="E56 - Drv Over Current"
Geo_Error(57)="E57 - Drive O/U Volt"
Geo_Error(58)="E58 - Hi Drive Temp"
Geo_Error(59)="E59 - Int Drive Error"
Geo_Error(61)="E61 - Multiple SafeMd"
Geo_Error(71)="E71 - Loss of Charge"
Geo_Error(72)="E72 - Suct Temp Snr"
Geo_Error(73)="E73 - LvgAir Temp Snr"
Geo_Error(74)="E74 - Max Op Pressure"
Geo_Error(99)="E99"
**HERE** Geo1 = Geo_Read("IP_ADDR1")
**HERE** Geo2 = Geo_Read("IP_ADDR2")
Dim objReader As System.IO.StreamWriter
Dim FullPath as String = hs.getapppath & "/scripts/wf-errors.html"
objReader = New System.IO.StreamWriter(FullPath)
objReader.Write("<head><meta http-equiv="&chr(34)&"refresh"&chr(34)& " content="&chr(34)&"180"&chr(34)&"></head>")
objReader.Write("<body bgcolor="&chr(34)&"#0000e6"&chr(34)&">")
objReader.Write("<table border=" & chr(34) &"1" & chr(34) & " style=" & chr(34) & "color:white" & chr(34) & "><tr><td>Error Name</td><td>Unit1</td><td>Unit2</td><tr>")
for x = 0 to Ubound(Geo1)-1
if(Geo1(x)<>"65535") Then
objReader.Write("<tr><td>")
objReader.Write(Geo_Error(x+1))
objReader.Write("</td><td>")
objReader.Write(Geo1(x))
objReader.Write("</td><td>")
objReader.Write(Geo2(x))
objReader.Write("</td></tr>")
End If
Next
Dim lastreset As String
lastreset = My.Computer.FileSystem.ReadAllText(hs.getapppath & "/scripts/wf-errors-reset.html")
objReader.Write("</tr><tr><td colspan=" & chr(34) & "5" & chr(34) & ">" & "Last Update: " & Now & "</td></tr></td></tr>")
objReader.Write("</tr><tr><td colspan=" & chr(34) & "5" & chr(34) & ">" & "Last Reset: " & lastreset & "</td></tr></td></tr>")
objReader.Write("</table></font>")
objReader.Close()
hs.writelog("Info","Unit1: " & Geo1(7))
hs.writelog("Info","Unit2: " & Geo2(7))
Send_results()
End Sub
Function Send_results()
Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText(hs.getapppath & "/scripts/wf-errors.html")
' filereader = "This is a string from VWS: " & filereader
' hs.writelog("Email Send", filereader)
hs.sendemail("myemail", "fromemail", "", "", "WaterFurnace Errors", filereader, "")
End Function
Function Geo_Read(ip As String)
Dim strBody, strWork, URLpath As String
Dim x,y As Double
Dim strSplit() As String
URLpath="/request.cgi?cmd=getregs&id=4&set=1&addr=2®s=601,99;"
strBody = hs.GetURLEx("http://" & ip, URLpath, "", "80", "TRUE", "FALSE", "")
hs.writelog("Info", ip & ": " & strBody)
y = Instr(1,strBody,"Unauthorized",1)
if (y=0) then
x = Instr(1,strBody,"values=",1)
strWork = Mid(strBody,x+7)
strSplit = Split(strWork, ",")
Geo_Read=strSplit
Else
hs.writelog("Info","Unit2: Not Authorized")
strBody = hs.GetURLEx("http://" & ip,"/request.cgi?cmd=auth&id=1&set=1&addr=247&passcode=1234", "", "80", "TRUE", "FALSE", "")
Geo_Read="0"
End If
End Function
I have been trying to figure this out for a while but I cannot get any further. After moving a working script from Windows to Linux i'm getting all sorts of errors. I read through the forum and was able to fix some of the common errors (implicit declarations etc) but i'm still stuck with these errors and I have no clue what they mean
Apr-13 9:21:53 PM | Error | Compiling script /opt/HomeSeer/scripts/waterfurnace-errors.vb: CHANGEME |
Apr-13 9:21:53 PM | Error | Compiling script /opt/HomeSeer/scripts/waterfurnace-errors.vb: 42021 |
Apr-13 9:21:53 PM | Error | Compiling script /opt/HomeSeer/scripts/waterfurnace-errors.vb: 42021 |
Apr-13 9:21:53 PM | Error | Compiling script /opt/HomeSeer/scripts/waterfurnace-errors.vb: The import 'System.Core' could not be found. |
------SCRIPT------
Sub Main(ByVal parm As String)
Dim x As Double
Dim Geo1 As String
Dim Geo2 As String
' Dim Geo1(100) As String
' Dim Geo2(100) As String
Dim Geo_Error(100) As String
Geo_Error(1)="E1 - Input Error"
Geo_Error(2)="E2 - High Pressure"
Geo_Error(3)="E3 - Low Pressure"
Geo_Error(4)="E4 - Frze Detect FP2"
Geo_Error(5)="E5 - Frze Detect FP1"
Geo_Error(7)="E7 - Condensate"
Geo_Error(8)="E8 - O/U Voltage"
Geo_Error(11)="E11 - FP1/2 Snr Err"
Geo_Error(13)="E13 - NCritAxbSnrErr"
Geo_Error(15)="E15 - Hot Water Limit"
Geo_Error(16)="E16 - VS Pump Error"
Geo_Error(18)="E18 - NCritComm Error"
Geo_Error(19)="E19 - Crit Comm Error"
Geo_Error(21)="E21 - Low Loop Press"
Geo_Error(23)="E23 - HAGeneralAlarm"
Geo_Error(24)="E24 - HAGeneralAlarm"
Geo_Error(41)="E41 - Hi Drive Temp"
Geo_Error(42)="E42 - Hi Dischrg Temp"
Geo_Error(43)="E43 - Lo Suct Press"
Geo_Error(44)="E44 - Lo Cond Press"
Geo_Error(45)="E45 - Hi Cond Press"
Geo_Error(46)="E46 - Output Pwr Lmt"
Geo_Error(47)="E47 - EEV ID Comm Err"
Geo_Error(48)="E48 - EEV OD Comm Err"
Geo_Error(49)="E49 - Cabinet Tmp Snr"
Geo_Error(51)="E51 - Dischrg Tmp Snr"
Geo_Error(52)="E52 - Suct Press Snr"
Geo_Error(53)="E53 - Cond Press Snr"
Geo_Error(54)="E54 - Lo Supply Volt"
Geo_Error(55)="E55 - Out of Envelope"
Geo_Error(56)="E56 - Drv Over Current"
Geo_Error(57)="E57 - Drive O/U Volt"
Geo_Error(58)="E58 - Hi Drive Temp"
Geo_Error(59)="E59 - Int Drive Error"
Geo_Error(61)="E61 - Multiple SafeMd"
Geo_Error(71)="E71 - Loss of Charge"
Geo_Error(72)="E72 - Suct Temp Snr"
Geo_Error(73)="E73 - LvgAir Temp Snr"
Geo_Error(74)="E74 - Max Op Pressure"
Geo_Error(99)="E99"
**HERE** Geo1 = Geo_Read("IP_ADDR1")
**HERE** Geo2 = Geo_Read("IP_ADDR2")
Dim objReader As System.IO.StreamWriter
Dim FullPath as String = hs.getapppath & "/scripts/wf-errors.html"
objReader = New System.IO.StreamWriter(FullPath)
objReader.Write("<head><meta http-equiv="&chr(34)&"refresh"&chr(34)& " content="&chr(34)&"180"&chr(34)&"></head>")
objReader.Write("<body bgcolor="&chr(34)&"#0000e6"&chr(34)&">")
objReader.Write("<table border=" & chr(34) &"1" & chr(34) & " style=" & chr(34) & "color:white" & chr(34) & "><tr><td>Error Name</td><td>Unit1</td><td>Unit2</td><tr>")
for x = 0 to Ubound(Geo1)-1
if(Geo1(x)<>"65535") Then
objReader.Write("<tr><td>")
objReader.Write(Geo_Error(x+1))
objReader.Write("</td><td>")
objReader.Write(Geo1(x))
objReader.Write("</td><td>")
objReader.Write(Geo2(x))
objReader.Write("</td></tr>")
End If
Next
Dim lastreset As String
lastreset = My.Computer.FileSystem.ReadAllText(hs.getapppath & "/scripts/wf-errors-reset.html")
objReader.Write("</tr><tr><td colspan=" & chr(34) & "5" & chr(34) & ">" & "Last Update: " & Now & "</td></tr></td></tr>")
objReader.Write("</tr><tr><td colspan=" & chr(34) & "5" & chr(34) & ">" & "Last Reset: " & lastreset & "</td></tr></td></tr>")
objReader.Write("</table></font>")
objReader.Close()
hs.writelog("Info","Unit1: " & Geo1(7))
hs.writelog("Info","Unit2: " & Geo2(7))
Send_results()
End Sub
Function Send_results()
Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText(hs.getapppath & "/scripts/wf-errors.html")
' filereader = "This is a string from VWS: " & filereader
' hs.writelog("Email Send", filereader)
hs.sendemail("myemail", "fromemail", "", "", "WaterFurnace Errors", filereader, "")
End Function
Function Geo_Read(ip As String)
Dim strBody, strWork, URLpath As String
Dim x,y As Double
Dim strSplit() As String
URLpath="/request.cgi?cmd=getregs&id=4&set=1&addr=2®s=601,99;"
strBody = hs.GetURLEx("http://" & ip, URLpath, "", "80", "TRUE", "FALSE", "")
hs.writelog("Info", ip & ": " & strBody)
y = Instr(1,strBody,"Unauthorized",1)
if (y=0) then
x = Instr(1,strBody,"values=",1)
strWork = Mid(strBody,x+7)
strSplit = Split(strWork, ",")
Geo_Read=strSplit
Else
hs.writelog("Info","Unit2: Not Authorized")
strBody = hs.GetURLEx("http://" & ip,"/request.cgi?cmd=auth&id=1&set=1&addr=247&passcode=1234", "", "80", "TRUE", "FALSE", "")
Geo_Read="0"
End If
End Function
Comment