www.homeseer.com    
 

Go Back   HomeSeer Message Board > HomeSeer Products & Services > HomeSeer Help

HomeSeer Help Help, How-to's and Documentation

Reply
 
Thread Tools Display Modes
  #1  
Old February 27th, 2017, 12:01 PM
acromion acromion is offline
Seer Deluxe
 
Join Date: Jun 2012
Location: Saskatchewan, Canada
Posts: 162
Parse text on new line from script

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?
Reply With Quote
  #2  
Old February 27th, 2017, 12:06 PM
sparkman's Avatar
sparkman sparkman is offline
OverSeer
 
Join Date: Oct 2001
Location: Calgary, Alberta, Canada
Posts: 6,007
This might work:

Code:
Sub Main(parm as object)

Dim sVal
sVal = hs.devicestring(514)
sVal = sVal.Replace(Chr(13), "")
dim splitVal() as string
splitVal = sVal.split(Chr(10))
hs.WriteLog("Info", splitVal(0)) 
hs.SetDeviceString(532, splitVal(0),True)
End Sub
__________________
HS3Pro 3.0.0.318 on Jetway JBC501F9Q-Q87-B i7 8GB 1874 Devices, 955 Events, 28 Plugins
Z-Wave 3.0.1.131 Z-Net 105 nodes:Leviton Vizia,Kwikset,FortrezZ Valve/Sensors,Everspring Sensors/Modules/Outlets,CT30 Stats,MIMOLites,Aeotec Smart Switches
RFXCom W800,RFXrec433,RFXtrx433|APCUPSD|Pushover|Squeezebox|weatherXML|HS Phone W2C|APCUPSD|UltraLog
UltraGCIR GC-100|UltraNetcam|UltraPioneer|Ultra1Wire|DSC PC1832|BLLED|BLTVGuide|ImperiHome|jon00 Utilities|MySensors

PHLocation|X10 CM11A IOLinc,etc

Last edited by sparkman; February 27th, 2017 at 12:47 PM.
Reply With Quote
  #3  
Old February 27th, 2017, 12:14 PM
acromion acromion is offline
Seer Deluxe
 
Join Date: Jun 2012
Location: Saskatchewan, Canada
Posts: 162
Now I get this in the log:

Running script C:\Program Files (x86)\HomeSeer HS3\scripts\parseroomba2.vb :Exception has been thrown by the target of an invocation.Public member 'split' on type 'String()' not found.
Reply With Quote
  #4  
Old February 27th, 2017, 12:33 PM
acromion acromion is offline
Seer Deluxe
 
Join Date: Jun 2012
Location: Saskatchewan, Canada
Posts: 162
I figured it out. The text was showing carriage returns and line feeds when I cut and pasted it into a text editor but the actual ascii codes in the original text simply had a <(nospace)br(nospace)> at the end of each line. If I split based on that it works.

Thanks for the help.

Edit: Had to put the (nospace) filler in there so it wouldn't get interpreted instead of printed.
Reply With Quote
  #5  
Old February 27th, 2017, 12:47 PM
sparkman's Avatar
sparkman sparkman is offline
OverSeer
 
Join Date: Oct 2001
Location: Calgary, Alberta, Canada
Posts: 6,007
Quote:
Originally Posted by acromion View Post
Now I get this in the log:

Running script C:\Program Files (x86)\HomeSeer HS3\scripts\parseroomba2.vb :Exception has been thrown by the target of an invocation.Public member 'split' on type 'String()' not found.
Sorry, had messed up the code. It's fixed now, but looks like you have it resolved.

Cheers
Al
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
is it possible to parse wildcard to text? eliashall Kinect (3P) 1 May 17th, 2015 07:09 AM
Script Help - Parse JSON VB.net skarragallagher HS2 / HSPRO 17 November 26th, 2013 04:50 AM
You can use a single script line of text to toggle a device in the button skybolt HSTouch™ 0 January 7th, 2009 02:22 PM
Parse Out Last line in Text File JFTLNG Script & Plug-In Development 4 July 31st, 2006 11:49 AM
example script to parse email & extract text? alevey Script & Plug-In Development 6 January 10th, 2003 12:57 PM


All times are GMT -4. The time now is 03:46 AM.


Copyright HomeSeer Technologies, LLC