Announcement

Collapse
No announcement yet.

Does hs.SendToComPort work or is it only me?

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

  • Does hs.SendToComPort work or is it only me?

    I'm trying to control the HDMI switch (from Monoprice). This is the exact same script as in HS2:

    Code:
    Sub Main(parm as object)
    hs.OpenComPort(5,"4800,n,8,1",1,"","")
    hs.WaitSecs(1)
    hs.sendtocomport(5, parm.tostring & vbCrLf)
    hs.WaitSecs(1)
    hs.CloseComPort(5)
    End Sub
    (for example, calling sub "Main" with parameter "OFF").

    And this worked without problems in HS2. The same methods with the same arguments exist in HS3, but I get no reaction from the switch.

    What gives?
    HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
    Running on Windows 10 (64) virtualized
    on ESXi (Fujitsu Primergy TX150 S8).
    WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

    Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

  • #2
    Fixed?

    Originally posted by Moskus View Post
    I'm trying to control the HDMI switch (from Monoprice). This is the exact same script as in HS2:

    Code:
    Sub Main(parm as object)
    hs.OpenComPort(5,"4800,n,8,1",1,"","")
    hs.WaitSecs(1)
    hs.sendtocomport(5, parm.tostring & vbCrLf)
    hs.WaitSecs(1)
    hs.CloseComPort(5)
    End Sub
    (for example, calling sub "Main" with parameter "OFF").

    And this worked without problems in HS2. The same methods with the same arguments exist in HS3, but I get no reaction from the switch.

    What gives?
    Did you ever get this figured out?

    Comment


    • #3
      No...
      HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
      Running on Windows 10 (64) virtualized
      on ESXi (Fujitsu Primergy TX150 S8).
      WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

      Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

      Comment


      • #4
        Here's a script I used to use in HS3 to control my monoprice amp. (before the plugin) Maybe something useful in it.

        Code:
        'Send Parameters in the form target|command|value ie. z1|volume|20
        'targets: a1,a2,a3, z1,z2,z3,z4,z5,z6,z7,z8,z9,z10,z11,z12,z13,z14,z15,z16,z17,z18.
        'commands: power,volume, mute, dnd(do not disturb),balance, treble, bass, source.
        'value: on, off, volume 00-38, treble/base 00-14, balance 00-20
        'Don't forget to set the com port
        
        Imports System.Threading
        Imports System.IO.Ports
        Imports System.Object
        Imports System.Text
        Public COMPort As New SerialPort()
        
        Public Sub Main(ByVal parm as Object)
        
        Dim tcArray(2) As String
        tcArray = parm.ToString.Split("|")
        Dim target As String = tcArray(0)
        Dim command As String = tcArray(1)
        Dim value As String = tcArray(2)
        
        hs.writelog("Monoprice Amp", "Script called with: "& target & "|" & command & "|" & value)
        
        Dim tcString = "" 'this is what will eventually be sent to the com port
        Dim tcStringBuilder As New StringBuilder("<") 'start building tcString
        
        Select Case target           'Select Target
        Case "a1"
        tcStringBuilder.Append ("10")
        Case "a2"
        tcStringBuilder.Append ("20")
        Case "a3"
        tcStringBuilder.Append ("30")
        Case "z1"
        tcStringBuilder.Append ("11")
        Case "z2"
        tcStringBuilder.Append ("12")
        Case "z3"
        tcStringBuilder.Append ("13")
        Case "z4"
        tcStringBuilder.Append ("14")
        Case "z5"
        tcStringBuilder.Append ("15")
        Case "z6"
        tcStringBuilder.Append ("16")
        Case "z7"
        tcStringBuilder.Append ("21")
        Case "z8"
        tcStringBuilder.Append ("22")
        Case "z9"
        tcStringBuilder.Append ("23")
        Case "z10"
        tcStringBuilder.Append ("24")
        Case "z11"
        tcStringBuilder.Append ("25")
        Case "z12"
        tcStringBuilder.Append ("26")
        Case "z13"
        tcStringBuilder.Append ("31")
        Case "z14"
        tcStringBuilder.Append ("32")
        Case "z15"
        tcStringBuilder.Append ("33")
        Case "z16"
        tcStringBuilder.Append ("34")
        Case "z17"
        tcStringBuilder.Append ("35")
        Case "z18"
        tcStringBuilder.Append ("36")
        
        Case Else
        hs.writelog("Monoprice Amp", "Target not found: " & target)
        End Select
        
        Select Case command
        Case "power"
        tcStringBuilder.Append ("PR")
        Case "mute"
        tcStringBuilder.Append ("MU")
        Case "volume"
        tcStringBuilder.Append ("VO")
        Case "dnd"
        tcStringBuilder.Append ("DT")
        Case "treble"
        tcStringBuilder.Append ("TR")
        Case "bass"
        tcStringBuilder.Append ("BS")
        Case "balance"
        tcStringBuilder.Append ("BL")
        Case "source"
        tcStringBuilder.Append ("CH")
        
        Case Else
        hs.writelog("Monoprice Amp", "Command not found: " & command)
        End Select
        
        Select Case value
        Case "on"
        tcStringBuilder.Append ("01")
        case "off"
        tcStringBuilder.Append ("00")
        
        Case Else
        tcStringBuilder.Append (value)
        End Select
        
        
        tcString = tcStringBuilder.ToString()
        
        Dim Com as Object
        Dim rxBuff as String
        rxBuff = ""
        
        COMPort.PortName = "COM5"
        COMPort.BaudRate = 9600
        COMPort.Parity = System.IO.Ports.Parity.None
        COMPort.DataBits = 8
        COMPort.StopBits = System.IO.Ports.StopBits.One
        Comport.ReadTimeout = 1000
         
        If COMPort.IsOpen = False Then 
         COMPort.Open() 
        End If
         
        Com = tcString & vbCr
         
        hs.writelog("Audio", "Sending: " & Com)
         
        COMPort.Write(Com)
        
        System.Threading.Thread.Sleep(600)
        
        'Reading the com port:
        rxBuff = (COMPort.ReadExisting)
        
        If rxBuff <> "" Then
        hs.writelog("Audio", "Received:" & rxBuff)
        rxBuff = ""
        End If
        
        COMPort.close()
         
        End Sub
        If it ain't broke, don't fix it!

        Comment


        • #5
          Originally posted by Moskus View Post
          I'm trying to control the HDMI switch (from Monoprice). This is the exact same script as in HS2:



          Code:
          Sub Main(parm as object)
          
          hs.OpenComPort(5,"4800,n,8,1",1,"","")
          
          hs.WaitSecs(1)
          
          hs.sendtocomport(5, parm.tostring & vbCrLf)
          
          hs.WaitSecs(1)
          
          hs.CloseComPort(5)
          
          End Sub
          (for example, calling sub "Main" with parameter "OFF").



          And this worked without problems in HS2. The same methods with the same arguments exist in HS3, but I get no reaction from the switch.



          What gives?


          Your script would probably work if you allowed more time for the com port to open. 1 second is way too short. 5-10 seconds is more realistic. Once the port is open, leave it open. No need to reopen it each time you send a command.

          I use sendtocomport a lot in HS3. I use a one line immediate script.

          Steve Q


          Sent from my iPad using Tapatalk
          HomeSeer Version: HS3 Pro Edition 3.0.0.368, Operating System: Microsoft Windows 10 - Home, Number of Devices: 373, Number of Events: 666, Enabled Plug-Ins
          2.0.83.0: BLRF, 2.0.10.0: BLUSBUIRT, 3.0.0.75: HSTouch Server, 3.0.0.58: mcsXap, 3.0.0.11: NetCAM, 3.0.0.36: X10, 3.0.1.25: Z-Wave,Alexa,HomeKit

          Comment


          • #6
            Originally posted by Steve Q View Post
            1 second is way too short. 5-10 seconds is more realistic.
            Hmmm! That might be it! I haven't even thought about that.

            But I scraped that Monoprice HDMI switch a couple of years ago...
            HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
            Running on Windows 10 (64) virtualized
            on ESXi (Fujitsu Primergy TX150 S8).
            WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

            Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

            Comment

            Working...
            X