Quantcast
Channel: HomeSeer Message Board
Viewing all articles
Browse latest Browse all 4847

HS2 Script

$
0
0
I have been trying to get a simple script working in HS2. It comes up with repeated errors. My original script got a value from a virtual devise, did a bunch of math to convert from a analog voltage reading to a temperature reading then saved it to a new virtual device.. I am trying to get the analog value from a simple web page and process it through the same math and back to the virtual device. My original script was a txt file. The only function I could find to reference a web page was a VB file. Any help is greatly appreciated

Sub Main(parms As Object)

Dim inputStr As String = hs.GetUrl("192.168.0.170", "/analogread.tpl", False, 80)
Dim rows() As String = Split(inputStr, "

")
rows(2) = rows(2).Replace("

", "")
'hs.writelog("Row 1 " & rows(1))
'hs.writelog("Row 2 " & rows(2))




dim TempPool as Integer
dim AnalogVoltDataPool as Integer
Dim OHMSPool as Integer
dim TempKPool as Integer
Dim tempCPool as Integer
Dim tempFPool as Integer

TempPool=convert.toint32(rows(2))

'Convert to Temp of Pool
AnalogVoltDataPool = (TempPool / 341)
OHMSPool = AnalogVoltDataPool/((5-AnalogVoltDataPool)/100000)
TempKPool = (1/((1/298.5)+(1/3400*(Math.log(OHMSPool/10000)))))
TempCPool = (TempKPool-273.15)
'TempCPool = Round(TempCPool,1)
TempFPool = ((TempCPool*(9/5))+32)
'TempFPool = Round(TempFPool,1)
TempCPool = TempCPool*10
'MsgBox TempC &"C - "&TempF &"F"

hs.SetDeviceValueByName ("Pool Air Temp", TempCPool)
hs.setdevicestring("V2",CStr((TempCPool)/10),True)

The raw web page being accessed, the value I would like is the 185 after the


See attached file


The LOG shows the following when I try and run
Error Script compile error: Statement cannot appear within a method body. End of method assumed.on line 49



Attached Files
File Type: txt page.txt (173 Bytes)

Viewing all articles
Browse latest Browse all 4847

Trending Articles