The prototype for CAPIGetControl is as follows:
Public Function CAPIGetControl(ByVal dvRef As Integer) As Collection
Because a device has multiple control options, this function returns a collection. The collection is an older COM compatible VB collection, NOT one of the newer .NET collections so that it may be used by older COM scripts, ASPs, and plug-ins.
The collection is of CAPIControl objects, which have the following properties:
Label() As String
ControlType() As CAPIControlType
ControlValue() As Object
ControlData() As Object
The CAPIControlType is a .NET Enum returned as an Integer value and is defined as follows:
The properties of the CAPIControl object are as follows:
Label - This is what HomeSeer will display as the status if this control option is used. Thus, if a device uses standard device status operations, then it will contain one of On, Off, Dim 0%, Dim 5%, ... Dim 95%. If the device has buttons associated with it, then this is the text that is displayed on the button. If the device has value/status pairs associated with it, then these are the status strings corresponding to particular values. If, for example, you wanted to turn a device ON that does not use the HomeSeer SetDeviceStatus command to operate it, you can search through the labels to find one that says "On", and then use the rest of the CAPIControl object information to invoke that control option.
ControlType - This numerical value indicates the type of control method to use to make the device control action happen, and are explained as follows:
Status - Use the hs.CAPIHandleStatus command. The ControlValue property contains a string command, and the ControlData property contains an integer value for use with the DIM operation.
Values - Use the hs.SetDeviceValue or hs.SetDeviceValueEx commands. The ControlValue property contains an integer value to use in setting the device value.
Button - Use the hs.CAPIHandleButton command. The Label property contains the button label, and the ControlData property contains the button command string, both of which are used with CAPIHandleButton.
IRButton - Use the hs.CAPIHandleIRCommand. The ControlData property contains the data needed for the CAPIHandleIRCommand call.
ControlValue - This object (Variant in older COM software) may contain strings or integers, depending upon the type control defined. See ControlType above.
ControlData - This object (Variant in older COM software) may contain strings or integers, depending upon the type control defined. See ControlType above.
The following example script demonstrates retrieving the control collection, and using it with an IR device and a device that has buttons on it.