New Home

Recent Updates

New Home
Please visit us at our new home. All content has been moved there.














































































Display all Insteon Events with Visual Basic 6

There are a lot of events that you can receive in Visual Basic. To learn what they are, we have made this simple snippet of code.

What it does is create an event sub for each of the SmartHome Device Managers events. Then you can simply run this code and watch events fly by. After a while, you'll get an idea of which events are available and can start writing your own code.

Start with a blank Form. Add a listbox to it called ListBox1. In the form, paste the following code (warning: you will have to remove the line breaks if you copy and paste from this HTML page, instead, get it from here)

 

Option Explicit
Dim WithEvents sm As SDM3Server.SDM3

Private Sub Form_Load()
Set sm = New SDM3Server.SDM3
End Sub

Private Sub sm_OnButtonTapEvent(ByVal buttonID As Integer)
lstInsteon.AddItem buttonID
End Sub

Private Sub sm_OnConnectedAndReady()
lstInsteon.AddItem "CNR"
End Sub

Private Sub sm_OnEvent(ByVal eventID As Integer)
lstInsteon.AddItem eventID
End Sub

Private Sub sm_OnINSTEON(ByVal eventID As Integer, ByVal fromID As String, ByVal toID As String, ByVal flags As Integer, ByVal cmd1 As Integer, ByVal cmd2 As Integer, ByVal extendedData As String)
lstInsteon.AddItem "eventID: " & eventID & " - fromID: " & fromID & " - toID: " & toID & " - flags: " & flags & " - cmd1: " & cmd1 & " - cmd2: " & cmd2 & " - extendedData: " & extendedData, 0
End Sub

Private Sub sm_OnINSTEONPacket(ByVal fromID As String, ByVal toID As String, ByVal flags As Integer, ByVal cmd1 As Integer, ByVal cmd2 As Integer, ByVal extendedData As String)
lstInsteon.AddItem "PACKET - eventID: " & eventID & " - fromID: " & fromID & " - toID: " & toID & " - flags: " & flags & " - cmd1: " & cmd1 & " - cmd2: " & cmd2 & " - extendedData: " & extendedData, 0
End Sub

Private Sub sm_OnMyINSTEONMessage(ByVal fromID As String, ByVal flags As Integer, ByVal cmd1 As Integer, ByVal cmd2 As Integer, ByVal extendedData As String)
lstInsteon.AddItem "MY - fromID: " & fromID & " - toID: " & toID & " - flags: " & flags & " - cmd1: " & cmd1 & " - cmd2: " & cmd2 & " - extendedData: " & extendedData, 0
End Sub

Private Sub sm_OnNAKINSTEON()
lstInsteon.AddItem "NAK"
End Sub

Private Sub sm_OnOtherINSTEONMessage(ByVal fromID As String, ByVal toID As String, ByVal flags As Integer, ByVal cmd1 As Integer, ByVal cmd2 As Integer, ByVal extendedData As String)
lstInsteon.AddItem "OTHER - fromID: " & fromID & " - toID: " & toID & " - flags: " & flags & " - cmd1: " & cmd1 & " - cmd2: " & cmd2 & " - extendedData: " & extendedData, 0
End Sub

Private Sub sm_OnSALADText(ByVal Text As String)
lstInsteon.AddItem "SALADText: " & Text
End Sub

Private Sub sm_OnText(ByVal Text As String)
lstInsteon.AddItem "sm_onText: " & Text
End Sub

Private Sub sm_OnTickEvent()
lstInsteon.AddItem "Tick..."
End Sub

Private Sub sm_OnUSBArrival(ByVal vendorID As Long, ByVal productID As Long)
lstInsteon.AddItem venderID & ":" & productID
End Sub

Private Sub sm_OnX10Address(ByVal x10text As String)
lstInsteon.AddItem "X10 Address: " & x10text, 0
End Sub

Private Sub sm_OnX10Command(ByVal x10text As String)
lstInsteon.AddItem "X10 Command: " & x10text, 0
End Sub

Private Sub sm_OnX10Extended(ByVal x10data As String)
lstInsteon.AddItem "X10 Extended: " & x10data, 0
End Sub


 

 

Jason Bauer

Written by

Jason Bauer is an owner and programmer for Portforward.com. He's allergic to twitter and facebook, but you can find more of his articles in the Guides section.
 
Saturday, 12-Oct-2024 01:32:28 PDT