Page 1 of 1

Getting text in a device

Posted: Thu Feb 28, 2013 9:57 am
by ldborn
I have a smartfone which is running tasker, tasker is getting my location and translates it to an adress. I can post this adress as a text file to my server where homeseer is running. I want to import this text file as a device or stringvalue in a virtual homeseer device. Is this possible? I can't script. Is there anybody who can drop a couple of scripting lines for me?

Re: Getting text in a device

Posted: Thu Feb 28, 2013 11:04 am
by AshaiRey
Did you think of the possibility to use this functionality?
homeseer.com/support/homeseer/WebHelp2/ ... ontrol.htm

Re: Getting text in a device

Posted: Thu Feb 28, 2013 1:15 pm
by ldborn
Sorry this is not what I mean, I have a text file on my server, in this text file is my adress. I want to import this adress in a virtual homeseer device

Re: Getting text in a device

Posted: Thu Feb 28, 2013 1:50 pm
by AshaiRey
First of all.
This is such a simple task with soooo many examples that you should be able to do it yourself.
You know what you want to do and you can google.
Learn a new thing each day is the motto.

Update the device and filepath in this code
Save as a .vb file
Remark: Code not tested but should work as planned.

Code: Select all

Public Sub Main(ByVal Parms As String)
	Const fsoForReading = 1

	Dim Device as String
	Dim strDevice as String
	Dim objFSO as Object
	Dim objFile as Object

	'Your virtual device code
	Device = "<your device code>"

	objFSO = CreateObject("Scripting.FileSystemObject")

	Try
	  objFile = objFSO.OpenTextFile("<full path to your textfile including filename>", fsoForReading )
	  strDevice = objFile.ReadLine

	  hs.setdevicestring(Device, strDevice)

	Catch e as Exception
	  hs.WriteLog("Script error",e.Message)
	End Try

 	objFSO        = Nothing
	objFile       = Nothing
End Sub

Re: Getting text in a device

Posted: Thu Feb 28, 2013 2:53 pm
by ldborn
This works, thanks man !