RegisterStatusChangeCB

Purpose

HomeSeer has the ability to trigger events based on the status of a device changing.  This is set in the event properties for the event.  It may be useful to run a script when a device changes status.  The RegisterStatusChangeCB function can be used to register your script with HomeSeer.  When a device changes status, your script will be called.  The script is passed the house code and unit code of the device that changed status, as well as the status the device changed to and the reference ID of the device.

To remove the callback script, call hs.UnRegisterStatusChangeCB.  There are no parameters with this call.

Remarks

When a device changes status, the given script is called as follows:

script_name( parm )

The parms parameter is an array of parameters.  The following parameters are available:

parm(0) = house code of the device that changed status
parm(1)
= device code of the device that changed status
parm(2)
= the X10 status that the device changed to.
parm(3)
= the device reference number.  Can be used with GetDevice to find the DeviceClass of the specific device.

Note that since a function can be called in the callback script, the registration and actual callback can all reside in the same script file.

Parameters

Parameter: script
Type: string
Description: This is the file name of the script to run.  Do not include the path in the script name; the script is assumed to be in the scripts directory (C:\Program Files\HomeSeer 2\Scripts by default).

Parameter: function
Type: string
Description: This is the function in the script to run, such as main.

Returns

None.

Example

' register a callback script

sub main()

hs.RegisterStatusChangeCB "stat_change.txt","statuscb"

end sub

' the actual status change script that is called when a device changes status given the above register call

sub statuscb(parm)

dim hc
dim dc

dim status


hc = parm(0)

dc = parm(1)

status = parm(2)

   end sub