Announcement

Collapse
No announcement yet.

How do I send a string over the ip network of the homeseer in infrared

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I send a string over the ip network of the homeseer in infrared

    hello, i live in brazil.


    I have an equipment that emits infrared signals much like the global cache. I've tried using the global cache plugin, but it does not recognize the device in the plugin. This equipment is called 7PORT works very well and cheaper. I would like to know how I send the string with the infrared code through the tcp network. Could you help me create a script? I do not have much experience. the device has 7 infrared ports, receives signals from the tcp network and sends to those ports p2 in the equipment. I do not understand much of structure. I did not find any commands or examples in the homeseer manual. I asked for support for them and it does not have a plugin for homeseer. I would like to use buttons in the hstouch application to send these infrared commands to the device.
    I put an attachment with more detailed information of the code and the equipment
    Thank you in advance.
    Attached Files

  • #2
    This is not tried, but should be close. You need to specify the IP and Port of the 7PORT unit. You will also likely want to parameterize the script to pass in the Command, but this should do for testing.

    Code:
    Sub Main(parms As Object)
      Dim IP as String = "192.168.1.2"
      Dim Port as Integer = 8000
      Dim Command as String = "sendir,1:3,1,40000,3,1,96,24,48,24,24,24,48,24,24,24,48,24,24,24,24,24,48,24,24,24,24,24,24,24,24,1035"
      Dim commandInBytes() As Byte = System.Text.Encoding.ASCII.GetBytes(Command)
      Dim tcpClient As New System.Net.Sockets.TcpClient
    
      If tcpClient.Connect(System.Net.IPAddress.Parse(IP), Port) Then
        Dim networkStream As System.Net.Sockets.NetworkStream = tcpClient.GetStream()
        networkStream.Write(commandInBytes, 0, commandInBytes.Length)
        tcpClient.Close()
      End if
    End Sub

    Comment


    • #3



      The following error is appearing when I try to run scriots

      Running script, script run or compile error in file: C: / Program Files (x86) / HomeSeer HS3 / scripts / Codigos.vbs1006: ')' expected in line 1 More info: ')' expected

      Comment


      • #4
        Here is my version of a TCP/IP write. Maybe it will help. Just replace the IP address, Port, and Command in the script and it should work.


        Code:
        ' import required modules
        Imports System.Net
        Imports System.Net.Sockets
        Imports System.Text
            Sub Main(ByVal parms as Object)
                Const IP = "192.168.1.XXX"
                Const Port = XXXX
                Const Command = "sendir,1:2,1,37993,1,1,342,170,22,21,22,21,22,63,22,21,22,21,22,21,22,21,22,21,22,63,22,63,22,21,22,63,22,63,22,63,22,63,22,63,22,21,22,21,22,21,22,63,22,21,22,21,22,21,22,21,22,63,22,63,22,63,22,21,22,63,22,63,22,63,22,63,22,1514,342,85,22,3654,342,3799" &vbCR
                Dim tcpClient As New System.Net.Sockets.TcpClient()
                tcpClient.Connect(IP, Port)
                Dim networkStream As NetworkStream = tcpClient.GetStream()
                Dim strResponse As String
                strResponse = "No response"
                  If networkStream.CanWrite Then
                     Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes(Command)
                     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

        Comment


        • #5

          Thank you very much.

          Worked all right

          Comment

          Working...
          X