Announcement

Collapse
No announcement yet.

HSPI_MoskusSample - An easier plugin sample [VB.NET]

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

    #31
    I got started last week, but then was out of town for the weekend. I can definitely see how a flowsheet would help in understanding how everything ties together. . .I only got a quick glance as the plugin.vb (I think it was). . .need a more thorough read. I have done basic coding in many different languages, but mostly scripting recently (Kixstart, php, perl, ahk). And VB definitely has a much different syntax.

    Comment


      #32
      Great Project!

      This is a great learning tool!

      Is there one of the examples that allows you to attach parameters to an online URL and get information returned - much like Textseer does?



      Thanks!

      Comment


        #33
        You're right! That is missing!

        I can add this but it will be a while, I'll write it down so I don't forget.
        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


          #34
          Great!

          Up until an hour ago, I thought that was my biggest problem. Then I discovered we have raccoons in the attic.

          So my priorities have shifted.

          But I'll still find time to enjoy the script training.

          Thanks!

          Comment


            #35
            I'm just starting off with Homeseer plugins, and I keep getting this error when I try to add a new device. Having the same problem in HSPI_SAMPLE_BASIC provided in the SDK support.
            Attached Files

            Comment


              #36
              Hmmm! That's weird! You shouldn't get to that place in the code, that bit is only "leftovers" from the original sample.

              I don't know which devices you are creating, but it seems that you have not set the device.Device_Type_String to anything other than "" or String.Empty.

              The subs CreateBasicDevice, CreateAdvancedDevice and CreateRootDevice all set this to the plugin name, a space char and "Basic", "Advanced" and "Root", like this:
              Code:
              device.Device_Type_String(hs) = Me.Name & " " & "Basic"

              The function ConfigDevice (where you hare having problems) is using .Device_Type_String to determine which device type you are handling at the moment, that's what the "Select Case" is doing (it removes the Me.Name (the plugin name) first).


              If you want a quick and dirty fix, you can add Return String.Empty after Select Case "", like this:


              .... but I would suggest that you rather try to understand what's going on. I'll try to help if I can!
              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


                #37
                Two points of clarity

                1. As a point of suggestion. I have replaced all references in your code from
                Code:
                device.Device_Type_String(hs) = Me.Name & "..."
                and replaced it with
                Code:
                PEDAdd(device.PlugExtraData_Get(hs), "C_Type", c_type)
                The reason for this is data assurance. Users can change the Device_Type which would then break your code. Using the PluginExtraData ensures users cannot access it to change the device type. I used the string C_Type for "Control Type". To speed this ability along I added an ENUM in the utils.vb for DeviceType so I can reference them in code more simply and also convert from integer to string when needed.

                2. This above method works in ALL areas except for one. The Function for ConfigDevice I call the PluginExtraData for the C_Type to render the page and it does not add the page to the control?

                Comment


                  #38
                  Originally posted by DNATechnologySolutions View Post
                  The reason for this is data assurance. Users can change the Device_Type which would then break your code. Using the PluginExtraData ensures users cannot access it to change the device type. I used the string C_Type for "Control Type". To speed this ability along I added an ENUM in the utils.vb for DeviceType so I can reference them in code more simply and also convert from integer to string when needed.
                  I don't recommend using the Device Type String for exactly that reason.

                  Instead I recommend using DeviceTypeInfo, as this cannot be easily overwritten.

                  Code:
                          Dim typeInfo As New DeviceTypeInfo
                          typeInfo.Device_Type = DeviceTypeInfo.eDeviceAPI.Plug_In
                          typeInfo.Device_API = DeviceTypeInfo.eDeviceAPI.Plug_In
                          typeInfo.Device_SubType = type 'an integer for me
                          typeInfo.Device_SubType_Description = type.ToString & ",IP=" & ip_address
                          device.DeviceType_Set(hs) = typeInfo
                  ... and it's much easier to get hold of as long as you can access the device Object.


                  Originally posted by DNATechnologySolutions View Post
                  2. This above method works in ALL areas except for one. The Function for ConfigDevice I call the PluginExtraData for the C_Type to render the page and it does not add the page to the control?
                  I'm not sure what you are asking ...
                  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


                    #39
                    I had started a separate thread for that specific issue in http://board.homeseer.com/showthread.php?t=185828

                    but in short, the built in PEDAdd util function (by HomeSeer) called in the DeviceConfig function isn't working.

                    I called this to add additional data right after creating the devices and I keep getting null errors.

                    Comment


                      #40
                      As far as your code for DeviceTypeInfo is there a way you have found to be able to query typeInfo.Device_SubType in you LinQ style searches?

                      Comment


                        #41
                        I FIGURED IT OUT MOSKUS

                        Solution found in http://forums.homeseer.com/showthread.php?t=173585 and after Tinkering

                        I Posted a More Detailed note on thread

                        Comment


                          #42
                          HUGE Thankyou to Moskus and Telholde, I was able to combine their samples into one example Serial script.

                          I am not the best coder and new to .net so happy for others to take and improve this. Much of the logging and code in there is to aid in testing so you'll want to streamline it for live use.

                          It's very basic (it's a sample), but has the following features:
                          1. Single serial port with send and receive logic
                          2. Port and Baud can be set in the config page
                          3. It handles disconnect and reconnect
                          4. It send a confirmation message to the serial port sender
                          5. Creates an additional device (Device Name is "UpdateMeFromSerial")
                          6. Device has two buttons that send data to the serial port
                          7. Any received data will appear on the Serial Device Status field
                          8. You can call the send function from a script to send data out the serial port
                          ie.
                          Code:
                          Public Sub Main(ByVal param As Object)
                          
                                  Const ScriptName = "Serial command"
                                  Try
                                      hs.WriteLog(ScriptName, "Sending to Serial port")
                                      hs.PluginFunction("TestSerial", "", "SendToSerialPort", New Object() { "some data to send to serial port goes here"})
                                  Catch ex As Exception
                                      hs.WriteLog(ScriptName, "Error C: " & ex.Message)
                                  End Try
                          
                              End Sub

                          Hope it helps others.
                          Attached Files
                          Last edited by davros; January 27, 2017, 06:34 AM.

                          Comment


                            #43
                            Cool!
                            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


                              #44
                              Yep. And on the back of this I have just completed by first plugin for my Arduino Mega Based IO Controller.

                              16 Relays contacts, 8 interupt driven opto-isolated Digital inputs (dry and active), 8 Analog opto isolated inputs. Very happy.
                              Relays can be set to timed events and it saves state. It's run via simple command like "11,2;" to set relay 2 to on, and returns state as "R2=1".

                              I even used PlugExtraData to store device info. which turns out to be very useful - and like many things HS, unecessarily complex and poorly documented.

                              Hey, does anyone have a TCPIP server Visual Studio VB.Net Solution/project they can share

                              Happy to reshape and publish as a TCP demo interface as per serial.

                              Sharing is caring
                              Last edited by davros; January 28, 2017, 08:36 PM.

                              Comment


                                #45
                                Just added basic TCPIP to the plugin Will share shortly.

                                https://forums.homeseer.com/showpost...2&postcount=12
                                Attached Files

                                Comment

                                Working...
                                X