Announcement

Collapse
No announcement yet.

HS3 Plugin Samples

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

  • Originally posted by Moskus View Post
    Yeah, I'm not there yet. Do you have a simple break down?
    Nothing is simple with that HSPI_SAMPLE plugin

    I spent hours upon hours using debug/trace to follow what it was doing. When it came to subtriggers, I gave up on trying to emulate what they were doing and just used my own object.

    I can send you some code samples offline if you want. It may help, or it may just muddy the waters even more.
    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


    • Originally posted by kriz83 View Post
      Will it be C# or VB ?
      VB.net for now. I'm thinking of a C# sampe as I want to master that as well better than now, but at the moment I'm more comfortable with VB.net.

      rmasonjr, I'll get back to you when I'm totally confused...
      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


      • Originally posted by Moskus View Post
        You need:
        - Visual Studio (Express or Community can be used) with VB.net
        - The link to the SDK: http://homeseer.com/support/homeseer...DK/default.htm
        - A download of the samples in the first post
        - Some experience with scripting, and some grasp of devices and events and how they work. tenScripting is a good idea.
        - ALOT of free time

        ... or wait a week or two until I release the my even more simplified version.




        Yeah, I'm not there yet. Do you have a simple break down?
        What are you working on? Sounds interesting [emoji2]
        Certified installer for HomeSeer, Control4, KNX and Eaton/xComfort

        Comment


        • Originally posted by U5tabil View Post
          What are you working on? Sounds interesting [emoji2]
          Right now I'm taking the basic plugin sample and simplifies it a little more. I'm adding comments and renaming variables so that the code is easier to read, so that we stand a chance of understanding what's going on.

          I really admire HomeSeer for what they have done, and what they enable for plugin developers. The posiblilites are really endless!

          But the code structure of the samples are... uhm... unstructured in my opinion. I'm used to reading SDKs (for Steam, Fitbit, Universal apps for Windows 10, etc), and while the possiblities are many in HomeSeer, the sample code and the code base is also somewhat messy and confusing.

          Examples:
          Hungarian notation. It's now abandoned by everyone (except old VB coders) at least 10 years ago. Hungarian notation is when you put the string type in front of the variable, so that it's easier to get the variable you want and the idea is that it makes the code easier to read.

          That might well be before .NET, but now it's not a problem. Now the recommendation is that if you really have to include the variable type, then add it to the end of the name. So "strName" becomes "NameString".

          The main problem is when variables, especially global variables, changes types. This is not uncommon when you start coding. You create a variable called "strLocation" because it is the name of a location and it's a string. As you keep coding, you see that you are not only passing the location name around, but also the GPS location with latitude and longitude, so you create your own class to pass all of this information around:

          Code:
          Public Class Location
              Public Property Name As String
              Public Property Latitude As Double
              Public Property Longitude As Double
          End Class
          ... but you now are used to the variable name "strLocation" you keep using that, even if the variable is now an instance of the Location class, not a String.

          I've used Hungarian notation myself. And now when I have to update my old programs, I can see that even my own code, which I am very familiar with, is pretty darn hard to understand sometimes.


          Abbreviations. Again something from the "good, old days" before Visual Studio had proper IntelliSense (auto completion) and people coded in Notepad or whatnot. Typing long words was "a vaste of time".

          But that results in classes named such as strActTrigInfo that perpahs started out as a string holding Action and/or Trigger information? I have no idea.


          Commenting. Perhaps the most important part of any programming project. Escpecially when you are to show your work others. Like in a SDK!

          There's no magic way to make a fellow programmer understand how you think. You need to tell him/her. One way is to avoid abbreviations and don't use Hungarian notation, but comments are even more important.

          The sample projects have almost no comments!

          Some statistics:
          - The main sample has 596 lines containing comment marks ( ' ).
          - The basic sample has 150 lines containing comment marks.
          - My basic sample has 816 lines containing comment marks, and I'm not even done yet!

          I'm going through the basic sample line for line, adding comments from the SDK on the web directly and adding comments on my own so that I better understand what's going on.

          I understand commenting on a sample plugin is way down on HSTs priority list. I just wish they had done it when they were coding it, it would have made it so much easier to understand.

          I want to understand the SDK. That's why I do this. But I don't see why I shouldn't help others getting started with plugins as well. Ultrajones made a similar sample for HS2, and I wouldn't have gotten into plugins at all if it weren't for him. I'm just paying it forward.
          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


          • Great work Moskus! Looking forward to follow your progress on this.
            Certified installer for HomeSeer, Control4, KNX and Eaton/xComfort

            Comment


            • Going to keep an eye on this thread because eventually I want to write a plugin that allows users to configure my HSMetro UI from within HS. It'll basically adding a new screen to the UI that allows drag/drop reordering, device selection, and server-side xml writing. Nothing crazy, but a nicely documented plugin sample will be a HUGE help!

              Comment


              • What HST has been able to do with the platform is impressive, but the plugin samples are a giant pain, so I will be interested in seeing your plugin sample as well.

                Truth be told, I think some of the personal plugins I have done work, but I am not sure how lol!
                HS3 PRO, Win10, WeatherXML, HSTouch, Pushover, UltraGCIR, Heaps of Jon00 Plugins, Just sold and about to move so very slim system.

                Facebook | Twitter | Flickr | Google+ | Website | YouTube

                Comment


                • Well I'm kinda stuck again, maybe someone can point me in the right direction. When a user clicks on a device on or off button setioMulti is called. Rick talks about how a best practice would be to use plugextradata to store information pertinent to a device http://board.homeseer.com/showthread.php?t=161861

                  The problem is, if I understand it correctly, is that I should be able to save a plugextradata object along with the device as the device is being created, there can be one EDO object with multiple named and unnamed objects in each EDO. However when I get to the line " EDO.AddNamed("My Device data obj", obj)" in the code below it seems to short circuit device creation. So I create my first device, add a plugextradata object to it, but then the next device never gets created. What am I missing?

                  Code:
                   dv.Status_Support(hs) = True
                                      dv.UserNote(hs) = "This is for user notes " & dv.Version.ToString
                                      'hs.SetDeviceString(ref, "Not Set", False)  ' this will override the name/value pairs
                                      dv.Relationship(hs) = Enums.eRelationship.Parent_Root 'Public Property Relationship(ByVal hs As IHSApplication) As Enums.eRelationship = parent
                  
                                      'Accessing the Extra Data object to work with it...
                                      Dim EDO As HomeSeerAPI.clsPlugExtraData = Nothing
                                      EDO = dv.PlugExtraData_Get(hs)
                  
                                      If EDO IsNot Nothing Then
                                          Dim obj As Object = Nothing
                                          obj = EDO.GetNamed("My Device data obj")
                                          If obj IsNot Nothing Then
                                              Log("Plug-In Extra Data Object Retrieved = " & obj.ToString, LogType.LOG_TYPE_INFO)
                                          End If
                                      Else
                                          Dim obj As New MyDeviceData()
                                          obj.ActiveAmp = MyDeviceData.ActiveAmps.Amp1
                                          obj.mydevice = MyDeviceData.mydevices.Amp1
                                          obj.myDVref = ref.ToString
                                          EDO.AddNamed("My Device data obj", obj)
                                      End If
                                      'Setting the modified Extra Data object back to the device...
                                      dv.PlugExtraData_Set(hs) = EDO
                                      '** After calling ".._Set", call hs.SaveEventsDevices to force HomeSeer to save the device that was modified.
                                      hs.SaveEventsDevices()
                                  End If
                  
                                  ref = hs.NewDeviceRef("Zone 1")
                                  If ref > 0 Then
                                      MyDevice = ref
                                      dv = hs.GetDeviceByRef(ref)
                                      Dim disp(1) As String
                  If it ain't broke, don't fix it!

                  Comment


                  • I think you need to switch two lines, from this:
                    Code:
                    dv.PlugExtraData_Set(hs) = EDO
                    hs.SaveEventsDevices()
                    ... to this:
                    Code:
                    hs.SaveEventsDevices()
                    dv.PlugExtraData_Set(hs) = EDO
                    That's because when you pass the (hs) object on PlugExtraData_set, so you are working on the "live" hs object, and therefore you need to update the device and store it first.
                    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


                    • I can actually comment out both those lines and device creation still short circuits. It's not until I comment out "EDO.AddNamed("My Device data obj", obj)" will my devices all get created. I did just notice that I'm getting a null reference error in homeseer log, so I'm obviously not doing something right. Setting a break point at that line shows that all my obj data looks fine. Switching the two statements doesn't change the behavior.

                      Originally posted by Moskus View Post
                      I think you need to switch two lines, from this:
                      Code:
                      dv.PlugExtraData_Set(hs) = EDO
                      hs.SaveEventsDevices()
                      ... to this:
                      Code:
                      hs.SaveEventsDevices()
                      dv.PlugExtraData_Set(hs) = EDO
                      That's because when you pass the (hs) object on PlugExtraData_set, so you are working on the "live" hs object, and therefore you need to update the device and store it first.
                      If it ain't broke, don't fix it!

                      Comment


                      • So after some more reading and another look at the plugin sample and some experimentation I've come to the conclusion that the PlugExtraData object can only be fed simple base types such as strings and integers. You can not feed it an actual object, or an enum, or maybe even an array. There also appears a plugextradataV2 within intellisense, but that appears to be anybody's guess as to what it does.

                        Any ways, I'll work with the limitation and move on...
                        If it ain't broke, don't fix it!

                        Comment


                        • You can actually stuff your own object into PED, but Rick told me long ago that you could run into problems if your plugin isn't loaded if HS evaluates PED. Base types are safe to use, but not as useful.

                          Sent from my SCH-R970X using Tapatalk
                          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


                          • ... and the plugin samples are storing custom classes...

                            Did changing type solve your problem?
                            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


                            • Originally posted by happnatious1 View Post
                              So after some more reading and another look at the plugin sample and some experimentation I've come to the conclusion that the PlugExtraData object can only be fed simple base types such as strings and integers. You can not feed it an actual object, or an enum, or maybe even an array. There also appears a plugextradataV2 within intellisense, but that appears to be anybody's guess as to what it does.
                              I store arrays in PlugExtraData in a plugin that I wrote with good consistent success. It's a Virtual Thermostat plugin and I store all the schedules etc in the root device which makes it easy to retrieve and edit from a remote plugin. I found issues if the devices are on a linux installation and you try to access the PlugExtraData from a remote plugin on windows. The issue is if you store named objects, unnamed objects work ok cross platform. See http://forums.homeseer.com/showthrea...ghlight=plugin.

                              Steve

                              Comment


                              • I wish I was as organised as you. I found it a long learning curve working through the basic plugin samples to understand how things work when writing my own plugin. Whilst I cracked most of it, or at least the bits I needed, I suspect that when I start another plugin project after a few months gap I will have forgotten most of what I learnt

                                Your work will be very useful to us all.
                                Thanks,
                                Steve

                                Originally posted by Moskus View Post
                                Right now I'm taking the basic plugin sample and simplifies it a little more. I'm adding comments and renaming variables so that the code is easier to read, so that we stand a chance of understanding what's going on.

                                I really admire HomeSeer for what they have done, and what they enable for plugin developers. The posiblilites are really endless!

                                But the code structure of the samples are... uhm... unstructured in my opinion. I'm used to reading SDKs (for Steam, Fitbit, Universal apps for Windows 10, etc), and while the possiblities are many in HomeSeer, the sample code and the code base is also somewhat messy and confusing.

                                Examples:
                                Hungarian notation. It's now abandoned by everyone (except old VB coders) at least 10 years ago. Hungarian notation is when you put the string type in front of the variable, so that it's easier to get the variable you want and the idea is that it makes the code easier to read.

                                That might well be before .NET, but now it's not a problem. Now the recommendation is that if you really have to include the variable type, then add it to the end of the name. So "strName" becomes "NameString".

                                The main problem is when variables, especially global variables, changes types. This is not uncommon when you start coding. You create a variable called "strLocation" because it is the name of a location and it's a string. As you keep coding, you see that you are not only passing the location name around, but also the GPS location with latitude and longitude, so you create your own class to pass all of this information around:

                                Code:
                                Public Class Location
                                    Public Property Name As String
                                    Public Property Latitude As Double
                                    Public Property Longitude As Double
                                End Class
                                ... but you now are used to the variable name "strLocation" you keep using that, even if the variable is now an instance of the Location class, not a String.

                                I've used Hungarian notation myself. And now when I have to update my old programs, I can see that even my own code, which I am very familiar with, is pretty darn hard to understand sometimes.


                                Abbreviations. Again something from the "good, old days" before Visual Studio had proper IntelliSense (auto completion) and people coded in Notepad or whatnot. Typing long words was "a vaste of time".

                                But that results in classes named such as strActTrigInfo that perpahs started out as a string holding Action and/or Trigger information? I have no idea.


                                Commenting. Perhaps the most important part of any programming project. Escpecially when you are to show your work others. Like in a SDK!

                                There's no magic way to make a fellow programmer understand how you think. You need to tell him/her. One way is to avoid abbreviations and don't use Hungarian notation, but comments are even more important.

                                The sample projects have almost no comments!

                                Some statistics:
                                - The main sample has 596 lines containing comment marks ( ' ).
                                - The basic sample has 150 lines containing comment marks.
                                - My basic sample has 816 lines containing comment marks, and I'm not even done yet!

                                I'm going through the basic sample line for line, adding comments from the SDK on the web directly and adding comments on my own so that I better understand what's going on.

                                I understand commenting on a sample plugin is way down on HSTs priority list. I just wish they had done it when they were coding it, it would have made it so much easier to understand.

                                I want to understand the SDK. That's why I do this. But I don't see why I shouldn't help others getting started with plugins as well. Ultrajones made a similar sample for HS2, and I wouldn't have gotten into plugins at all if it weren't for him. I'm just paying it forward.

                                Comment

                                Working...
                                X