Announcement

Collapse
No announcement yet.

Sample Plugin

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

    #16
    Why is the sample an exe-file? Should it not be example code?

    Comment


      #17
      I update the initial post on this forum to the latest sample plugin source. The zip contains source for 3 plugins. One shows an easy way to configure triggers and actions and a third shows how to create a multi instance plugin.
      💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

      Comment


        #18
        Thanks. Learning code from exe-files is hard ;-)

        Comment


          #19
          rjh

          Are there any walk-throughs or samples of a Linux based plugin? My main question is relating to compiling it for mono and respective best practices/tips.

          Thanks!
          HomeSeer 2, HomeSeer 3, Allonis myServer, Amazon Alexa Dots, ELK M1G, ISY 994i, HomeKit, BlueIris, and 6 "4k" Cameras using NVR, and integration between all of these systems. Home Automation since 1980.

          Comment


            #20
            You build the plugin on Windows and just copy over the EXE. Most of the time it just works as MONO is pretty complete. The MONO project page outlines interfaces that are not compatible with Linux. The obvious ones are anything PC specific or any code that references dll's directly.

            Our Z-Wave plugin is a huge plugin and the same EXE runs on both.

            Some points below (I will move this to a sticky post later).

            The code itself checks if its on Linux at startup with:

            Code:
            If hs.GetOSType = eOSType.linux Then
                            IsLinux = True
                            IsWindows = False
                            Console.WriteLine("Z-Wave Plugin: " & "OS Type is Linux")
                        Else
                            IsLinux = False
                            IsWindows = True
                            Console.WriteLine("Z-Wave Plugin: " & "OS Type is Windows")
                        End If
            If you reference file paths, you can use "/" everywhere and that works on on both Windows or Linux, or you can fix your paths as needed with:

            Code:
            Friend Function FixPath(ByVal fpath As String) As String
                    If IsLinux Then
                        Return fpath.Replace("\", "/")
                    Else
                        Return fpath
                    End If
                End Function
            For vb.net MONO does not have the "Err" class so just wrap so the code does not care:

            Code:
            Public Function Erl() As Integer
                    Return 0
                End Function
            
                Public Class Err
                    Public Shared Number As Integer = 0
                    Public Shared Erl As Integer = 0
                    Public Shared Description As String = ""
                    Public Shared Sub Clear()
                    End Sub
                End Class
            Also, MONO does not have the "Application" class, so we wrap that also:

            Code:
            Class Application
                    Shared Sub DoEvents()
                        Threading.Thread.Sleep(10)
                        'If IsWindows Then
                        'System.Windows.Forms.Application.DoEvents()
                        'End If
                    End Sub
            
                    Shared Function ProductVersion() As String
                        Return My.Application.Info.Version.ToString
                    End Function
                End Class



            Originally posted by Krumpy View Post
            rjh

            Are there any walk-throughs or samples of a Linux based plugin? My main question is relating to compiling it for mono and respective best practices/tips.

            Thanks!
            💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

            Comment


              #21
              Wow - cool - Thanks! Appreciate the quick response.
              HomeSeer 2, HomeSeer 3, Allonis myServer, Amazon Alexa Dots, ELK M1G, ISY 994i, HomeKit, BlueIris, and 6 "4k" Cameras using NVR, and integration between all of these systems. Home Automation since 1980.

              Comment


                #22
                Are the steps the same for RPI based Linux? How would one compile for RPI? From a code perspective what you provided earlier still applies, but the source needs to be compiled. I’ve done some research, but in case there are some differences in regards to HomeSeer, would appreciate some guidance in how to compile plugin for usage on RPI based hardware.

                second, if the plugin runs remotely on a Pi connected to a Windows based HS installation, does anything special need to be done with In terms of HS licensing? Doubt ful Hs but what about plugin license?

                thx!1
                HomeSeer 2, HomeSeer 3, Allonis myServer, Amazon Alexa Dots, ELK M1G, ISY 994i, HomeKit, BlueIris, and 6 "4k" Cameras using NVR, and integration between all of these systems. Home Automation since 1980.

                Comment


                  #23
                  There is no difference in the actual .exe file for windows or linux - they are the same. Inside the code itself, you just use the FixPath function above when referencing physical files.
                  HS4Pro on a Raspberry Pi4
                  54 Z-Wave Nodes / 21 Zigbee Devices / 108 Events / 767 Devices
                  Plugins: Z-Wave / Zigbee Plus / EasyTrigger / AK Weather / OMNI

                  HSTouch Clients: 1 Android

                  Comment


                    #24
                    As rmasonjr mentioned the same EXE you build on Windows will run on Linux. You may have to build it with the "Any Cpu" setting. So no compiling on Linux, just copy over the EXE.

                    Use "Console.WriteLine("")" to print out any debug messages if you need to debug on Linux, there isn't any debugger that works well there.

                    Make sure you Try/Catch everything and log any errors with Console.Writeline so you can see any errors.

                    As for licensing, there are some issues there as HS needs to see the EXE file and it will not see it on a remote system. So the user will need to install it on Windows, license it, then they can run it remotely. At some point we need to address remote plugin licensing.

                    Originally posted by Krumpy View Post
                    Are the steps the same for RPI based Linux? How would one compile for RPI? From a code perspective what you provided earlier still applies, but the source needs to be compiled. I’ve done some research, but in case there are some differences in regards to HomeSeer, would appreciate some guidance in how to compile plugin for usage on RPI based hardware.

                    second, if the plugin runs remotely on a Pi connected to a Windows based HS installation, does anything special need to be done with In terms of HS licensing? Doubt ful Hs but what about plugin license?

                    thx!1
                    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                    Comment


                      #25
                      Thanks - Happy thanksgiving
                      HomeSeer 2, HomeSeer 3, Allonis myServer, Amazon Alexa Dots, ELK M1G, ISY 994i, HomeKit, BlueIris, and 6 "4k" Cameras using NVR, and integration between all of these systems. Home Automation since 1980.

                      Comment

                      Working...
                      X