Discussion on this subject is at https://forums.homeseer.com/forum/de...xamples-coming with particular attempts and failures at post #9
Announcement
Collapse
No announcement yet.
VSP for status only features cannot be created
Collapse
X
-
Other examples where attempting to use UpdateFeatureByRef also fails with RemoteException: 'Do not set StatusControls directly Service Version: NO_VERSION'
Code:var updateList = new System.Collections.Generic.Dictionary<HomeSeer.PluginSdk.Devices.EProperty, Object>(); var vsp = new HomeSeer.PluginSdk.Devices.Controls.StatusControl(HomeSeer.PluginSdk.Devices.Controls.EControlType.Button); vsp.Label = _label; vsp.TargetValue = idValue; updateList.Clear(); updateList.Add(HomeSeer.PluginSdk.Devices.EProperty.StatusControls, vsp); _hs.UpdateFeatureByRef(modeRef, updateList);
Code:var vsp = new HomeSeer.PluginSdk.Devices.Controls.StatusControl(HomeSeer.PluginSdk.Devices.Controls.EControlType.Button); vsp.Label = _label; vsp.TargetValue = idValue; feature.StatusControls.Add(vsp);
-
I think the issue with trying to update a feature is that it needs to be done with the update methods rather than directly on the feature object. Don't know which enumeration of properties handles VSP and VGP or if a method yet exits.
The following is example while it is being created with feature factory. The first case is a button where the status reported is different than the button. The second case is without button. I think I have also done it where the graphic is null such as the third case. The fourth case is for a range rather than single value.
Code:#1 ff.AddButton(0, "departed", null, HomeSeer.PluginSdk.Devices.Controls.EControlUse.Off); ff.AddButton(255, "arrived", null, HomeSeer.PluginSdk.Devices.Controls.EControlUse.On); ff.AddGraphicForValue("/images/HomeSeer/status/away.png", 0,"not present"); ff.AddGraphicForValue("/images/HomeSeer/status/home.png", 255, "present"); #2 ff.AddGraphicForValue("/images/HomeSeer/status/away.png", 0,"not present"); ff.AddGraphicForValue("/images/HomeSeer/status/home.png", 255, "present"); #3 ff.AddGraphicForValue("", 0,"not present"); ff.AddGraphicForValue("", 255, "present"); #4 ff.AddGraphicForRange("/images/HomeSeer/status/custom-color.png", 0, max,"hot");
Comment
-
Thanks, appreciate your help. I tried to remove everything unnecessary to reproduce the error. The thing is, I need to separate the device creation from the feature creation, as not all required features are known upfront. So here is the code I am using:
' Create device
Dim ddf As DeviceFactory = DeviceFactory.CreateDevice(PI_Id)
ddf.WithName("Name")
ddf.AsType(Identification.EDeviceType.Generic, 0)
Dim dndd As NewDeviceData = ddf.PrepareForHs()
Dim ddv As HsDevice = hs.GetDeviceByRef(hs.CreateDevice(dndd))
hs.UpdateDeviceByRef(ddv.Ref, ddv.Changes)
' Create feature
Dim dff As FeatureFactory = FeatureFactory.CreateFeature(PI_Id)
dff.WithName("Feature1")
dff.AsType(Identification.EFeatureType.Generic, 0)
Dim nfd As NewFeatureData = dff.PrepareForHsDevice(ddv.Ref)
Dim ddvf As HsFeature = hs.GetFeatureByRef(hs.CreateFeatureForDevice(nfd))
'ddv.Features.Add(ddvf) ' is this neccesary?
'dff.AddGraphicForValue("/images/HomeSeer/status/away.png", 0, "not present")
'dff.AddGraphicForValue("/images/HomeSeer/status/home.png", 255, "present")
hs.UpdateFeatureByRef(ddvf.Ref, ddvf.Changes)
The last line (UpdateFeatureByRef) returns an error:
Failed to get robot information: Invalid type for property
Service Version: NO_VERSION
If I omit the UpdateFeatureByRef it works, but the feature is not completely saved.stefxx
Comment
-
I looked back at the SDK and there does exist EProperty for VSP And VGP (StatusControls and StatusGraphics) This means that once you have your StatusControl objected formatted the way you want then you update the feature using UpdatePropertyByRef. I don't know the situation when you would use UpdateFeatureByRef.
UpdatePropertyByRef(featureRef, HomeSeer.PluginSdk.Devices.EProperty.StatusGraphic, statusGraphicObject)
Comment
-
I gave it a try to use UpdatePropertyByRef for StatusControl and have same error about NO_VERSION when it is executed. I also tried to directly add the StatusControl and it ran, but no actual change in the feature VSP's. The code below has both approaches with the commented-out lines with the UpdatePropertyByRef approach. This means the original bug report still remains unsolved.
Code:Dim sGraphicPath As String = "images/HomeSeer/status/" 'Dim PairCollection As New HomeSeer.PluginSdk.Devices.Controls.StatusControlCollection 'Dim GraphicCollection As New HomeSeer.PluginSdk.Devices.StatusGraphicCollection Dim feature As HomeSeer.PluginSdk.Devices.HsFeature = hs.GetFeatureByRef(iRef) For Each kvp As KeyValuePair(Of String, Integer) In oMQTT.GetVGP Dim sGraphic As String Dim Pair As New HomeSeer.PluginSdk.Devices.Controls.StatusControl(Devices.Controls.EControlType.Button) iPair = kvp.Value Dim arrGraphic As String() = GetGraphic(kvp.Key) If iPair = 0 Then sGraphic = arrGraphic(0) Pair.ControlUse = HomeSeer.PluginSdk.Devices.Controls.EControlUse.Off ElseIf iPair = 1 Then sGraphic = arrGraphic(1) Pair.ControlUse = HomeSeer.PluginSdk.Devices.Controls.EControlUse.On Else sGraphic = "dim-" & (iPair - 1).ToString & "0.gif" Pair.ControlUse = HomeSeer.PluginSdk.Devices.Controls.EControlUse.NotSpecified End If Pair.IsRange = False Pair.TargetValue = CType(kvp.Value, Double) Pair.Label = kvp.Key Pair.ControlUse = HomeSeer.PluginSdk.Devices.Controls.EControlUse.NotSpecified 'PairCollection.Add(Pair) feature.StatusControls.Add(Pair) If (oMQTT.Misc And HomeSeer.PluginSdk.Devices.EMiscFlag.NoGraphicsDisplay) <> 0 Then 'if graphics have already been defined then dont update them Dim vgPair As New HomeSeer.PluginSdk.Devices.StatusGraphic(sGraphicPath & sGraphic, CType(kvp.Value, Double)) 'GraphicCollection.Add(vgPair) feature.StatusGraphics.Add(vgPair) End If Next If (oMQTT.Misc And HomeSeer.PluginSdk.Devices.EMiscFlag.NoGraphicsDisplay) <> 0 AndAlso oMQTT.StatusType = StatusTypes.StatusOnly Then Dim iMisc As Integer = (HomeSeer.PluginSdk.Devices.EMiscFlag.NoGraphicsDisplay Xor &HFFFFFFFF) 'enable graphics oMQTT.Misc = oMQTT.Misc And iMisc End If 'hs.UpdatePropertyByRef(iRef, HomeSeer.PluginSdk.Devices.EProperty.StatusControls, PairCollection) 'hs.UpdatePropertyByRef(iRef, HomeSeer.PluginSdk.Devices.EProperty.StatusGraphics, GraphicCollection)
Comment
-
What I have had success with is to use ClearStatusControlsByRef if needed and then use AddStatusControlToFeature to add the VSP to the Feature. Same process for Graphics with equivalent methods.
Code:Dim sGraphicPath As String = "images/HomeSeer/status/" 'Dim PairCollection As New HomeSeer.PluginSdk.Devices.Controls.StatusControlCollection 'Dim GraphicCollection As New HomeSeer.PluginSdk.Devices.StatusGraphicCollection 'Dim feature As HomeSeer.PluginSdk.Devices.HsFeature = hs.GetFeatureByRef(iRef) For Each kvp As KeyValuePair(Of String, Integer) In oMQTT.GetVGP Dim sGraphic As String Dim Pair As New HomeSeer.PluginSdk.Devices.Controls.StatusControl(Devices.Controls.EControlType.Button) iPair = kvp.Value Dim arrGraphic As String() = GetGraphic(kvp.Key) If iPair = 0 Then sGraphic = arrGraphic(0) Pair.ControlUse = HomeSeer.PluginSdk.Devices.Controls.EControlUse.Off ElseIf iPair = 1 Then sGraphic = arrGraphic(1) Pair.ControlUse = HomeSeer.PluginSdk.Devices.Controls.EControlUse.On Else sGraphic = "dim-" & (iPair - 1).ToString & "0.gif" Pair.ControlUse = HomeSeer.PluginSdk.Devices.Controls.EControlUse.NotSpecified End If Pair.IsRange = False Pair.TargetValue = CType(kvp.Value, Double) Pair.Label = kvp.Key Pair.ControlUse = HomeSeer.PluginSdk.Devices.Controls.EControlUse.NotSpecified 'PairCollection.Add(Pair) hs.AddStatusControlToFeature(iRef, Pair) 'feature.StatusControls.Add(Pair) If (oMQTT.Misc And HomeSeer.PluginSdk.Devices.EMiscFlag.NoGraphicsDisplay) <> 0 Then 'if graphics have already been defined then dont update them Dim vgPair As New HomeSeer.PluginSdk.Devices.StatusGraphic(sGraphicPath & sGraphic, CType(kvp.Value, Double)) 'GraphicCollection.Add(vgPair) hs.AddStatusGraphicToFeature(iRef, vgPair) 'feature.StatusGraphics.Add(vgPair) End If Next
Comment
-
stefxx
Please see IHSController.CreateFeatureForDevice(NewFeatureData featureData) for adding features to devices. It is important to note that calling to HomeSeer to update any device/feature will not automatically update local references and vice versa. This is why you must call methods like UpdatePropertyByRef() and AddStatusGraphicToFeature() to explicitly update the references in HomeSeer. All instances of an HsDevice or HsFeature in your plugin code should be considered immutable for this reason. Local changes, except Controls and Graphics, can be committed by pulling the AbstractHsDevice.Changes field and pushing the contained changes to HomeSeer with the relevant methods.
For future reference, I highly recommend posting your issues in the Issues section of the Plugin SDK GitHub repository: https://github.com/HomeSeer/Plugin-SDK/issues to get the fastest responses from the HS development team regarding any questions about implementing the Plugin SDK in your projects.
Albeit still a work in progress, you can also find a list of all of the members available in the Plugin SDK through the API Reference here: https://docs.homeseer.com/display/HS...nSdk+Namespace.
Comment
-
I have been trying to follow HST guidance on issue resolution. It may be obvious to HST what is a SDK issue vs what is a HS4 issue vs. something that is not easy categorized. We have the same thing bow with the Legacy plugins test plans. What is a issue of HS3 plugin working under HS4 and HS4 issue that could be SDK or could be HS4 or could be something else. I find myself submitting the same issue under multiple places and still do not have any feedback on my issues. I still need to test every release to see if the issues I submitted still exist or not. It seems there is yet another issue system thst was introduced when power users were invited to the mix. A single clearinghouse for all issues would be best to serve all those involved.
Comment
-
If you are using the PluginSDK, create an issue on the GitHub repository. If you are not using the PluginSDK, ie discussing how your HS3 plugin is displayed in the new UI or noting basic functionality issues etc, post it here.
We were trying to separate HS4 "feedback" from actual bugs in the SDK development. This is because there is little we can do from an SDK perspective when the issue is something involving general HS4 use like adjusting settings etc, but that got a lot of wires crossed. Apologies for the confusion. I'm not sure what issue tracking mechanisms you are speaking about other than this forum and the GitHub page; as those are the only ones noted in any of the documentation on getting support. I have not seen any issues from you on the GitHub page yet; it's actually oddly quiet. I recommend that you try creating some tickets over there for any issues you are running into while developing with the Plugin SDK and encouraging others to do the same.
Comment
-
I have submitted tickets on GitHub for the SDK when I was following the guidance in the SDK on how to create a plugin. I posted issues where the guidance was wrong, missing, etc as those were errors in the SDK. i.e. the documentation in the SDK is in error.
If I am trying to use the info from the SDK to migrate my HS3 plugin and it is not working for me or seems like I am not able to do what I want with that which is documented then I have been posting on the forum to get guidance and community support. I did not view it as an error in the SDK because I don't know how to do something. Apparently you want all communication to be on Github and in that case I do not see why this forum topic exists.
The recently added forum for HS4 power users is at https://forums.homeseer.com/forum/de...esting-private. In Rich's sticky post there the following instructions are provided:
Legacy Plugin Test Doc
If you run into any issues with any of your plugins, please log the issues in the Plugin Test Doc:
https://docs.google.com/document/d/1...it?usp=sharing
Comment
-
Originally posted by JLDubz View PoststefxxFor future reference, I highly recommend posting your issues in the Issues section of the Plugin SDK GitHub repository: https://github.com/HomeSeer/Plugin-SDK/issues to get the fastest responses from the HS development team regarding any questions about implementing the Plugin SDK in your projects.
Really disappointing... again. I am so close in finalizing my first HS4 plugin, but this is really killing motivation.stefxx
- Likes 2
Comment
Comment