Announcement

Collapse
No announcement yet.

Plugin and RegisterEventCB issues

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

  • Plugin and RegisterEventCB issues

    I have a plugin that runs remotely and will run and then terminate throughout the day, sometimes only minutes apart (by design).

    In the InitIO sub, I have the following:

    Code:
     ''
            '' Register for HS Events
            ''
            callback.RegisterEventCB(Enums.HSEvent.VALUE_CHANGE, IFACE_NAME, "")
            callback.RegisterEventCB(Enums.HSEvent.LOG, IFACE_NAME, "")
            callback.RegisterEventCB(Enums.HSEvent.STRING_CHANGE, IFACE_NAME, "")
    In HS2, I called RegisterEventCB once with the three requested events ORed together. Could not make this work, but calling RegisterEventCB three separate times does seem to work. Is this the way it is working for others, and is this correct? Seems to work ok for me, just unexpected.

    Now, my real problem is that there is no way that I have uncovered to unregister for these events. I have not been able to determine a way to terminate execution of my plugin without the HsEvents sub being called after I have shut down the plugin, resulting in a bad object reference.

    I disconnect both client and clientcallback objects, wait for their connection status to become disconnected, and after that, my HsEvents routine gets called still (at least, that what seems to be happening).

    While this results in an error in the log, that I guess I could ignore, the larger problem is that when the plugin is started again, the RegisterEvendCB calls don't always result in HsEvent calls. All of this is somewhat random. Sometimes works fine, other times not.

    Any thoughts would be appreciated.

    tenholde
    tenholde

  • #2
    Hitting exactly this same issue. Did you resolve it?
    The only way I can reregister for callback events after exiting my plugin is to restart Homeseer!

    There must be some other way around this. Until I found your post I was going round in circles trying to find out what I was doing wrong.

    s.

    Comment


    • #3
      I have not found a solution.

      tenholde
      tenholde

      Comment


      • #4
        Originally posted by tenholde View Post
        I have not found a solution.

        tenholde
        So -- how do you handle the same issue in your excellent tenscripting plugin?
        It gets started and stopped all the time, but i never have to restart HS3 and I still see all the events?

        s.

        Comment


        • #5
          Small update...

          1. I started my *remote* plugin. Observed events correctly being received. Shutdown the plugin.

          2. I restarted the plugin, RegisterEventCB executes without errors. No events received.

          3. I shut down my plugin and left it for a few hours. Repeated #2. Events started flowing again.

          So it appears HS3 has some garbage collection processes that flush unattached CallBacks every so often. The question is (a) what periodicity and (b) how to trigger it.

          Is your experience only with remote plugins or local or both?

          s.

          Comment


          • #6
            I have the same experience. After a while, I can restart the plugin and the Events will flow again.

            Do you get an object reference not exist for the Event routine when you stop the plugin (in the log)?

            tenholde
            tenholde

            Comment


            • #7
              Originally posted by skavan View Post
              So -- how do you handle the same issue in your excellent tenscripting plugin?
              It gets started and stopped all the time, but i never have to restart HS3 and I still see all the events?

              s.
              It is tenScripting that is creating the problem for me. If I rerun it without a long delay, I do not get HsEvents

              tenholde
              tenholde

              Comment

              Working...
              X