Announcement

Collapse
No announcement yet.

HS3 Plugin Samples

Collapse
This is a sticky topic.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #91
    I ran it here and it worked fine a remote PC. Download the latest sample, maybe I need to update the posted samples:

    ftp://homeseer.com/pub/HSPI_SAMPLE.exe

    On the remote PC launch the plugin with a command prompt with:

    hspi_sample.exe server=x.x.x.x

    Should connect without error.

    Originally posted by Kirby View Post
    I have run the installer and all three of the HS3 dlls are referenced:
    HomeSeerAPI.dll 2/17/14 1.0.2.1
    HSCF.dll 2/17/14 1.0.0.2
    Scheduler.dll 2/17/14 3.0.0.0
    website | buy now | support | youtube

    Comment


    • #92
      I'm still getting the error. This is what it says in the HS Log.
      Initializing plug-in(2): Sample Plugin Instance::Object reference not set to an instance of an object.0STACK: at System.Runtime.Remoting.Messaging.LogicalCallContext.Propaga teIncomingHeadersToCallContext(IMessage msg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(Mess ageData& msgData, Int32 type) at HomeSeerAPI.IPlugInAPI.InitIO(String port) at Scheduler.clsHSPI.CheckInterfaces()

      I have a couple of plugins on the Hometroller that are not copied to the directory on the remote machine where the HSPI_Sample is running from. Could that be the problem?

      Comment


      • #93
        Your example is working now. I copied the plugins from the hometroller to the sample directory and it now works.

        The three I copied were:
        HSPI_Zwave.exe
        HSPI_HAI_Omnistat.exe
        HSPI_Sample_CS.exe (a C# version of HSPI_SAMPLE)

        Comment


        • #94
          My sample now works also. The only plugin I needed to add a reference to was HSPI_HAI_Omnistat.exe.

          I guess, from the thread that Mr. Happy pointed me to, that this plugin is serializing complex objects that can't be deserialized without the class definition.

          Comment


          • #95
            Originally posted by Kirby View Post
            My sample now works also. The only plugin I needed to add a reference to was HSPI_HAI_Omnistat.exe.

            I guess, from the thread that Mr. Happy pointed me to, that this plugin is serializing complex objects that can't be deserialized without the class definition.
            That is my understanding of it also, whoever wrote that plugin should be able to elaborate on whether they are or not...
            My Plugins:

            Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
            Yeelight 3P | Nanoleaf 3P

            Comment


            • #96
              I hope not to drive everyone crazy with not to bright questions but I'm trying to run the HSPI_SAMPLE_BASIC plugin and the compiler complains

              Warning 1 Function 'Search' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used. C:\HS3 Development\HSPI_SAMPLE_BASIC\hspi.vb 280 5 HSPI_SAMPLE_BASIC


              I've tried a return statement return "" but doesn't like that.

              What is the search function looking for? The exe does compile....

              Also I'm struggling with opening and closing a comport.

              in the hspi.vb module I found the port# string in the var port which I'm assuming it gets from the interface
              page.

              PHP Code:
                 Public Function InitIO(ByVal port As String) As String Implements HomeSeerAPI.IPlugInAPI.InitIO
                      
              Return oPlugin.InitIO(port)
                  
              End Function 
              In the same module I'm trying to open and close a com port using the following code.

              PHP Code:
               Public Shared Sub myComPort()
                      
              Dim MSComm1 As New SerialPort(x)

                      
              MSComm1.BaudRate 9600
                      MSComm1
              .Parity Parity.None
                      MSComm1
              .StopBits StopBits.One
                      MSComm1
              .DataBits 8
                      MSComm1
              .Handshake Handshake.None

                      
              'AddHandler MSComm1.DataReceived, AddressOf DataReceivedHandler

                      MSComm1.Open()

                  End Sub 
              Question 1: How do I get the port number to use in the Sub myComPort? In HS2 I declared a public
              variable and assigned it the port number in the Function InitIO.

              Question 2: How do I make the object MSComm1 public, so I can create a sub to close it without creating a new serial port object?

              Thanks
              Last edited by donstephens; June 4th, 2014, 11:25 PM.
              Don

              Comment


              • #97
                Don, the first warning is just a warning and it should compile and run without it. HS I don't believe have documented or are really using the search functionality so I would not worry too much about it.

                Concerning the serial port is this the .net ports class you are using or the old mscomm control that was used with VB6 (it looks .net-ish but the control name is an older control name). I guess there is nothing wrong with using it but if you are trying for linux support then it should be the .net version. I do this with the .net ports class:

                In the declarations declare

                Code:
                Public WithEvents sP As New System.IO.Ports.SerialPort
                Then I create it with this;

                Code:
                    Private Sub InitComm(ByVal port As String)
                        Log("InitComm Called: " & port, LogLevel.Debug)
                
                        With sP
                            .PortName = port
                            .BaudRate = 57600
                            .DataBits = 8
                            .ReadBufferSize = 214740
                            .Handshake = Handshake.None
                            .Parity = Parity.None
                        End With
                
                        Try
                            sP.Open()
                
                            If sP.IsOpen Then
                                Log("COM Port Open", LogLevel.Debug)
                                Log("COM Port Open", LogLevel.Normal)
                            Else
                        Catch ex As Exception
                            Log("Unable To Open COM Port: " & ex.Message, LogLevel.Normal)
                            Log("InitComm Exception: " & ex.Message, LogLevel.Debug)
                        End Try
                
                
                    End Sub
                I call InitCom from InitIO just using
                Code:
                InitComm(port)
                which just passes the port straight through. Then to handle the data I just use this event handler
                Code:
                Private Sub SerialData(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) Handles sP.DataReceived
                        Log("SerialData Sub Called", LogLevel.Debug)
                        DataInput(sP.ReadLine)
                    End Sub
                Which passes the line read to another sub routine for processing.

                So in respect to 1) I would pass 'port' into your myComPort routine, accept it as a parameter and use this when you are creating the new serial port however for 2) if you placed 'Dim MSComm1 As New SerialPort' outside of the subroutine then it should be across the class so you would then just need to instead select the port name (so you would add another line of .portname = port or some such) and you could close it by just doing mscomm1.close (or whatever the command is) from another sub.
                My Plugins:

                Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
                Yeelight 3P | Nanoleaf 3P

                Comment


                • #98
                  Thanks Adam. Will try it when I get home.

                  Sent from my XT1080 using Tapatalk
                  Don

                  Comment


                  • #99
                    Still struggling. I'm trying to walk through the code (Visual Studio Express) but hangs if I start with the step thru and the plugin isn't initialized. If I initialize it via Interfaces page and then try to step through the code I get an error saying the plugin is already active.

                    Is there some simple (read novice) way to step through the code to see what is going on?

                    Sorry for the lame questions.
                    Don

                    Comment


                    • Originally posted by donstephens View Post
                      Still struggling. I'm trying to walk through the code (Visual Studio Express) but hangs if I start with the step thru and the plugin isn't initialized. If I initialize it via Interfaces page and then try to step through the code I get an error saying the plugin is already active.

                      Is there some simple (read novice) way to step through the code to see what is going on?

                      Sorry for the lame questions.
                      I personally don't use step through so I can't help there, is there a specific error or function you are trying to run through? All I do from Visual Studio is run the project and it runs the project, any debugging I try and do into the console window. If I must I set a breakpoint but it is rare I need one. With HS3 now you do not need to enable the plugin in the interfaces menu and can just run it straight from VS.
                      My Plugins:

                      Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
                      Yeelight 3P | Nanoleaf 3P

                      Comment


                      • Set your breakpoint (F9) to a line in InitIO. This is where the plugin initializes its connection to HomeSeer.
                        HS3Pro Running on a Raspberry Pi3
                        64 Z-Wave Nodes, 168 Events, 280 Devices
                        UPB modules via OMNI plugin/panel
                        Plugins: Z-Wave, BLRF, OMNI, HSTouch, weatherXML, EasyTrigger
                        HSTouch Clients: 3 Android, 1 Joggler

                        Comment


                        • Thanks to much help I am now receiving data from my Denon Receiver. On to creating devices. The sample code has a function called InitHSDevice. One of the params it wants is
                          a type Scheduler.Classes.DeviceClass. A bit lost here... do I create a new variable of the type Scheduler.Classes.DeviceClass?

                          Dim NewDevice As New Scheduler.Classes.DeviceClass?
                          Don

                          Comment


                          • Originally posted by donstephens View Post
                            Thanks to much help I am now receiving data from my Denon Receiver. On to creating devices. The sample code has a function called InitHSDevice. One of the params it wants is
                            a type Scheduler.Classes.DeviceClass. A bit lost here... do I create a new variable of the type Scheduler.Classes.DeviceClass?

                            Dim NewDevice As New Scheduler.Classes.DeviceClass?
                            The sample (if I never edited mine) just wants an optional reference by parameter...if this helps here is some source code of a plugin to send data to a RGB LED controller by TCP socket. Not saying my programming is the best but it the creating devices stuff works fine and you want a rough idea it could be somewhere to start...it is quite simple.
                            Last edited by mrhappy; January 31st, 2015, 05:30 PM.
                            My Plugins:

                            Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
                            Yeelight 3P | Nanoleaf 3P

                            Comment


                            • mrhappy, thanks!
                              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


                              • Thanks. Will take a look.
                                Don

                                Comment

                                Working...
                                X