Announcement

Collapse
No announcement yet.

IP / Serial Plugin for HS3 (by "drule") - Discussion Thread

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

    How to you plan to send the command? Scipt or event or some other way?

    Check the doco for the benq and find out how it terminates a command string. Usually <cr> and or <lf>.
    Add this to the end of your command using C Escape notation ie. \r and \n respecively.

    Comment


      I am sending it as a plugin command, triggered by an event.
      The doc seems to indicate it starts with a carriage return and terminates with one. Does that make sense?

      Comment


        Strange to start with a CR...but ok.

        Just add the \r to your command at the start and end then and set the type to C Escaped.

        ie.
        \rPower On: *pow=on#\r

        Comment


          Looking for help with the script thing. I've been using this plugin and it works awesome for serial control of my Rotel RSP. But I'm only using it one-way. The return data is being read by the plugin and passed to the script (modified the gc-ire-pass.vb just enough to see if it's working). Would love to use the returned data to push into the virtual device that's holding the volume and source info.

          Here's the modified script I'm using:
          Code:
          Sub Main(Param As Object)
              Dim Params() As String = Split(Param.ToString, Chr(0))
          	' Param(0) is the name of the plugin's connector
          	' Param(1) is the ip address of the remote end
          	' Param(2) is the data received
              Dim SplitString() As String = Split(Params(2), Chr(13))
              For i As Integer = 0 To UBound(SplitString)
                  Select Case SplitString(i)
                      Case "GC-IRE XXXXXXXX"
                          ' Do stuff
                          Exit For
                      Case "GC-IRE YYYYYYYY"
                          ' Do other stuff
                          Exit For
                      Case "PANDO VOL 48"
                          hs.WriteLog("NF", "matched PANDO")
                          Exit For
          
                      Case Else
                          hs.WriteLog("drhsIpPlugin", "Volume is now: " & right(SplitString(0),3) & "(originally [" & SplitString(0) & "]")
                  End Select            
              Next
          End Sub
          And here's what shows in the log when the volume changes (even if changed at the unit - not just changed by HS):
          Code:
          drhsIpPlugin	Volume is now: 30 (originally [?? VID 3 VOL 30 ]
          The "Case PANDO..." thing is me trying to grab the source (PANDO or "VID 3"
          as examples) but having no luck at that.

          I've isolated the volume far enough to have the log show just the number... but not sure how to make that push into the virtual device.


          EDIT: got the volume working in 2-way. Just added this line after the log line I had:
          Code:
          hs.SetDeviceValue("V1",right(SplitString(0),3))
          Feels really crappy... but it works. Would love help on how I'd extract the sources. Really clueless on that since it seems to get varied lengths in the capture. And I'd guess I'm looking for a bunch of "cases" where I'd match it to each of the source patterns? By grabbing each case from /anywhere/ in the captured line? Probably easy if I can find the right command. HELP?
          Last edited by gregoryx; January 29, 2017, 09:31 PM.

          Comment


            HTTP GET

            I have a 'simple' connection and command I'm trying to setup...without luck.
            I guess it's not so simple to me.

            I'm just sending a URL directly to a Foscam camera; the url string works fine if I just punch into to a browser address bar.

            The URL is similar to this: http://myip:myport/usernameblahblah&...=blaha/command

            I created a HTTP GET connection with my IP and Port, I then created a raw text command like this: /usernameblahblah&password=blaha/command

            I created a manual event that runs the command...nothing.

            It doesn't do anything? Am I misunderstanding how this plugin works for HTTP GET?

            Comment


              Wrote my own plugin for DAB1 and Arduino

              So, I gave up waiting and wrote my own serial plugin that solves the issues identified below (Thanks to Moskus and Telholde). Like all things, easy once you know how....but a mongrel of a learning curve and HS have overcomplicated and underdocumented everything !

              I have shared a vanilla serial sample plugin code over here... https://forums.homeseer.com/showpost...3&postcount=42. You can run it in MS Visual Studio Express.

              I'll also share the Sonance DAB1 and Arduino code as well one I confirm it's final.

              Now, just need to do same for IP and share that...hopefully someone will give me a legup with some existing plugin code for IP client server comms

              Originally posted by davros View Post
              Hi David, how are you coming with the 2 bugs:

              1) Concatenation
              http://forums.homeseer.com/showpost....&postcount=527

              2) Ability to call plugin from json
              http://forums.homeseer.com/showpost....&postcount=484

              3) Plugin does not recover from a port disconnect. I am running a flaky cat6 port extender and it seems to drop and reconnect the com ports. In the below com port after x mins. (example below lasted 17min 36 sec's and 8 mins 29 sec's.

              There is also a third issue where the plugin shuts the serial connection....
              Code:
              Dec-26 7:46:44 PM	 	drhsIpPlugIn	Stopping DAB1...
              I need to restart the plugin to get it to work again.

              You can see this pattern in the below. Disabling and re-enabling the connection in the "drhsIpPlugIn"/"config"/"Connections" tab/screen produces an error saying the comm post can not be found.
              Code:
              Dec-26 7:46:46 PM	 	drhsIpPlugIn	SerialPort COM4 not found
              Dec-26 7:46:46 PM	 	drhsIpPlugIn	Starting serial client for DAB1 on COM4
              Restarting the plugin temporarily fixes the connection.
              Code:
              Dec-26 7:48:03 PM	 	Plug-In	Finished initializing plug-in drhsIpPlugIn
              Dec-26 7:48:02 PM	 	drhsIpPlugIn	Starting Tcp host for DAB1-Relay on port 1026
              Dec-26 7:48:02 PM	 	drhsIpPlugIn	Starting serial client for DAB1 on COM4
              Dec-26 7:48:02 PM	 	Info	Plugin drhsIpPlugIn has connected. IP:127.0.0.1:65464
              Dec-26 7:47:45 PM	 	Info	Plugin drhsIpPlugIn with instance: has disconnected
              Dec-26 7:47:45 PM	 	Plug-In	Shutting down Plug-In:

              Debug log below:
              Code:
              Dec-26 7:57:54 PM	 	drhsIpPlugIn	DAB1 - closing serial client
              Dec-26 7:56:34 PM	 	Z-Wave	Device: Node 21 Z-Wave Luminance Set to 36 (Lux)
              Dec-26 7:56:32 PM	 	Z-Wave	Device: Node 21 Z-Wave Temperature Set to 27 (C)
              Dec-26 7:55:15 PM	 	Warning	Not running script since its already running: C:/Program Files (x86)/HomeSeer HS3/scripts/get_emoncms.vb Single instance option enabled in event properties
              Dec-26 7:50:39 PM	 	Z-Wave	Device: Lights Z-Wave Watts 2 Set to 42.2 (42.2 Watts)
              Dec-26 7:49:25 PM	 	DAB1_Parse_In	Data(1) :+OK
              Dec-26 7:49:25 PM	 	DAB1_Parse_In	Data(1) :+OK
              Dec-26 7:49:25 PM	 	DAB1_Parse_In	Data(0) :+V323
              Dec-26 7:49:25 PM	 	DAB1_Parse_In	param(0):DAB1 Data:+V323 +OK
              Dec-26 7:49:25 PM	 	DAB1_Parse_In	Data(1) :+OK
              Dec-26 7:49:25 PM	 	DAB1_Parse_In	Data(0) :+V323
              Dec-26 7:49:25 PM	 	DAB1_Parse_In	param(0):DAB1 Data:+V323 +OK
              Dec-26 7:49:25 PM	 	DAB1_Parse_In	Data(0) :+
              Dec-26 7:49:25 PM	 	DAB1_Parse_In	param(0):DAB1 Data:+
              Dec-26 7:49:25 PM	 	DAB1_Relay_Cmd	Sending to DAB1 :V3--
              Dec-26 7:48:03 PM	 	Plug-In	Finished initializing plug-in drhsIpPlugIn
              Dec-26 7:48:02 PM	 	drhsIpPlugIn	Starting Tcp host for DAB1-Relay on port 1026
              Dec-26 7:48:02 PM	 	drhsIpPlugIn	Starting serial client for DAB1 on COM4
              Dec-26 7:48:02 PM	 	Info	Plugin drhsIpPlugIn has connected. IP:127.0.0.1:65464
              Dec-26 7:47:45 PM	 	Info	Plugin drhsIpPlugIn with instance: has disconnected
              Dec-26 7:47:45 PM	 	Plug-In	Shutting down Plug-In: drhsIpPlugIn
              Dec-26 7:46:46 PM	 	drhsIpPlugIn	SerialPort COM4 not found
              Dec-26 7:46:46 PM	 	drhsIpPlugIn	Starting serial client for DAB1 on COM4
              Dec-26 7:46:44 PM	 	drhsIpPlugIn	Stopping DAB1...
              Dec-26 7:46:35 PM	 	drhsIpPlugIn	BuildComPortList: Item has already been added. Key in dictionary: 'COM7' Key being added: 'COM7'
              Dec-26 7:42:42 PM	 	Z-Wave	Device: Node 22 Z-Wave Temperature Set to 26.62 (C)
              Dec-26 7:39:13 PM	 	drhsIpPlugIn	DAB1 - closing serial client
              Dec-26 7:21:37 PM	 	DAB1_Parse_In	Data(1) :+OK
              Dec-26 7:21:37 PM	 	DAB1_Parse_In	Data(0) :+V324
              Dec-26 7:21:37 PM	 	DAB1_Parse_In	param(0):DAB1 Data:+V324 +OK
              Note: this does not occur with any other serial clients I have tested with the DAB1 device on the same windows machine so I suspect the plugin does not detect a disconnect event and try reconnecting.

              I suspect it's the code assuming that once the port is opened, it never closes. This is not the case...a cable may fall lose or .net may pull one of it's tricks and crap out the serial. perhaps check if the port is .Open when doing a write (and every now and then) and if not open it?



              Edit: Just going to say it....it would be sooo much easier to debug this if you' publish the source...just saying.

              Comment


                Originally posted by davros View Post
                3) Plugin does not recover from a port disconnect. I am running a flaky cat6 port extender and it seems to drop and reconnect the com ports. In the below com port after x mins. (example below lasted 17min 36 sec's and 8 mins 29 sec's.
                I also have this problem that a serial port is disconnecting.
                I can detect when it is disconnected by sending every 10 minutes a command and set a device to ON.
                When the serial device replies, the device is set to OFF.
                When the device is on for more than 10 minutes, I know that the connection is dropped and an event is restarting HS.
                Is it possible in an event or script, to disconnect the connection and reconnect?
                like you can do by hand in the connections tab?
                Peter

                http://ohh.pcgsm.nl

                Comment


                  it's pretty easy to check and try a reconnect in the vb.net plugin script...so best if drule adds this to the standard plugin.

                  The following is what I am using...not perfect, but it works.

                  Code:
                      Public Sub WriteToSerialPort(theLIne As String)
                          'hs.WriteLog(IFACE_NAME, "String To Send: " & theLIne)
                          'console.WriteLine("String To Send: " & theLIne)
                          Try
                              If SerialPort1.IsOpen Then
                                  If theLIne.ToLower() = "update" Then
                                      PollDab1Status()
                                  Else
                                      Me.SerialPort1.WriteLine(theLIne & vbCr)
                                  End If
                              Else
                                  hs.WriteLog(IFACE_NAME, "ComPort Is Closed : trying to open")
                                  DAB1Startup() ' try opening it.
                              End If
                  
                          Catch e As Exception
                              hs.WriteLog(IFACE_NAME, "SerialProcessing Exception at WriteToSerialPort() writing " & theLIne & ": " & e.Message)
                  
                          End Try
                      End Sub

                  Comment


                    If I can only enable or disable a connection, then it will work for me.

                    Same like enable/disable an event:
                    Code:
                    sub main()
                    dim eref
                    eref = hs.GetEventRefByName("My Event")
                    hs.EnableEventByRef eref
                    end sub
                    Attached Files
                    Peter

                    http://ohh.pcgsm.nl

                    Comment


                      Thanks for a great tool.
                      Intend to use this plugin.

                      I have a question about the persist.
                      Is this broadcast some kind of pause frame to poll if link is up?
                      Is't the host or the client that sends this?
                      And how often is this sent?

                      My thought is to use ESP8266 in the house. I want to know if someone probably goes down. Without a formula close TCP message has been sent out.

                      Brg
                      Findus

                      Comment


                        Though this may be helpful

                        Blackbird 4k 4x4 HDMI Matrix (Monoprice 15378) / Lindy 38152 RS232

                        Port Switch Change (Will work on status codes later)

                        Blackbird HDMI A1=Binary,0xA5 0x5B 0x02 0x03 0x01 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0xF9
                        Blackbird HDMI A2=Binary,0xA5 0x5B 0x02 0x03 0x02 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0xF8
                        Blackbird HDMI A3=Binary,0xA5 0x5B 0x02 0x03 0x03 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0xF7
                        Blackbird HDMI A4=Binary,0xA5 0x5B 0x02 0x03 0x04 0x00 0x01 0x00 0x00 0x00 0x00 0x00 0xF6
                        Blackbird HDMI B1=Binary,0xA5 0x5B 0x02 0x03 0x01 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0xF8
                        Blackbird HDMI B2=Binary,0xA5 0x5B 0x02 0x03 0x02 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0xF7
                        Blackbird HDMI B3=Binary,0xA5 0x5B 0x02 0x03 0x03 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0xF6
                        Blackbird HDMI B4=Binary,0xA5 0x5B 0x02 0x03 0x04 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0xF5
                        Blackbird HDMI C1=Binary,0xA5 0x5B 0x02 0x03 0x01 0x00 0x03 0x00 0x00 0x00 0x00 0x00 0xF7
                        Blackbird HDMI C2=Binary,0xA5 0x5B 0x02 0x03 0x02 0x00 0x03 0x00 0x00 0x00 0x00 0x00 0xF6
                        Blackbird HDMI C3=Binary,0xA5 0x5B 0x02 0x03 0x03 0x00 0x03 0x00 0x00 0x00 0x00 0x00 0xF5
                        Blackbird HDMI C4=Binary,0xA5 0x5B 0x02 0x03 0x04 0x00 0x03 0x00 0x00 0x00 0x00 0x00 0xF4
                        Blackbird HDMI D1=Binary,0xA5 0x5B 0x02 0x03 0x01 0x00 0x04 0x00 0x00 0x00 0x00 0x00 0xF6
                        Blackbird HDMI D2=Binary,0xA5 0x5B 0x02 0x03 0x02 0x00 0x04 0x00 0x00 0x00 0x00 0x00 0xF5
                        Blackbird HDMI D3=Binary,0xA5 0x5B 0x02 0x03 0x03 0x00 0x04 0x00 0x00 0x00 0x00 0x00 0xF4
                        Blackbird HDMI D4=Binary,0xA5 0x5B 0x02 0x03 0x04 0x00 0x04 0x00 0x00 0x00 0x00 0x00 0xF3

                        Comment


                          Is anyone having issues with this plugin since the latest Homeseer update? I keep getting errors while trying to connect to my Global Cache GC100:

                          Apr-12 17:55:00 drhsIpPlugIn TcpClient Global Cache Com 6 TV, 192.168.1.6:4999 failed
                          Apr-12 17:54:59 drhsIpPlugIn Starting Tcp client for Global Cache Com 6 TV at address 192.168.1.6:4999
                          Apr-12 17:54:59 drhsIpPlugIn Watchdog restarting connection for Global Cache Com 6 TV
                          Apr-12 17:54:59 drhsIpPlugIn TcpClient Global Cache Com 5 WHA, 192.168.1.6:5000 failed
                          Apr-12 17:54:57 drhsIpPlugIn Starting Tcp client for Global Cache Com 5 WHA at address 192.168.1.6:5000

                          Thanks,
                          Steve

                          Comment


                            My GC100 works without problems (Zee S2).

                            Comment


                              How are you guys dealing with TCP/IP connection time outs?

                              For example, when connecting and controlling bticino's MyHome devices (through a bticino's IP gateway), connection needs to be opened first with an "open frame" command, then the gateway starts listening and executing commands perfectly.

                              But If the connection stays inactive for more than 30 secs, it closes.

                              What would be the proper way to deal with this using this plugin?

                              Thanks in advanced.

                              Comment


                                Just got my new Sony OLED and 4K player. Looking again at this plug in. All I am looking for is minor control stuff over IP
                                Power, Volume, etc

                                I assume it runs in Linux

                                I have both IP Access to both units ( XBR65Z9D and UPB-1000 ES ) as well as serial thru global cache
                                Ubuntu on the Intel NUC ( 8i5BEK ), 32 G, 250G SSD, V4 Pro 😎

                                Comment

                                Working...
                                X