Announcement

Collapse
No announcement yet.

Run HTTP command from HS script on HS PRO Linux (macos)

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

    Run HTTP command from HS script on HS PRO Linux (macos)

    Hi,
    I have to execute a http command (http://192.168.0.116:8081/json.htm?t...2&seccode=c646) from a HS script in an event.


    have tried many ways, but I allways get some sort of an error like this:
    Compiling script /Users/riendupre/HomeSeer/scripts/ArmAway.vb: Visual Basic.Net Compiler version 0.0.0.5943 (Mono 4.8 - (HEAD/ce5406a) Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved. vbnc : Command line : error VBNC2017: The library 'Scheduler.dll' could not be found. There were 1 errors and 0 warnings. Compilation took 00:00:00.2313940

    Any help would be more than welcome

    Thanks,
    Rien
    Regards,

    Rien du Pre
    The Netherlands
    Using:
    Homeseer PRO latest HS4 BETA on a Raspberry
    Plugin's:
    RFXCOM, mcsMQTT, Z-Wave

    #2
    +1 on this. I have a post under HSTouch where I want to use a button to send such a command. I could put the command in an event as an immediate script and use the button in HSTouch to run the script. When I tried this I got errors also. When I put the command in a browser address bar it worked.

    Chuck

    Comment


      #3
      I think one might be able to do it with the code below, however I'm using "drule":s IP / RS232 plugin for this kind of communication:
      https://forums.homeseer.com/forum/de...r-hs3-by-drule

      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
      I'm not the father of the script above.

      Comment


        #4
        If this is a simple GET and doing it from an event. This works.

        HTML Code:
        &hs.GetURL("192.168.1.86","/rest/nodes/5399/cmd/DON",TRUE,80)
        Simple GET call I use a lot from HS3.

        Comment

        Working...
        X