Hi All
I'm probably not the only one here that has been struggling with how incomplete the HS3 plugin documentation is, and how convoluted the sample VB.Net plugins were. It took me months to get my head around what they were doing with multiple levels of indirection, multiple copies of core objects, and multiple static classes cross referencing each other.
Anyway, I've had a breakthrough and managed to make a very simple, barebones C# plugin that can launch and connect to the Homeseer HS3 server. 99% of the code is now in a single non-static class (perfect for multiple instances), with the bare minimum of code in the console wrapper required to launch it and wait for shutdown. It took me ages to figure out how to successfully connect to the Homeseer TCP API, but now that it works I've made it as straightforward and sensible as I can, with lots of code comments to explain what is going on.
The basic premise is:
1) All of your functional code goes into the plugin (HSPI) class that implements the IPlugInAPI interface
2) The console wrapper creates an instance of your plugin class, and calls a Connect method on your plugin
3) The plugin makes it's own private connection to Homeseer and sets up the bi-directional remote call functionality
4) The console wrapper sits in a sleep loop, periodically testing if the plugin has failed or needs to shut down.
Note that I haven't implemented any devices, actions, triggers, conditions or web pages, this is an empty shell ready for you to populate with your own code.
Current version (1.0.0.0) here: https://drive.google.com/open?id=0B3...Xl2OXhIb2ZxZVk
I'm probably not the only one here that has been struggling with how incomplete the HS3 plugin documentation is, and how convoluted the sample VB.Net plugins were. It took me months to get my head around what they were doing with multiple levels of indirection, multiple copies of core objects, and multiple static classes cross referencing each other.
Anyway, I've had a breakthrough and managed to make a very simple, barebones C# plugin that can launch and connect to the Homeseer HS3 server. 99% of the code is now in a single non-static class (perfect for multiple instances), with the bare minimum of code in the console wrapper required to launch it and wait for shutdown. It took me ages to figure out how to successfully connect to the Homeseer TCP API, but now that it works I've made it as straightforward and sensible as I can, with lots of code comments to explain what is going on.
The basic premise is:
1) All of your functional code goes into the plugin (HSPI) class that implements the IPlugInAPI interface
2) The console wrapper creates an instance of your plugin class, and calls a Connect method on your plugin
3) The plugin makes it's own private connection to Homeseer and sets up the bi-directional remote call functionality
4) The console wrapper sits in a sleep loop, periodically testing if the plugin has failed or needs to shut down.
Note that I haven't implemented any devices, actions, triggers, conditions or web pages, this is an empty shell ready for you to populate with your own code.
Current version (1.0.0.0) here: https://drive.google.com/open?id=0B3...Xl2OXhIb2ZxZVk
Comment