SetIO and SetIOEx are callbacks HomeSeer will make into your plug-in when a device that your plug-in owns is controlled. Your plug-in owns a device when it's INTERFACE property is set to the name of your plug-in.
Before SetIO is called in your plug-in, the procedure SupportsHS2 is called. If your plug-in has it and True is returned from that procedure, then SetIOEx is called instead of SetIO.
There are controls on whether SetIO(Ex) is called. These controls affect changes to the device status or value using the hs script commands, which is generally done by scripts but can also be done by other plug-ins. If hs.SetDeviceStatus is used, the call to SetIO(Ex) will only be made if the MISC_SETSTATUS_NOTIFY bit of the device's MISC property is set. If hs.SetDeviceValue is used, the call to SetIO(Ex) will only be made if the MISC_SETVALUE_NOTIFY bit of the device's MISC property is set.
SetIO(Ex) is only called for the plug-in that owns the device UNLESS the user's system has the following setting in the SETTINGS.INI file:
[Settings]
SetIOOwner=False
When set to False, SetIO(Ex) is called in all plug-ins, not just the owning plug-in.
The prototype for SetIO and SetIOEx are as follows:
Public Sub SetIO(dv as Object, housecode as String, devicecode as String,
command as Short, brightness as Short, data1 as Short, data2 as Short)
Public Sub SetIOEx(dv as Object, housecode as String, devicecode as String,
command as Short, brightness as Short, data1 as Short, data2 as Short,
voice_command as String, host as String)
The parameters passed to SetIO are as follows - depending upon what generated the SetIO call, not all parameters will contain data. Be sure to test for "Is Nothing" before testing for values or your plug-in may generate an exception error when a variable passed is uninitialized.
dv - This is a device class object reference for the device that was changed. It is not always included.
housecode - The housecode for the device, which may not always be upper case or lower case.
devicecode - The devicecode for the device, which should always be in the range from "1" to "99". Use Val() or CShort() with devicecode.Trim to convert it to a numerical value. When several devices are changed with HomeSeer's multi-device actions, the devicecode may be a string of device unit numbers separated by a "+" character as in this example: 1+6+9
command - The device command numerical value.
brightness - The bright or dim value provided to the bright/dim command.
data1 & data2 - When an X-10 extended data command is used, these contain the data bytes.
voice_command - When a device was changed in response to a voice command, this parameter is the voice command that was used to trigger the change.
host - If a voice command was used to change a device, the host parameter is the hostname:instance of the speaker client that the voice command originated from.