Announcement

Collapse
No announcement yet.

External Device Support

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

    External Device Support

    Mark,

    I have a plugin that I want to use to support an external device instead of a script. Should that be possible? I struggle with two parts of this.

    Firstly it seems that the syntax for providing the external receive data function expect a script name and function. If there is a way to provide these values so that it is a plugin, I have not been able to figure it out. What I have done for the moment is to provide a script that just forwards the data to the plugin. I don't really like having this script be there.

    Even with that script, I still assumed that I could register the script from within my plugin. It doesn't seem like it takes effect. I have coded another script function to only call my plugin to register when the scripts register function gets called. I assume there must be some kind of timing issue. Perhaps the insteon plugin needs to be in a certain state before it can take an external registration. I tried looking for the insteons plugins InterfaceStatus to go to 0 before sending the registration, but this didn't seem to help.
    - Tom

    HSPro/Insteon
    Web Site
    YouTube Channel

    #2
    Within your plugin you should use .net serial communications stuff instead of Homeseer's.

    tenholde
    tenholde

    Comment


      #3
      Originally posted by tpchristian View Post
      Mark,

      I have a plugin that I want to use to support an external device instead of a script. Should that be possible? I struggle with two parts of this.

      Firstly it seems that the syntax for providing the external receive data function expect a script name and function. If there is a way to provide these values so that it is a plugin, I have not been able to figure it out. What I have done for the moment is to provide a script that just forwards the data to the plugin. I don't really like having this script be there.

      Even with that script, I still assumed that I could register the script from within my plugin. It doesn't seem like it takes effect. I have coded another script function to only call my plugin to register when the scripts register function gets called. I assume there must be some kind of timing issue. Perhaps the insteon plugin needs to be in a certain state before it can take an external registration. I tried looking for the insteons plugins InterfaceStatus to go to 0 before sending the registration, but this didn't seem to help.
      Tom,

      A plug-in for a plug-in! Nice. I have thought about and discussed this with others but for right now this isn't going to work as the plugin is designed. We would need to develop an interface and callback system between the two plugins; this is not something I'm prepared to do right now.

      the reason the .vb script works is because my plugin uses the hs.RunEx which expects a physical .vb file. RunEx will not run a method within a plugin. Remember this is an hs method so there are limitations with its use.

      The InterfaceStatus property is rather basic - it only reports the status of the "serial interface" not the status of the plugin.

      I would use HS.AppStarting(True) in your code to get it to wait until everything is initialized. Once the hs scripting engine is initialized, the ext scripts get initialized.

      I could add an public method to let you know when the plugin is completely initialized if that would help with the timing, but my guess is that is not really the problem.
      Mark

      HS3 Pro 4.2.19.5
      Hardware: Insteon Serial PLM | AD2USB for Vista Alarm | HAI Omnistat2 | 1-Wire HA7E | RFXrec433 | Dahua Cameras | LiftMaster Internet Gateway | Tuya Smart Plugs
      Plugins: Insteon (mine) | Vista Alarm (mine) | Omnistat 3 | Ultra1Wire3 | RFXCOM | HS MyQ | BLRadar | BLDenon | Tuya | Jon00 Charting | Jon00 Links
      Platform: Windows Server 2022 Standard, i5-12600K/3.7GHz/10 core, 16GB RAM, 500GB SSD

      Comment


        #4
        Thanks for the thought, Mark. I will work with a helper function receive function for now. I will also play around some more to see if I can get the timing worked out for the register.

        I kind of suspected that you were using RunEx. What I didn't know if there was some special use of it to run on of the parameters as a script line instead of a function in an external script file. I thought there might be because this can be done, for instance, when you are defining script actions. However, this could, and likely is, being done with a different technique. Perhaps the application doesn't expose a method to run this script line like can be done in actions. I will ask more about this in the development forum. I think that a callback would be the best alternative. However, I don't think that a custom callback mechanism would be needed since HS already has a generic event callback. Here is my thought. In the receive function, if both the receive and function name are blank, it indicates that a generic callback should be used. Such that your code would look like this...

        Code:
        If scriptName == "" and funcName == "" Then
            Dim parms() as String
            parms(0) = address
            parms(1) = receivedData
            hs.RaiseGenericEventCB("InsteonRcv", parms, "Insteon Plugin")
        Else
            hs.RunEx(scriptName, funcName, receivedData, false)
        End If
        I understand that you have other priorities and, like said, will use a helper script for now.
        - Tom

        HSPro/Insteon
        Web Site
        YouTube Channel

        Comment

        Working...
        X