Announcement

Collapse
No announcement yet.

Interfacing with HSPI_APRILAIRE from plugin

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

    Interfacing with HSPI_APRILAIRE from plugin

    I am looking for someone who knows a bit about the Aprilaire plugin internals, specifically I would like to interface

    I have successfully used the following from ASP when using VisualBasic:
    Code:
    intCurTemp = hs.Plugin("Aprilaire Thermostats").GetTemp(1,1)
    but I am trying to include support for Aprilaire within my plugin that is coded in C#... Since I must include reference to the Aprilaire plugin, I cannot use the syntax above. The closest I have come is with the following code, but when I run it I only get "0" back as a response.

    Code:
    HSPI_APRILAIRE.Thermostat thermObj = new HSPI_APRILAIRE.Thermostat("Main", false);
    
    CurOper = thermObj.GetOperating(thermID).ToString();
    CurTemp = thermObj.GetTemp(thermID).ToString();
    ModeSet = thermObj.GetModeSet(thermID).ToString();
    ModeSet = thermObj.GetCurrentMode(thermID).ToString();
    CoolSet = thermObj.GetCoolSet(thermID).ToString();
    HeatSet = thermObj.GetHeatSet(thermID).ToString();
    FanSet = thermObj.GetFanMode(thermID).ToString();
    HoldSet = thermObj.GetHoldMode(thermID).ToString();
    I have also tried creating an object from HSPI_APRILAIRE.HSPI instead of HSPI_APRILAIRE.Thermostat, but the results were worse in that case. Can anyone help me interface with this plugin?

    #2
    Exception

    I should add that I did get an exception from HSPI_APRILAIRE when I used the HSPI_APRILAIRE.HSPI() class. I am assuming that HSPI is the class to use since that is how the plugin template I used is setup.

    Code:
    2/9/2014 9:52:03 AM  - IP Phone XML - Error: DrawThermostat(AprilAire): System.NullReferenceException: Object variable or With block variable not set.   at Microsoft.VisualBasic.CompilerServices.Symbols.Container..ctor(Object Instance)   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)   at HSPI_APRILAIRE.HSPI.Log(String Msg, LT type)   at HSPI_APRILAIRE.HSPI.GetOperating(Int32 Therm, Int32 Partition)   at HSPI_IPPHONEXML.clsDrawScreen.DrawThermostat(Bitmap b, String thermType, String thermDevice)
    Most notably, I see that processing is getting to the following method within the HSPI_APRILAIRE plugin:
    HSPI_APRILAIRE.HSPI.Log(String Msg, LT type)

    I have a feeling this is because I am trying to access one plugin functionality from another, and this may not be possible. If that is the case I may have to end up having my plugin make an http call to Homeseer web server to get the data, and it seems like there should be a better way.

    Comment


      #3
      Figured it out!

      Ok, with a little digging and continuing to experiment, I found a solution. For anyone who stumbles upon this that may be interested in accessing another plugin's methods from their own, the following 3 lines will allow you to do this:
      Code:
      Object thermObj = m_objApp.ifHSApp.Plugin("Aprilaire Thermostats");
      Type type = thermObj.GetType();
      CurOper = type.InvokeMember("GetOperating", System.Reflection.BindingFlags.InvokeMethod, null, thermObj, parameter).ToString();

      Comment

      Working...
      X