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
21 stars 5 forks source link

GetFeatureByRef Returns Nothing even though the ref exists and is a feature #282

Closed sjhill01 closed 2 years ago

sjhill01 commented 2 years ago

Environment

HomeSeer

OS

Windows

HS Version

v4.2.130

Development

PSDK Version

v1.4.1.0

Language

VB

IDE

VS2019

Dev OS

Windows

Plugin

Honeywell WiFi Plugin

Problem

Description

Title says it all. This line of code fully executes (it passes both checks) and still the return value is Nothing:

If hs.DoesRefExist(intRef) And hs.IsRefDevice(intRef) = False Then objFeature = hs.GetFeatureByRef(intRef)

Expected Behavior

Requesting the feature for a valid ref should return the feature.

Steps to Reproduce

See above.

sjhill01 commented 2 years ago

Attempts to do this in other ways also fail; if I try to do this:

Dim objDevice As HsDevice = hs.GetDeviceWithFeaturesByRef(13)

It fails with this error:

HSCF.Communication.ScsServices.Communication.Messages.ScsRemoteException: 'Exception while executing GetDeviceWithFeaturesByRef - devRef : 13 - message : Error while converting 21 to HsFeature : Specified argument was out of the range of valid values.'

(Note that 21 is the specific feature I was trying to get in the original issue, so there's something about that feature that the HS isn't handling well...)

spudwebb commented 2 years ago

can you send me your devices.json so that I can try to reproduce with this specific feature

spudwebb commented 2 years ago

I'm closing this issue, if you still have this problem please reopen and send me the devices.json file.

sjhill01 commented 1 year ago

Sorry, I wasn't getting email notifications from github to the right account so I missed all this. I think I've figured out the problem thanks to this thread: https://forums.homeseer.com/forum/hs4-products/hs4-plugins/utilities-plug-ins-aa/device-history-shill-aa/1594383-upgrade-failure

The bottom line is that if a device has an invalid Status Value/Graphics configuration (overlapping values/ranges) caused by the migration from HS3's way of separating the status/control from graphics to HS4's method of controls vs. status/graphics (sometimes? this is still weird IMO). So if you have a device with a status range of -10 to 10 AND a single value of 0, you'll see Homeseer throw an error in the log when you try to retrieve the device via a plugin/hs.GetDevice call:

2/21/2023 6:50:53 PM HomeSeer Error Error while getting feature 3531 : A status graphic with that value set already exists

followed in my case by:

2/21/2023 6:50:51 PM Device History Error Device Location/Name lookup failed: Object reference not set to an instance of an object

because the result of the request was Nothing.

I no longer have the problem in my environment (so I can't share the json) since I addressed the underlying cause without realizing it was this, and HS4 no longer lets you get devices into this state. But hopefully this is enough detail for you to recreate the problem and provide a solution.