Hi, I'm newbie using homeseer and hstouch .. I created a script using select case to send infrared codes in the tcp ip network. through an event with the function "Run a Script or Script Command" using a Parameters with the name of the case that is in the script to send the infrared codes.
It turns out that I do not want to be creating events in homesser, I want to call these cases from the direct button script in the hstouch interface. I do not quite understand the functions of vbs and everything I try to do in hstouch is generating errors, it is not working.
I need to know only what command I should write on the hstouch tab to call the script case.

Please help me!
Below is the script that works and uses hstouch images.






' import required modules
Imports System.Net
Imports System.Net.Sockets
Imports System.Text

Sub Main(ByVal parms as Object)


' COMANDOS MANUAIS AR CONDICIONADO SALA DE ESTAR *-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Select case parms

Case "ARESTARLIGA"
Const Digit_1 = "sendir,1:4,1,38000,1,1,126,62,15,16,15,16,15,47,15,16,1 5,47 ,15,16,15,16,15,16,15,47,15,47,15,16,15,16,15,16,15,47,15,47 ,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16 ,15,16,15,16,15,16,15,47,15,16,15,16,15,16,15,16,15,16,15,16 ,15,16,15,47,15,16,15,16,15,16,15,16,15,47,15,47,15,47,15,47 ,15,47,15,47,15,47,15,47,15,16,15,16,15,47,15,16,15,16,15,16 ,15,16,15,16,15,16,15,16,15,16,15,47,15,47,15,16,15,16,15,47 ,15,16,15,16,15,16,15,16,15,47,15,16,15,16,15,47,15,16,15,16 ,15,16,15,16,15,16,15,16,15,16,15,47,15,16,15,16,15,16,15,16 ,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16 ,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16 ,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16 ,15,16,15,16,15,47,15,16,15,16,15,47,15,16,15,47,15,47,15,16 ,15,16,15,16,15,47,15,2000\r\n"&vbCR

CALL ENVIADADOS(Digit_1)


Case "ARESTARDESLIGA"
Const Digit_1 = "sendir,1:4,1,38000,1,1,126,62,15,16,15,16,15,47,15,16,1 5,47 ,15,16,15,16,15,16,15,47,15,47,15,16,15,16,15,16,15,47,15,47 ,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16 ,15,16,15,16,15,16,15,47,15,16,15,16,15,16,15,16,15,16,15,16 ,15,16,15,47,15,16,15,16,15,16,15,16,15,47,15,16,15,16,15,16 ,15,16,15,16,15,16,15,47,7,423,0,52852,7,16,15,47,15,47,15,4 7,15,47,15,47,15,47,15,2000\r\n"&vbCR

CALL ENVIADADOS(Digit_1)


Case "ARESTAR16"
Const Digit_1 = "sendir,1:4,1,38000,1,1,126,62,15,16,15,16,15,47,15,16,1 5,47 ,15,16,15,15,15,15,15,47,15,47,15,15,15,15,15,16,15,47,15,47 ,15,15,15,16,15,16,15,16,15,16,15,15,15,15,15,16,15,16,15,16 ,15,16,15,15,15,15,15,47,15,16,15,16,15,16,15,15,15,15,15,16 ,15,16,15,47,15,15,15,15,15,16,15,16,15,47,15,47,15,47,15,47 ,15,47,15,47,15,47,15,47,15,16,15,16,15,47,15,16,15,16,15,16 ,15,16,15,16,15,15,15,16,15,16,15,47,15,47,15,16,15,16,15,16 ,15,16,15,16,15,16,15,15,15,15,15,16,15,16,15,16,15,16,15,47 ,15,15,15,15,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,47 ,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16 ,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16 ,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16,15,16 ,15,16,15,16,15,47,15,16,15,16,15,16,15,16,15,47,15,47,15,47 ,15,16,15,16,15,47,15,2000\r\n"&vbCR

CALL ENVIADADOS(Digit_1)



End Select

End Sub



Private Sub ENVIADADOS (Digit_2)

Const Host = "192.168.0.100"
Const HostPort = 4998

Dim tcpClient As New System.Net.Sockets.TcpClient()
tcpClient.Connect(host, hostport)
Dim networkStream As NetworkStream = tcpClient.GetStream()
Dim strResponse As String
strResponse = "No response"
If networkStream.CanWrite Then
Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(Digit_2)
networkStream.Write(sendBytes, 0, sendBytes.Length)
Dim bytes(tcpClient.ReceiveBufferSize) As Byte
networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize))
Dim returndata As String = Encoding.ASCII.GetString(bytes)
strResponse = "Device responded: " & CStr(returndata)

Else

If Not networkStream.CanWrite Then
strResponse = "Error: Cannot write data to the device"
tcpClient.Close()
End If
End If

End Sub
Attached Files