Announcement

Collapse
No announcement yet.

HSPI_MoskusSample - An easier plugin sample [VB.NET]

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

  • HSPI_MoskusSample - An easier plugin sample [VB.NET]

    The wait is finally over!
    I'm releasing my simple basic plugin sample, so that others can get started with writing plugins and (hopefully) contribute to the sample. I'll be adding elements as I get to them writing my own plugins.

    The plugin is based on the samples from HomeSeer Tech, but I've added comments from the SDK and online help (and links to it so that it's easier accessible), I've renamed many variables to make them more compliant with newer naming conventions and make them easier to read and understand what's really going on (I am of course not able to rename classes from HS3, so there's a few strange things like "strTrigActInfo" which is not a string at all). I've also added a few elements to make coding easier (like a custom Settings class and functions to handle Linq on Devices and Events).

    The samples and APIs from HomeSeer are really totally awesome! The versatility and integration is quite unique, and that leaves endless possibilities. It's just that I found the samples from HST somewhat confusing to understand, and as there are virtually no comments, it was rather hard to get going. I figured the time I spent on understanding the sample could be put to good use, so that others will save some time.

    I've stared a simple FAQ below.
    Q: "What does this plugin do?"
    A: Nothing very useful, it just does "something" to get you started. Heres a quick summary:
    1. It generates a random value every X minutes or seconds (this Is user changeable by a settings page). This is used to show how triggers and conditions work. See the region "Trigger Interface".

    2. It generates different types of devices, just to show how that could be done and how the plugin reacts to usage of the different controls (CAPI). See the sub "CheckAndCreateDevices".

    3. It shows how text, values and even custom objects can be stored in a device, and how you create your own "Tab" on the device settings. See subs "ConfigDevice" and "ConfigDevicePost".

    4. It has a simple settings page that demonstrate how you can update settings for your plugin.


    Q: "What do I need?"
    A: You need Visual Studio (Visual Studio Community Edition should work just fine), HomeSeer 3 running either locally or on a remote computer, some spare time (the more, the better), and an appetite for coding.


    Q: "Where do I start?"
    A: 1. Copy "HomeSeerAPI.dll", "HSCF.dll" and "Scheduler.dll" from your HS3 dir to into the dir of this project (extract the zip file first, of course).
    2. Just start HS3 if its not running, and hit Debug in Visual Studio. Then youll see whats going on
    3. Do some customization, I suggest start by naming your plugin. this is done several places:
    a. In "utils.vb", see variables "IFACE_NAME" and "INIFILE".
    b. See in "My Project" in the Solution, and change both
    c. If you, like me, dont want the solution and project named "MoskusSample" you can edit the .vbproj and .sln files in notepad (but close Visual Studio first).
    4. Then look into the "Plugin.vb" file. A good place like any other is to start by finding the sub "InitIO", whats where the plugin is initialized.
    5. However, if you REALLY want to dive right in to it, find the "UpdateTimerTrigger" sub and read to the end.


    Here's a screenshot of the devices the plugin creates:


    The sample demonstrates a few different methods for creating devices and how to handle input and output of data.


    Here's a screenshot of Event triggers and actions:


    The sample has two Triggers. One without subtriggers and one with. Both can be used as a condition. See Enums "TriggerTypes" and "SubTriggerTypes" which I've added to make "(int) TrigInfo.TANumber" and "(int) TrigInfo.SubTANumber" more understandable.

    I've just added one action, but most of the same logic applies also applies to actions.


    This sample doesn't magically make writing plugins super easy. It still requires some time to understand how it is pieced together. But hopefully it will get you started.

    If you know what you are doing and have comments of what I can do better, then please feel free to let me know. Share code if you can.


    What is missing at the moment:
    • Public plugin functions
    • Public property get/set
    • Proper documentation for web page building (I'm not done yet)


    And last:
    If you want, you can always "tip" me via Paypal to "moskus a_t gmail d_o_t com" (where "a_t" = "@" and "d_o_t" = "."). It is not expected or required, but highly appreciated.


    Download in the next post.


    I've written a basic "Getting Started" post here.
    Last edited by Moskus; December 18th, 2015, 04:06 AM.
    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
    Here's the download.

    Changelog:
    1.0.0: Initial release.
    Attached Files
    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


    • #3
      Excellent work!

      Comment


      • #4
        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


        • #5
          Many thanks !
          I wish something like this in C# will be available too ...

          Comment


          • #6
            I'm thinking about converting it to C#. But I thougt I'd release the VB-version first.
            (I'm actually a faster coder in VB than C#, but I'm getting more and more used to C# too.)
            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


            • #7
              Wow! This is VERY KIND of you.
              It is one thing to take the time to make something like this, and a whole lot more when to try to share this( a lot more effort, time, and documentation).

              It will be helpful to many, and one day, hopefully, I'll be able to use this 8p
              Tom
              baby steps...starting again with HS3
              HS3Pro: Z-NET & 80 Z wave Devices,
              HSTouch: 4 Joggler (Android Kitkat), 2 iPhone, 3 iPads
              Whole House Audio: 5 SqueezePlay Jogglers w Bose Speakers
              In The Works: 10 Cameras Geovision, new Adecmo/Envisalink Alarm, Arduinos
              System: XP on Fanless Mini-ITX w/ SSD

              Comment


              • #8
                Sweet! Thanks.
                Don

                Comment


                • #9
                  Thank you very much!

                  my vb coding is whatever google tells me

                  so you are saying switch to C#

                  is C# hard to learn? so I guess Ill have to "Google" C# tutorials and get my hands wet. I would love to be able to do stuff like this!
                  HW - i5 4570T @2.9ghz runs @11w | 8gb ram | 128gb ssd OS - Win10 x64

                  HS - HS3 Pro Edition 3.0.0.435

                  Plugins - BLRF 2.0.94.0 | Concord 4 3.1.13.10 | HSBuddy 3.9.605.5 | HSTouch Server 3.0.0.68 | RFXCOM 30.0.0.36 | X10 3.0.0.36 | Z-Wave 3.0.1.190

                  Hardware - EdgePort/4 DB9 Serial | RFXCOM 433MHz USB Transceiver | Superbus 2000 for Concord 4 | TI103 X-10 Interface | WGL Designs W800 RF | Z-Net Z-Wave Interface

                  Comment


                  • #10
                    Thanks!
                    DSteiNeuro

                    HS3Pro

                    MSI Cubi Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz, 2201 Mhz, 2 Core(s), 4 Logical Processor(s) 16GB DDRl RAM

                    Enabled Plug-Ins
                    BLRussound, BLSpeech, HSTouch Server, JowiHue, MyQ, Nest, Rain8, Squeezebox, Ultra1Wire3, UltraGCIR3, Vista Alarm, X10,Z-Wave

                    Comment


                    • #11
                      Originally posted by TomTom View Post
                      Wow! This is VERY KIND of you.
                      It is one thing to take the time to make something like this, and a whole lot more when to try to share this( a lot more effort, time, and documentation).

                      It will be helpful to many, and one day, hopefully, I'll be able to use this 8p
                      Originally posted by donstephens View Post
                      Sweet! Thanks.
                      Originally posted by DSteiNeuro View Post
                      Thanks!
                      You are all very welcome! Please report any problems and give me feedback.


                      Originally posted by TeleFragger View Post
                      Thank you very much!

                      my vb coding is whatever google tells me

                      so you are saying switch to C#

                      is C# hard to learn? so I guess Ill have to "Google" C# tutorials and get my hands wet. I would love to be able to do stuff like this!
                      If you are currently learning VB.net, then learn that first. If you use vb.net or C# is just a matter of habbit, do not let anyone tell you something else.

                      I've used VB for 15 over 15 years, so I'm still a better and faster coder in VB.net. The "professionals" don't like it, apparently it has too much text. But I like to program without thinking about the code, I want to keep my head on the actual problem (after all, I'm an engineer, MSc). "Dim counter as Integer" is easier to read than "int counter", especially when the expressions are longer (which most of them are!).

                      However, if you haven't started, you could just as well start with C#. C# has some nice little touches which aren't as well implemented in VB.net, like lambda expressions. In that case, it's actually the other way around: C# is easier to understand than VB.net.
                      And I guess that for professional programmes, the language doesn't really matter, so they prefer typing speed over readability. "Dim counter as Integer" is a much longer expression than "int counter" to type, so that's an immediate increase in productivity.


                      What matters most is how you use the .NET framework and all it's various libraries, and how you structure your code.



                      .... but that's just my $0.02.
                      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


                      • #12
                        Originally posted by Moskus View Post

                        If you are currently learning VB.net, then learn that first.


                        What matters most is how you use the .NET framework and all it's various libraries, and how you structure your code.



                        .... but that's just my $0.02.
                        I havent started learning ANYTHING yet... when I said VB I should of clarified VBScript for my job functions (I support 4000 laboratory computers and I specialize in Symantec Management Platform 7.5 SP1 and going to 7.6 HF5 soon)
                        HW - i5 4570T @2.9ghz runs @11w | 8gb ram | 128gb ssd OS - Win10 x64

                        HS - HS3 Pro Edition 3.0.0.435

                        Plugins - BLRF 2.0.94.0 | Concord 4 3.1.13.10 | HSBuddy 3.9.605.5 | HSTouch Server 3.0.0.68 | RFXCOM 30.0.0.36 | X10 3.0.0.36 | Z-Wave 3.0.1.190

                        Hardware - EdgePort/4 DB9 Serial | RFXCOM 433MHz USB Transceiver | Superbus 2000 for Concord 4 | TI103 X-10 Interface | WGL Designs W800 RF | Z-Net Z-Wave Interface

                        Comment


                        • #13
                          This is awesome. Great work!

                          Comment


                          • #14
                            Originally posted by TeleFragger View Post
                            I havent started learning ANYTHING yet... when I said VB I should of clarified VBScript for my job functions (I support 4000 laboratory computers and I specialize in Symantec Management Platform 7.5 SP1 and going to 7.6 HF5 soon)
                            VBscript is closer to VB.net than C#...
                            ... and I don't really know what Symantec Management Platform is.

                            Originally posted by Jingoro View Post
                            This is awesome. Great work!
                            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


                            • #15
                              Hi Moskus, this is one of the best initiatives that have been made in the forum. Let's hope we get more interesting plugins from new developers. Great work.
                              Please excuse any spelling and grammatical errors I may make.
                              --
                              Tasker Plugin / Speech Droid
                              Tonlof | Sweden

                              Comment

                              Working...
                              X