www.homeseer.com    
 

Go Back   HomeSeer Message Board > Developer Support > Programming & Plug-in Development > Plug-In Development

Plug-In Development Discussions related to development new HomeSeer plug-ins.

Reply
 
Thread Tools Display Modes
  #1  
Old October 20th, 2015, 07:19 AM
Moskus's Avatar
Moskus Moskus is offline
OverSeer
 
Join Date: Aug 2007
Location: Norway
Posts: 3,782
HSPI_MoskusSample - An easier plugin sample [VB.NET]

The wait is finally over!
I'm releasing my simple basic plugin sample, so that others can get started with writing plugins and (hopefully) contribute to the sample. I'll be adding elements as I get to them writing my own plugins.

The plugin is based on the samples from HomeSeer Tech, but I've added comments from the SDK and online help (and links to it so that it's easier accessible), I've renamed many variables to make them more compliant with newer naming conventions and make them easier to read and understand what's really going on (I am of course not able to rename classes from HS3, so there's a few strange things like "strTrigActInfo" which is not a string at all). I've also added a few elements to make coding easier (like a custom Settings class and functions to handle Linq on Devices and Events).

The samples and APIs from HomeSeer are really totally awesome! The versatility and integration is quite unique, and that leaves endless possibilities. It's just that I found the samples from HST somewhat confusing to understand, and as there are virtually no comments, it was rather hard to get going. I figured the time I spent on understanding the sample could be put to good use, so that others will save some time.

I've stared a simple FAQ below.
Q: "What does this plugin do?"
A: Nothing very useful, it just does "something" to get you started. Heres a quick summary:
1. It generates a random value every X minutes or seconds (this Is user changeable by a settings page). This is used to show how triggers and conditions work. See the region "Trigger Interface".

2. It generates different types of devices, just to show how that could be done and how the plugin reacts to usage of the different controls (CAPI). See the sub "CheckAndCreateDevices".

3. It shows how text, values and even custom objects can be stored in a device, and how you create your own "Tab" on the device settings. See subs "ConfigDevice" and "ConfigDevicePost".

4. It has a simple settings page that demonstrate how you can update settings for your plugin.


Q: "What do I need?"
A: You need Visual Studio (Visual Studio Community Edition should work just fine), HomeSeer 3 running either locally or on a remote computer, some spare time (the more, the better), and an appetite for coding.


Q: "Where do I start?"
A: 1. Copy "HomeSeerAPI.dll", "HSCF.dll" and "Scheduler.dll" from your HS3 dir to into the dir of this project (extract the zip file first, of course).
2. Just start HS3 if its not running, and hit Debug in Visual Studio. Then youll see whats going on
3. Do some customization, I suggest start by naming your plugin. this is done several places:
a. In "utils.vb", see variables "IFACE_NAME" and "INIFILE".
b. See in "My Project" in the Solution, and change both
c. If you, like me, dont want the solution and project named "MoskusSample" you can edit the .vbproj and .sln files in notepad (but close Visual Studio first).
4. Then look into the "Plugin.vb" file. A good place like any other is to start by finding the sub "InitIO", whats where the plugin is initialized.
5. However, if you REALLY want to dive right in to it, find the "UpdateTimerTrigger" sub and read to the end.


Here's a screenshot of the devices the plugin creates:


The sample demonstrates a few different methods for creating devices and how to handle input and output of data.


Here's a screenshot of Event triggers and actions:


The sample has two Triggers. One without subtriggers and one with. Both can be used as a condition. See Enums "TriggerTypes" and "SubTriggerTypes" which I've added to make "(int) TrigInfo.TANumber" and "(int) TrigInfo.SubTANumber" more understandable.

I've just added one action, but most of the same logic applies also applies to actions.


This sample doesn't magically make writing plugins super easy. It still requires some time to understand how it is pieced together. But hopefully it will get you started.

If you know what you are doing and have comments of what I can do better, then please feel free to let me know. Share code if you can.


What is missing at the moment:
  • Public plugin functions
  • Public property get/set
  • Proper documentation for web page building (I'm not done yet)

And last:
If you want, you can always "tip" me via Paypal to "moskus a_t gmail d_o_t com" (where "a_t" = "@" and "d_o_t" = "."). It is not expected or required, but highly appreciated.


Download in the next post.


I've written a basic "Getting Started" post here.
__________________
HSPro 3.0.0.435, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
Running on Windows 10 (64) virtualized
on ESXi (Fujitsu Primergy TX150 S8).
WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

Last edited by Moskus; December 18th, 2015 at 05:06 AM.
Reply With Quote
  #2  
Old October 20th, 2015, 07:21 AM
Moskus's Avatar
Moskus Moskus is offline
OverSeer
 
Join Date: Aug 2007
Location: Norway
Posts: 3,782
Here's the download.

Changelog:
1.0.0: Initial release.
Attached Files
File Type: zip HSPI_MoskusSample 1.0.0.zip (47.7 KB, 451 views)
Reply With Quote
  #3  
Old October 20th, 2015, 07:23 AM
MrMxyzptlk MrMxyzptlk is offline
Seer Deluxe
 
Join Date: Aug 2015
Location: Peachtree City, GA
Posts: 478
Excellent work!
Reply With Quote
  #4  
Old October 20th, 2015, 07:40 AM
Moskus's Avatar
Moskus Moskus is offline
OverSeer
 
Join Date: Aug 2007
Location: Norway
Posts: 3,782
Thanks!
Reply With Quote
  #5  
Old October 20th, 2015, 08:21 AM
kriz83 kriz83 is offline
Seer Deluxe
 
Join Date: Oct 2012
Location: Belgium
Posts: 445
Many thanks !
I wish something like this in C# will be available too ...
Reply With Quote
  #6  
Old October 20th, 2015, 08:23 AM
Moskus's Avatar
Moskus Moskus is offline
OverSeer
 
Join Date: Aug 2007
Location: Norway
Posts: 3,782
I'm thinking about converting it to C#. But I thougt I'd release the VB-version first.
(I'm actually a faster coder in VB than C#, but I'm getting more and more used to C# too.)
Reply With Quote
  #7  
Old October 20th, 2015, 08:29 AM
TomTom's Avatar
TomTom TomTom is offline
Seer Master
 
Join Date: Apr 2012
Location: USA
Posts: 1,402
Wow! This is VERY KIND of you.
It is one thing to take the time to make something like this, and a whole lot more when to try to share this( a lot more effort, time, and documentation).

It will be helpful to many, and one day, hopefully, I'll be able to use this 8p
__________________
Tom
baby steps...starting again with HS3
HS3Pro: Z-NET & 80 Z wave Devices,
HSTouch: 4 Joggler (Android Kitkat), 2 iPhone, 3 iPads
Whole House Audio: 5 SqueezePlay Jogglers w Bose Speakers
In The Works: 10 Cameras Geovision, new Adecmo/Envisalink Alarm, Arduinos
System: XP on Fanless Mini-ITX w/ SSD
Reply With Quote
  #8  
Old October 20th, 2015, 09:50 AM
donstephens's Avatar
donstephens donstephens is offline
OverSeer
 
Join Date: Dec 2001
Location: Hamilton, MT
Posts: 2,724
Sweet! Thanks.
__________________
Don
Reply With Quote
  #9  
Old October 20th, 2015, 10:00 AM
TeleFragger's Avatar
TeleFragger TeleFragger is offline
OverSeer
 
Join Date: Jun 2004
Location: Williamstown, NJ
Posts: 4,771
Thank you very much!

my vb coding is whatever google tells me

so you are saying switch to C#

is C# hard to learn? so I guess Ill have to "Google" C# tutorials and get my hands wet. I would love to be able to do stuff like this!
__________________
HW - i5 4570T @2.9ghz runs @11w | 8gb ram | 128gb ssd OS - Win10 x64

HS - HS3 Pro Edition 3.0.0.368

Plugins - BLLAN 2.0.38.0 | BLRF 2.0.93.0 | Concord 4 3.1.13.8 | HSTouch Server 3.0.0.68 | RFXCOM 30.0.0.36 | X10 3.0.0.36 | Z-Wave 3.0.1.150

Hardware - EdgePort/4 DB9 Serial | RFXCOM 433MHz USB Transceiver | Superbus 2000 for Concord 4 | TI103 X-10 Interface | WGL Designs W800 RF | Z-Net Z-Wave Interface
Reply With Quote
  #10  
Old October 20th, 2015, 10:00 AM
DSteiNeuro DSteiNeuro is offline
Seer Master
 
Join Date: Jan 2001
Location: Audrey Land (Somewhere near San Diego CA USA)
Posts: 755
Thanks!
Reply With Quote
  #11  
Old October 20th, 2015, 02:31 PM
Moskus's Avatar
Moskus Moskus is offline
OverSeer
 
Join Date: Aug 2007
Location: Norway
Posts: 3,782
Quote:
Originally Posted by TomTom View Post
Wow! This is VERY KIND of you.
It is one thing to take the time to make something like this, and a whole lot more when to try to share this( a lot more effort, time, and documentation).

It will be helpful to many, and one day, hopefully, I'll be able to use this 8p
Quote:
Originally Posted by donstephens View Post
Sweet! Thanks.
Quote:
Originally Posted by DSteiNeuro View Post
Thanks!
You are all very welcome! Please report any problems and give me feedback.


Quote:
Originally Posted by TeleFragger View Post
Thank you very much!

my vb coding is whatever google tells me

so you are saying switch to C#

is C# hard to learn? so I guess Ill have to "Google" C# tutorials and get my hands wet. I would love to be able to do stuff like this!
If you are currently learning VB.net, then learn that first. If you use vb.net or C# is just a matter of habbit, do not let anyone tell you something else.

I've used VB for 15 over 15 years, so I'm still a better and faster coder in VB.net. The "professionals" don't like it, apparently it has too much text. But I like to program without thinking about the code, I want to keep my head on the actual problem (after all, I'm an engineer, MSc). "Dim counter as Integer" is easier to read than "int counter", especially when the expressions are longer (which most of them are!).

However, if you haven't started, you could just as well start with C#. C# has some nice little touches which aren't as well implemented in VB.net, like lambda expressions. In that case, it's actually the other way around: C# is easier to understand than VB.net.
And I guess that for professional programmes, the language doesn't really matter, so they prefer typing speed over readability. "Dim counter as Integer" is a much longer expression than "int counter" to type, so that's an immediate increase in productivity.


What matters most is how you use the .NET framework and all it's various libraries, and how you structure your code.



.... but that's just my $0.02.
Reply With Quote
  #12  
Old October 20th, 2015, 02:43 PM
TeleFragger's Avatar
TeleFragger TeleFragger is offline
OverSeer
 
Join Date: Jun 2004
Location: Williamstown, NJ
Posts: 4,771
Quote:
Originally Posted by Moskus View Post

If you are currently learning VB.net, then learn that first.


What matters most is how you use the .NET framework and all it's various libraries, and how you structure your code.



.... but that's just my $0.02.
I havent started learning ANYTHING yet... when I said VB I should of clarified VBScript for my job functions (I support 4000 laboratory computers and I specialize in Symantec Management Platform 7.5 SP1 and going to 7.6 HF5 soon)
Reply With Quote
  #13  
Old October 20th, 2015, 03:45 PM
Jingoro Jingoro is offline
Seer Deluxe
 
Join Date: Jan 2004
Location: United States
Posts: 166
This is awesome. Great work!
Reply With Quote
  #14  
Old October 21st, 2015, 10:40 AM
Moskus's Avatar
Moskus Moskus is offline
OverSeer
 
Join Date: Aug 2007
Location: Norway
Posts: 3,782
Quote:
Originally Posted by TeleFragger View Post
I havent started learning ANYTHING yet... when I said VB I should of clarified VBScript for my job functions (I support 4000 laboratory computers and I specialize in Symantec Management Platform 7.5 SP1 and going to 7.6 HF5 soon)
VBscript is closer to VB.net than C#...
... and I don't really know what Symantec Management Platform is.

Quote:
Originally Posted by Jingoro View Post
This is awesome. Great work!
Thanks!
Reply With Quote
  #15  
Old October 21st, 2015, 02:21 PM
tonlof's Avatar
tonlof tonlof is offline
Seer Master
 
Join Date: Apr 2001
Location: Nordic
Posts: 1,464
Thumbs up

Hi Moskus, this is one of the best initiatives that have been made in the forum. Let's hope we get more interesting plugins from new developers. Great work.
__________________
Please excuse any spelling and grammatical errors I may make.
--
Tasker Plugin / Speech Droid
Tonlof | Sweden
Reply With Quote
  #16  
Old October 21st, 2015, 03:31 PM
TeleFragger's Avatar
TeleFragger TeleFragger is offline
OverSeer
 
Join Date: Jun 2004
Location: Williamstown, NJ
Posts: 4,771
Quote:
Originally Posted by tonlof View Post
Hi Moskus, this is one of the best initiatives that have been made in the forum. Let's hope we get more interesting plugins from new developers. Great work.
im on
Introduction for the really challenged C# users... but we WILL get you there course
Reply With Quote
  #17  
Old October 22nd, 2015, 02:25 AM
beerygaz's Avatar
beerygaz beerygaz is offline
Super Seer
 
Join Date: Mar 2006
Location: Johannesburg, South Africa
Posts: 1,658
Great work Moskus. My two most frustrating aspect after getting my head around the architecture, are:

1. Parsing query strings in PostBacks from the config, trigger and action pages, hardcoding the text names of controls seems messy

2. Building those pages with complex config pages / multiple controls. Adding endless lines of manually coded HTML seems so frustrating when there are so many good HTML editors out there.

Any thoughts on trying to abstract some of these painful process in a class wrapper to make life easier?
Reply With Quote
  #18  
Old October 22nd, 2015, 07:41 AM
Moskus's Avatar
Moskus Moskus is offline
OverSeer
 
Join Date: Aug 2007
Location: Norway
Posts: 3,782
Quote:
Originally Posted by beerygaz View Post
Great work Moskus. My two most frustrating aspect after getting my head around the architecture, are:

1. Parsing query strings in PostBacks from the config, trigger and action pages, hardcoding the text names of controls seems messy

2. Building those pages with complex config pages / multiple controls. Adding endless lines of manually coded HTML seems so frustrating when there are so many good HTML editors out there.

Any thoughts on trying to abstract some of these painful process in a class wrapper to make life easier?
1. I'm not sure how you'll get around the need to name your controls. Or maybe I'm not getting what you're asking.

2. After I've gotten used to the way HS3 handles these pages, it does make sense. Yes, there is some quite good WYSIWYG editors out there, but they can't handle controls like this. Even Visual Studio or Blend does not handle jQueries like this do.

And remember: That is an option. If you want to build your pages in asp.net you still can!
Reply With Quote
  #19  
Old October 22nd, 2015, 07:42 AM
Moskus's Avatar
Moskus Moskus is offline
OverSeer
 
Join Date: Aug 2007
Location: Norway
Posts: 3,782
Quote:
Originally Posted by tonlof View Post
Hi Moskus, this is one of the best initiatives that have been made in the forum. Let's hope we get more interesting plugins from new developers. Great work.
That's the idea! Thanks for the support.
Reply With Quote
  #20  
Old October 22nd, 2015, 08:43 AM
happnatious1's Avatar
happnatious1 happnatious1 is offline
Seer Master
 
Join Date: Mar 2004
Location: Southern Maryland
Posts: 1,285
Quote:
Originally Posted by beerygaz View Post
Great work Moskus. My two most frustrating aspect after getting my head around the architecture, are:

1. Parsing query strings in PostBacks from the config, trigger and action pages, hardcoding the text names of controls seems messy

2. Building those pages with complex config pages / multiple controls. Adding endless lines of manually coded HTML seems so frustrating when there are so many good HTML editors out there.

Any thoughts on trying to abstract some of these painful process in a class wrapper to make life easier?
For 1. I found that loading everything from control names to config settings into PED and then assigning them to variables when the plugin starts made a lot of sense.

For 2. I just struggled along until I got things functional (but it looks like cat vomit) So anything that can be helpful in building JQuery pages would be great.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
why is plugin name not showing up in the basic plugin sample wetlip HS3 Plug-In Development 2 July 14th, 2013 04:37 PM
VB .Net plugin sample Blade HS2 / HSPRO 29 January 16th, 2006 01:16 AM


All times are GMT -4. The time now is 11:50 PM.


Copyright HomeSeer Technologies, LLC