I am attempting to parse out some text from a device (the thinking cleaner plugin for my Roomba) into discrete fields. This should be a simple task but I can't get it to work. The motivation for this can be seen here: https://forums.homeseer.com/showthread.php?t=173509
The text is:
Status: On homebase: Trickle Charging
Model: 600
Battery charge: 88 %
Total cleaning distance: 299.30 KM
Total cleaning time: 277 hours 8 minutes
Last cleaning took: 0 hours 0 minutes
This is the script that I have:
Sub Main(parm as object)
Dim sVal
sVal = hs.devicestring(514)
dim splitVal() as string
splitVal = sVal.split(Chr(13))
hs.WriteLog("Info", splitVal(0))
hs.SetDeviceString(532, splitVal(0),True)
End Sub
The trouble is that it doesn't actually split on Chr(13) as I would expect. Instead I end up with everything in splitVal(0) and nothing in splitVal(1). I can replace this with ":" and it splits fine. I've also tried "/n", "/r", Chr(10), and Environment.NewLine without success. This seems very simple but I can't figure out where I'm going wrong. Any ideas?
The text is:
Status: On homebase: Trickle Charging
Model: 600
Battery charge: 88 %
Total cleaning distance: 299.30 KM
Total cleaning time: 277 hours 8 minutes
Last cleaning took: 0 hours 0 minutes
This is the script that I have:
Sub Main(parm as object)
Dim sVal
sVal = hs.devicestring(514)
dim splitVal() as string
splitVal = sVal.split(Chr(13))
hs.WriteLog("Info", splitVal(0))
hs.SetDeviceString(532, splitVal(0),True)
End Sub
The trouble is that it doesn't actually split on Chr(13) as I would expect. Instead I end up with everything in splitVal(0) and nothing in splitVal(1). I can replace this with ":" and it splits fine. I've also tried "/n", "/r", Chr(10), and Environment.NewLine without success. This seems very simple but I can't figure out where I'm going wrong. Any ideas?
Comment