I'm tinkering with an example from the HS documentation... getting the ID of a device by device name is turning out to be problematic for some reason. I'm populating a variable with the device name and when the code executes the device ID value is -1 but when I replace the variable with the actual device name text that is populating the variable I get the device ID.
From the log using the variables
deviceID: -1
devicename: kitchen light
From the log using entered text
deviceID: 81
devicename: kitchen light
I'm at a loss why I'm getting a -1 value when I'm populating with valid device values
Code:
Dim objCAPIControl As CAPIControl Dim dvRef As Integer dvRef = hs.GetDeviceRefByName("" & room & device & "") hs.WriteLog("BuildRequest()", "deviceID: " & dvRef) hs.WriteLog("BuildRequest()", "devicename: " & room & device) objCAPIControl = hs.CAPIGetSingleControlByUse(dvRef, ePairControlUse._On) If objCAPIControl IsNot Nothing Then hs.CAPIControlHandler(objCAPIControl) End If
deviceID: -1
devicename: kitchen light
From the log using entered text
deviceID: 81
devicename: kitchen light
I'm at a loss why I'm getting a -1 value when I'm populating with valid device values
Comment