Announcement

Collapse
No announcement yet.

Really simple C# sample plugin available here!

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

  • jmta16
    replied
    Sample

    Hey Axis - if you feel so inclined, a Hello World sample may be good

    Leave a comment:


  • aXis
    replied
    Awesome, it's really good to see people are getting some use out of it.

    I've just started my sixth plugin using this template. The plain input/status only ones were easy, the last one I did had some outputs which made it harder but still worked out OK.

    Leave a comment:


  • jmta16
    replied
    Thanks

    Thank you very much, I too have tried to rake through the documentation and samples to find the basics.

    I have taken the liberty of creating a template from your project. The template was built using Visual Studio 2015 Community and is for C#
    Attached Files

    Leave a comment:


  • aXis
    replied
    You're very welcome

    I wrote a new hardware plugin using this template over the weekend and also upgraded/refactored and old one, both are working well. I didn't have to make any changes to the template so I'm happy that it's about as simple as I can get it.

    Leave a comment:


  • heppfs
    replied
    Thanks for this, I'm currently building my first plugin and this has already been quite helpful!

    Leave a comment:


  • aXis
    replied
    Good pick up. I didnt think it was necessary but you're right, it will help beginners. I've repackaged the csproj and app.config files now, original link has been updated.

    Leave a comment:


  • beerygaz
    replied
    Axis, thanks for sharing. There's no .csproj file included so opening the .sln file throws an error. Nothing major, but a little confusing for beginners?

    Leave a comment:


  • Thrag
    replied
    Thanks for sharing this! I've been planning to turn my aspx page into an actual plug in and have been wondering if something like this existed. Going through the docs to try to just figure out where to begin has been a somewhat frustrating experience so far.

    Leave a comment:


  • aXis
    started a topic Really simple C# sample plugin available here!

    Really simple C# sample plugin available here!

    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
    Last edited by aXis; January 17th, 2016, 10:10 PM.
Working...
X