How would I take this device string, parse the 66 from the "Heat: 66" portion and save it as the value of a virtual device?
String
String
If this is your first visit, be sure to check out the FAQ. You must register before you can post.
IMPORTANT: Your first post will be checked for appropriate content. This may take a bit of time.
Sub Main(ByVal Parms As Object)
Dim DevStr As String = hs.devicestring("X1")
'change this to the thermostat code
If Instr(DevStr, "Heat: ") > 1 Then
Dim ValTherm As String
ValTherm = DevStr.SubString(Instr(DevStr, "Heat: ") + 5, 2)
hs.writelog("TestStr", "Temperature Is: " & ValTherm)
hs.setdevicevalue("Y1", CInt(ValTherm))
hs.setdevicestring("Y1", "New Temp: " & ValTherm, True)
'update Y1 with your virtual device code
Else
hs.writelog("TestStr", "Check the device, no string found")
End If
End Sub
Sub Main(parm as object)
Dim pi As Object
Dim fanm,setpc,setph,setp,mode,modeset,temp As String
Try
pi = hs.Plugin("ZWave Thermostats")
temp = pi.GetTemp(1)
setpc = pi.GetCoolSet(1)
setph = pi.GetHeatSet(1)
If(pi.GetModeSet(1)=0) Then
modeset="Off"
ElseIf (pi.GetModeSet(1)=1) Then
modeset="Heat"
hs.setdevicestring ("t2",setph,true)
setp=setph
ElseIf(pi.GetModeSet(1)=2) Then
modeset="Cool"
hs.setdevicestring ("t2",setpc,true)
setp=setpc
ElseIf(pi.GetModeSet(1)=3) Then
modeset="Auto"
ElseIf(pi.GetModeSet(1)=4) Then
modeset="Aux"
End If
If(pi.GetCurrentMode(1)=0) Then
mode="Off"
ElseIf (pi.GetCurrentMode(1)=1) Then
mode="Heating"
ElseIf(pi.GetCurrentMode(1)=2) Then
mode="Cooling"
ElseIf(pi.GetCurrentMode(1)=3) Then
mode="Auto"
ElseIf(pi.GetCurrentMode(1)=4) Then
mode="Aux"
End If
If(pi.GetFanMode(1)=0) then
fanm="Auto"
ElseIf(pi.GetFanMode(1)=1) then
fanm="On"
End If
hs.writeLog("debug", "Mode Set=[" & modeset & "] temp=[" & temp & "] cool set pt=[" & setpc & "] heat set pt=[" & setph & "] mode=[" & mode & "] fan mode=[" & fanm & "]")
Catch e As Exception
hs.WriteLog("debug", e.Message)
Finally
pi = Nothing
End Try
hs.setdevicestring ("t1","Set to " & modeset & " - " & mode & ":Temp " & temp & ":Fan " & fanm & ":Set Point " & setp,true)
End Sub
Comment