When you wish to have HomeSeer call back in to your plug-in or application when certain events happen in the system, call the RegisterEventCB procedure and provide it with an object from your plug-in or application that has an HSEvent procedure.
For instance, you can call into HomeSeer and register a form object that will be called when HomeSeer receives an X10 command. Call the following function:
hs.RegisterEventCB evtype As Integer, obj as Object
The evtype parameter is a bitmap of event types. The event types are defined as follows:
|
Event Name |
Value (Hex) |
Value (Decimal) |
Description |
|
EV_TYPE_X10 |
1 |
1 |
X10 received event |
|
EV_TYPE_LOG |
2 |
2 |
A message written to the event log |
|
EV_TYPE_STATUS_CHANGE |
4 |
4 |
A device changed status (value or status) |
|
EV_TYPE_AUDIO |
8 |
8 |
Audio start or stop |
|
EV_TYPE_X10_TRANSMIT |
10 |
16 |
Transmit X10 event |
|
EV_TYPE_CONFIG_CHANGE |
20 |
32 |
Device or event has changed |
|
EV_TYPE_STRING_CHANGE |
40 |
64 |
Device's string value has changed |
|
EV_TYPE_SPEAKER_CONNECT |
80 |
128 |
Speaker client connected to HomeSeer |
|
EV_TYPE_CALLER_ID |
100 |
256 |
Caller ID Information |
|
EV_TYPE_ZWAVE |
200 |
512 |
Z-Wave device changes |
|
EV_TYPE_VALUE_CHANGE |
400 |
1024 |
Device's value has changed |
|
EV_TYPE_STATUS_ONLY_CHANGE |
800 |
2048 |
Device's status changed. (Is not raised when the value changes.) |
|
EV_TYPE_GENERIC |
8000 |
32768 |
Generic event raised by other plug-ins and scripts. |
The obj parameter should be a reference to a form or class object with the following method declared public:
Public Sub HSEvent(parms As Object)
Note: Use Variant instead of Object in non .NET plug-ins.
The parameters are passed in an array of objects. Each entry in the array is a parameter. The number of entries depends on the type of event and are described below. The event type is always present in the first entry or parms(0).
The parms(0) event type is defined as follows:
1
= X10 event
2
= Event log message event
4
= Device status change
8
= Audio start/stop
16
= Transmit X10
32
= Configuration change
64
= Device string change
128 = Speaker Client Connect
256 = Caller ID Event
512 = Z-Wave Device Event
1024 = Value Change Event
2048 = Status Change Only Event
32768 = Generic Event
Other events may be added in the future.
IMPORTANT:
Although not shown in the older VB6 sample below, you must provide error
trapping in your HSEvent procedure. If
an error occurs in this procedure when HomeSeer calls it, HomeSeer will
remove the callback and will no longer make the HSEvent callback for that
event type to your plug-in until you re-register the callback.
HomeSeer will then call the HSEvent method when the requested event is available. Note that this method should return as quickly as possible as to not interfere with normal HomeSeer event processing. Here is some sample code for a client using the HomeSeer server. Add a reference to the "HomeSeer" object to your project.
|
parms(1)=devices |
Device string like "A1+2" |
|
parms(2)=housecode |
The house code the command was heard on, such as "A". |
|
parms(3)=command |
The actual X10 command, in the range 1-16. |
|
parms(4)=dim_level |
Normally the dim level from a dim command or data byte 1 for the extended X10 command. |
|
parms(5)=data2 |
Data byte 2 for the extended X10 command. |
Parameters for the Event Log event are:
|
parms(1)=date_time |
Date and time of log entry. |
|
parms(2)=msg_class |
Type of log entry, i.e., "speak" or "ERROR". |
|
parms(3)=msg |
The actual event log message. |
Parameters for the Device Status Change event are:
|
parms(1)=device |
The device that changed status. |
|
parms(2)=housecode |
The house code of the device that changed status. |
|
parms(3)=command |
The X10 command sent to the device. |
|
parms(4)=extra |
The first byte of extended data, such as dim level. |
|
parms(5)=data2 |
The second byte of the extended X10 command. |
Parameters for the Audio event are:
|
parms(1)=started |
TRUE means that the audio channel is now being used (HomeSeer is speaking or a WAV file is playing). When True, it indicates when there is audio activity at any of the speaker apps. For instance, if an event is to go to all speaker apps and there are 3 apps running, then 3 will be returned. If an event goes to a specific speaker app then only 1 will be returned. FALSE means that the device is now free. |
|
parms(2)=typeid |
This is the type of audio that is being played. 0 is for TTS (HomeSeer speaking) and 100 is for WAV files. |
Parameters for the Transmit X10 event are:
|
parms(1)=devices |
This is a device string, such as "A1+2". |
|
parms(2)=housecode |
This is the house code the command was heard on, such as "A". |
|
parms(3)=command |
This is the actual X10 command, in the range 1-16. |
|
parms(4)=dim_level |
This is normally the dim level from a dim command, or the preset dim level for a preset dim command. |
|
parms(5)=data1 |
This is data byte 1 for the extended X10 command. |
|
parms(6)=data2 |
This is data byte 2 for the extended X10 command. |
Parameters for the Configuration Change event are:
|
parms(1)=type |
0=a device was changed 1=an event was changed |
|
parms(2)=id |
The index ID of the device or event that was change. 0 means that the ID is not known such as when a device or event is deleted. |
|
parms(3)=ref |
The device reference number or event reference number. 0 means that the reference is not known such as when a device or event is deleted. |
To get a reference to the actual device that
was modified, use set dv = hs.GetDeviceByRef(ref).
To get a reference to the actual event that was modified, use set ev =
hs.GetEventByRef(ref).
The ID may be 0, which means either multiple events or devices were modified, the device or event was deleted, or the device or event was modified from a script, which means the device/event ID was not known.
Parameters for the Device String Change event are:
|
parms(1)=hcuc |
The house code and unit code of the device that changed (string value). |
|
parms(2)=txt |
The new value for the device string (what it's changing to). |
Devices may have duplicate
house codes and unit codes to other devices, so you may have to check
for other devices sharing the same address.
ParametersSpeakerClientConnect ParametersCallerID
Parameters for the Speaker Client Connect event are:
|
parms(1)=host |
The host computer (name) that the speaker client is on. |
|
parms(2)=instance |
The instance name of the speaker client connecting - if an instance name is not specified, the speaker client uses 'Default' as the instance name. |
|
parms(3)=cStatus |
Connection Status is 0 for disconnect, 1 for connect. |
|
parms(4)=IPAddr |
The IP address of the host machine where the speaker client resides. |
Speaker client disconnects may not always register due to network problems.
Parameters for the Caller ID event are:
|
parms(1)=CIDNumber |
The Caller ID reported phone number from the phone company. |
|
parms(2)=CIDName |
The Caller ID reported caller name from the phone company. |
|
parms(3)=dir_last |
Last name from the entry in the address book matching CIDNumber. |
|
parms(4)=dir_first |
First name from the entry in the address book matching CIDNumber. |
|
parms(5)=dir_company |
Company name from the entry in the address book matching CIDNumber. |
|
parms(6)=line |
The line number that the CID information was obtained from. |
You must have the Caller ID Name service in order to receive CIDName data, otherwise this will be blank.
Parameters for the Z-Wave event are:
|
parms(1)=device ref ID |
The unique device reference ID number. |
|
parms(2)=level |
The new level of the device. |
Parameters for the device Value change event are:
|
parms(1)=device code |
The device code of the device with the changed value. |
|
parms(2)=house code |
The house code of the device with the changed value. |
|
parms(3)=new value |
The new value of the device. |
|
parms(4)=old value |
The old value of the device. |
Parameters for the device Status Only change event are:
|
parms(1)=device code |
The device code of the device with the changed value. (May list multiple devices) |
|
parms(2)=house code |
The house code of the device with the changed status. |
|
parms(3)=Command |
The X-10 command sent to the device. |
|
parms(4)=extra |
The first byte of extended data, such as dim level. |
|
parms(5)=Data2 |
The second byte of the extended X10 command. |
Parameters for the Generic Type event are:
|
parms(1)=Generic Event |
The generic event string describing this event type. |
|
parms(2)=Sender |
The plug-in name (if an object was used) or name string (if called from a script) that identifies the plug-in or script that raised this event. |
|
parms(3...n)=Parms |
The parameters that were provided by the plug-in or script that called RaiseGenericEventCB. |