... and the plugin samples are storing custom classes...
Did changing type solve your problem?
Announcement
Collapse
No announcement yet.
HS3 Plugin Samples
Collapse
This is a sticky topic.
X
X
-
You can actually stuff your own object into PED, but Rick told me long ago that you could run into problems if your plugin isn't loaded if HS evaluates PED. Base types are safe to use, but not as useful.
Sent from my SCH-R970X using Tapatalk
Leave a comment:
-
So after some more reading and another look at the plugin sample and some experimentation I've come to the conclusion that the PlugExtraData object can only be fed simple base types such as strings and integers. You can not feed it an actual object, or an enum, or maybe even an array. There also appears a plugextradataV2 within intellisense, but that appears to be anybody's guess as to what it does.
Any ways, I'll work with the limitation and move on...
Leave a comment:
-
I can actually comment out both those lines and device creation still short circuits. It's not until I comment out "EDO.AddNamed("My Device data obj", obj)" will my devices all get created. I did just notice that I'm getting a null reference error in homeseer log, so I'm obviously not doing something right. Setting a break point at that line shows that all my obj data looks fine. Switching the two statements doesn't change the behavior.
Originally posted by Moskus View PostI think you need to switch two lines, from this:
Code:dv.PlugExtraData_Set(hs) = EDO hs.SaveEventsDevices()
Code:hs.SaveEventsDevices() dv.PlugExtraData_Set(hs) = EDO
Leave a comment:
-
I think you need to switch two lines, from this:
Code:dv.PlugExtraData_Set(hs) = EDO hs.SaveEventsDevices()
Code:hs.SaveEventsDevices() dv.PlugExtraData_Set(hs) = EDO
Leave a comment:
-
Well I'm kinda stuck again, maybe someone can point me in the right direction. When a user clicks on a device on or off button setioMulti is called. Rick talks about how a best practice would be to use plugextradata to store information pertinent to a device http://board.homeseer.com/showthread.php?t=161861
The problem is, if I understand it correctly, is that I should be able to save a plugextradata object along with the device as the device is being created, there can be one EDO object with multiple named and unnamed objects in each EDO. However when I get to the line " EDO.AddNamed("My Device data obj", obj)" in the code below it seems to short circuit device creation. So I create my first device, add a plugextradata object to it, but then the next device never gets created. What am I missing?
Code:dv.Status_Support(hs) = True dv.UserNote(hs) = "This is for user notes " & dv.Version.ToString 'hs.SetDeviceString(ref, "Not Set", False) ' this will override the name/value pairs dv.Relationship(hs) = Enums.eRelationship.Parent_Root 'Public Property Relationship(ByVal hs As IHSApplication) As Enums.eRelationship = parent 'Accessing the Extra Data object to work with it... Dim EDO As HomeSeerAPI.clsPlugExtraData = Nothing EDO = dv.PlugExtraData_Get(hs) If EDO IsNot Nothing Then Dim obj As Object = Nothing obj = EDO.GetNamed("My Device data obj") If obj IsNot Nothing Then Log("Plug-In Extra Data Object Retrieved = " & obj.ToString, LogType.LOG_TYPE_INFO) End If Else Dim obj As New MyDeviceData() obj.ActiveAmp = MyDeviceData.ActiveAmps.Amp1 obj.mydevice = MyDeviceData.mydevices.Amp1 obj.myDVref = ref.ToString EDO.AddNamed("My Device data obj", obj) End If 'Setting the modified Extra Data object back to the device... dv.PlugExtraData_Set(hs) = EDO '** After calling ".._Set", call hs.SaveEventsDevices to force HomeSeer to save the device that was modified. hs.SaveEventsDevices() End If ref = hs.NewDeviceRef("Zone 1") If ref > 0 Then MyDevice = ref dv = hs.GetDeviceByRef(ref) Dim disp(1) As String
Leave a comment:
-
What HST has been able to do with the platform is impressive, but the plugin samples are a giant pain, so I will be interested in seeing your plugin sample as well.
Truth be told, I think some of the personal plugins I have done work, but I am not sure how lol!
Leave a comment:
-
Going to keep an eye on this thread because eventually I want to write a plugin that allows users to configure my HSMetro UI from within HS. It'll basically adding a new screen to the UI that allows drag/drop reordering, device selection, and server-side xml writing. Nothing crazy, but a nicely documented plugin sample will be a HUGE help!
Leave a comment:
-
Great work Moskus! Looking forward to follow your progress on this.
Leave a comment:
-
Originally posted by U5tabil View PostWhat are you working on? Sounds interesting [emoji2]
I really admire HomeSeer for what they have done, and what they enable for plugin developers. The posiblilites are really endless!
But the code structure of the samples are... uhm... unstructured in my opinion. I'm used to reading SDKs (for Steam, Fitbit, Universal apps for Windows 10, etc), and while the possiblities are many in HomeSeer, the sample code and the code base is also somewhat messy and confusing.
Examples:
Hungarian notation. It's now abandoned by everyone (except old VB coders) at least 10 years ago. Hungarian notation is when you put the string type in front of the variable, so that it's easier to get the variable you want and the idea is that it makes the code easier to read.
That might well be before .NET, but now it's not a problem. Now the recommendation is that if you really have to include the variable type, then add it to the end of the name. So "strName" becomes "NameString".
The main problem is when variables, especially global variables, changes types. This is not uncommon when you start coding. You create a variable called "strLocation" because it is the name of a location and it's a string. As you keep coding, you see that you are not only passing the location name around, but also the GPS location with latitude and longitude, so you create your own class to pass all of this information around:
Code:Public Class Location Public Property Name As String Public Property Latitude As Double Public Property Longitude As Double End Class
I've used Hungarian notation myself. And now when I have to update my old programs, I can see that even my own code, which I am very familiar with, is pretty darn hard to understand sometimes.
Abbreviations. Again something from the "good, old days" before Visual Studio had proper IntelliSense (auto completion) and people coded in Notepad or whatnot. Typing long words was "a vaste of time".
But that results in classes named such as strActTrigInfo that perpahs started out as a string holding Action and/or Trigger information? I have no idea.
Commenting. Perhaps the most important part of any programming project. Escpecially when you are to show your work others. Like in a SDK!
There's no magic way to make a fellow programmer understand how you think. You need to tell him/her. One way is to avoid abbreviations and don't use Hungarian notation, but comments are even more important.
The sample projects have almost no comments!
Some statistics:
- The main sample has 596 lines containing comment marks ( ' ).
- The basic sample has 150 lines containing comment marks.
- My basic sample has 816 lines containing comment marks, and I'm not even done yet!
I'm going through the basic sample line for line, adding comments from the SDK on the web directly and adding comments on my own so that I better understand what's going on.
I understand commenting on a sample plugin is way down on HSTs priority list. I just wish they had done it when they were coding it, it would have made it so much easier to understand.
I want to understand the SDK. That's why I do this. But I don't see why I shouldn't help others getting started with plugins as well. Ultrajones made a similar sample for HS2, and I wouldn't have gotten into plugins at all if it weren't for him. I'm just paying it forward.
Leave a comment:
-
Originally posted by Moskus View PostYou need:
- Visual Studio (Express or Community can be used) with VB.net
- The link to the SDK: http://homeseer.com/support/homeseer...DK/default.htm
- A download of the samples in the first post
- Some experience with scripting, and some grasp of devices and events and how they work. tenScripting is a good idea.
- ALOT of free time
... or wait a week or two until I release the my even more simplified version.
Yeah, I'm not there yet. Do you have a simple break down?
Leave a comment:
-
Originally posted by Moskus View PostYeah, I'm not there yet. Do you have a simple break down?
I spent hours upon hours using debug/trace to follow what it was doing. When it came to subtriggers, I gave up on trying to emulate what they were doing and just used my own object.
I can send you some code samples offline if you want. It may help, or it may just muddy the waters even more.
Leave a comment:
-
Originally posted by U5tabil View PostHow do i even start?
What do i need to do to use this to make something of my own?
- Visual Studio (Express or Community can be used) with VB.net
- The link to the SDK: http://homeseer.com/support/homeseer...DK/default.htm
- A download of the samples in the first post
- Some experience with scripting, and some grasp of devices and events and how they work. tenScripting is a good idea.
- ALOT of free time
... or wait a week or two until I release the my even more simplified version.
Originally posted by rmasonjr View PostTANumber and SubTANumber took quite a while for me to wrap my head around.
Leave a comment:
Leave a comment: