HomeSeer / Plugin-SDK

Plugin development kit for the 4th major edition of the HomeSeer platform.
https://www.nuget.org/packages/HomeSeer-PluginSDK/
GNU Affero General Public License v3.0
20 stars 4 forks source link

UpdateFeatureByRef always fails #44

Closed stefxx closed 4 years ago

stefxx commented 4 years ago

Environment and System Config

I can't get UpdateFeatureByRef to work. UpdateDeviceByRef works just fine. What is the difference? For UpdateFeatureByRef I always get this error: _Invalid type for property Service Version: NOVERSION

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))
hs.UpdateFeatureByRef(ddvf.Ref, ddvf.Changes)

Everything goes well until the last line.

Thanks!

jldubz commented 4 years ago

@stefxx

This is because you are trying to update a feature that does not exist yet. Try creating the feature first with hs.CreateFeatureForDevice()

stefxx commented 4 years ago

@jldubz I am creating the feature with hs.CreateFeatureForDevice() in the second-last line: Dim ddvf As HsFeature = hs.GetFeatureByRef(hs.CreateFeatureForDevice(nfd))