Announcement

Collapse
No announcement yet.

HS object is Nothing when plugin is called from ASPX page

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

    HS object is Nothing when plugin is called from ASPX page

    I'm in the middle of developing a plugin for Domation, a wireless system for controlling 12V LED strips, both white and RGB leds. Pretty cool stuff, and I want to make HomeSeer do cool stuff with this. I started with developing it for HS2, but have started HS3 development too.


    99% of the plugin is done. What is missing is a ASPX page to set up devices and its commands.

    After alot of swearing I discovered that when the plugin is called from the aspx page, the HS object in the plugin is Nothing! That makes my plugin fuctions crash of course, but they work fine when used in a script.


    How can that be? What am I missing?
    I have to fix this before I dare start debugging the HS3 version....
    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
    how do you call plugin from aspx page in hs3 ?

    Comment


      #3
      The same way, I gather. I will have to figure out the HS2 problem first before I start cursing over HS3.
      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


        #4
        I don't know if this will help, but here is the aspx code from an older plugin thet initializes the hs variable and plugin.

        Dim hs As Object
        Dim pi As HSPI_PLUGIN.HSPI

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Try
        hs = Context.Items("Content")
        pi = hs.Plugin("Sample Plugin")

        If Not IsPostBack Then
        LoadItems()
        End If
        Catch ex As Exception
        Response.Write("Error In Load: " & ex.Message)
        End Try
        End Sub
        Wade

        "I know nothing... nothing!"

        Comment


          #5
          Yes, that is exactly what I'm doing, and I'm able to use both the hs object and the hspi object like I should in the aspx page.

          The problem occurs when I try to use a hs object inside the plugin when I call it from the aspx page.

          In the HSPI class in the plugin I do the following:
          Code:
              Public Function CreateDevTest() As String
                  If IsNothing(hs) Then
                      Throw New Exception("Error!")
                  End If
          
                  Try
                      Domation.CreateDevice("Child 1 Green", "A3", 1, 2, True)
                      Return "Success!"
                  Catch ex As Exception
                      Return "Error: " & ex.Message '& "  --- InnerExpeption: " & ex.InnerException.Message
                  End Try
              End Function
          If I call that function (hs.Plugin("Domation").CreateDevTest) from a script it works OK. If I call it from an aspx page I get a "System.Exception: Error!" message, just like I should if the HS object is Nothing...

          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


            #6
            I think a plugin has to be set to Com Visible to be able to use the
            hs.Plugin function in one line.


            If the plugin is not com visible you have to use:
            Dim pObj As Object = Nothing
            pObj = hs.Plugin("My Favorite Plug-In")
            hs.WriteLog("Test","The Name is: " & pObj.Name())

            I ran into this when I wrote my Misc Plug-In. I couldn't call the public functions until I set the plugin to com visible.

            That was in HS2. I haven't gotten far enough along to test it in HS3.
            --
            Jeff Farmer
            HS 3, HSPhone
            My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
            Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

            Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

            Comment


              #7
              This is my guess:

              I'm assuming you've not initiated hs in the plugin when the plugin is instantiated? The hs variable in the aspx page, while pointing to the same place, is a different variable than the hs inside the plugin. Until it's set, it would come back as nothing.

              This is in the hspi.vb file:

              Public Sub RegisterCallback(ByRef frm As Object)
              Try
              callback = frm
              hs = frm.GetHSIface
              Catch ex As Exception
              End Try
              End Sub
              Wade

              "I know nothing... nothing!"

              Comment


                #8
                i have this in an hs2 webapplication communicating with hs:


                PHP Code:

                  Dim pi 
                As HSPI_JAN.HSPI
                        pi 
                hs.Plugin("JAN Plug-In"

                Comment


                  #9
                  Thank you all for for trying to help me out! I really appreciate it, I'm about to tear all my hair out.
                  However, I alread do everything you have suggested, so I am still lost.


                  Originally posted by CFGuy View Post
                  I think a plugin has to be set to Com Visible to be able to use the
                  hs.Plugin function in one line.

                  If the plugin is not com visible you have to use:
                  Dim pObj As Object = Nothing
                  pObj = hs.Plugin("My Favorite Plug-In")
                  hs.WriteLog("Test","The Name is: " & pObj.Name())

                  I ran into this when I wrote my Misc Plug-In. I couldn't call the public functions until I set the plugin to com visible.

                  That was in HS2. I haven't gotten far enough along to test it in HS3.
                  I have set the project to be COM visible in Visual Studio (under My Project -> Assembly Information -> Make assembly COM-visible), so I don't think that is the issue.

                  However, perhaps there are other COM options I need to explore?


                  Originally posted by Sgt. Shultz View Post
                  This is my guess:

                  I'm assuming you've not initiated hs in the plugin when the plugin is instantiated? The hs variable in the aspx page, while pointing to the same place, is a different variable than the hs inside the plugin. Until it's set, it would come back as nothing.

                  This is in the hspi.vb file:

                  Public Sub RegisterCallback(ByRef frm As Object)
                  Try
                  callback = frm
                  hs = frm.GetHSIface
                  Catch ex As Exception
                  End Try
                  End Sub
                  Thanks, I double checked this as well, but that's what I do inthe plugin. The plugin works great on its own and when controlled directly from a homeseer script (.vb file or one line script).

                  I find it strange that the plugin does not find the HS object when I call it from the aspx page. The aspx page is able to generate both the header and the footer, so it does have a HS object reference.
                  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


                    #10
                    Just adding my guesswork

                    Does this function require additional DLLs? Check the <hs root>\html\bin subdirectory and make sure that all DLLs that this function uses are in there.

                    Seem to remember having to change my installer to copy some DLLs that I was using (AODB or UPNP if I remember correct) or some function calls from an ASPX page were failing.

                    I see that HS copies the DLLs in there at start-up, maybe there is something missing. Don't think the scripting engine uses the ASP engine so believe they have a very different behavior.

                    Dirk

                    Comment


                      #11
                      in hs 2 you can reference your hspi via the dll , but how to reference an exe file as in hs3 ?

                      Comment


                        #12
                        I don't have any external DLLs, but I did check that HS copied the hspi dll to the \bin folder in the \html folder. And yes, that should be OK.


                        So I tried yet another approach: Adding the HS reference as a parameter to the function call. But no.


                        Originally posted by wetlip View Post
                        in hs 2 you can reference your hspi via the dll , but how to reference an exe file as in hs3 ?
                        Don't know yet. But that's a question for another thread.
                        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


                          #13
                          Ooookay, I think I found the error. HomeSeer works okay when run normally in Windows 8 (and 7), but for stuff like this to work:

                          You need to run HomeSeer AS AN ADMINISTRATOR!

                          And I still have to reference the HS object from the ASPX page to the Plugin functions!
                          This is not how it's supposed to be, I'm pretty sure about that!

                          *sigh*...
                          Last edited by Moskus; December 19, 2012, 04:44 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"!

                          Comment


                            #14
                            For HS3, I found it easier to just convert the aspx pages to a class and to use the jquery objects built into Homeseer.

                            Aspx pages tend to be a bit hoggish when it comes to a lower powered machine, such as the Hometrollers, so will run slower.

                            Aspx pages will run in Linux, but can be a bit buggy.

                            As you noted, aspx pages can encounter security issues with Homeseer.
                            Wade

                            "I know nothing... nothing!"

                            Comment


                              #15
                              Originally posted by Sgt. Shultz View Post
                              For HS3, I found it easier to just convert the aspx pages to a class and to use the jquery objects built into Homeseer.
                              Hi Wade,

                              any chance to post an example of how you do that? I use aspx pages quite a bit in HS2 and have my PI running under HS3 except for the aspx config/status pages.

                              Thanks

                              Dirk

                              Comment

                              Working...
                              X